Skip to content

Commit f13c65c

Browse files
authored
Merge pull request awslabs#1 from aniloncloud/aws-location-mcp-server-new-tools
feat: Add AWS Location Service Geo-Places Functionality to MCP Server
2 parents df5abba + 75dc7e6 commit f13c65c

File tree

7 files changed

+1067
-392
lines changed

7 files changed

+1067
-392
lines changed

.secrets.baseline

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -133,40 +133,6 @@
133133
}
134134
],
135135
"results": {
136-
"src/aws-location-mcp-server/tests/test_server.py": [
137-
{
138-
"type": "AWS Access Key",
139-
"filename": "src/aws-location-mcp-server/tests/test_server.py",
140-
"hashed_secret": "4283ebd4fe8e41100063ee91ae46f317c02b8613",
141-
"is_verified": false,
142-
"line_number": 156,
143-
"is_secret": false
144-
},
145-
{
146-
"type": "AWS Access Key",
147-
"filename": "src/aws-location-mcp-server/tests/test_server.py",
148-
"hashed_secret": "d70eab08607a4d05faa2d0d6647206599e9abc65",
149-
"is_verified": false,
150-
"line_number": 157,
151-
"is_secret": false
152-
},
153-
{
154-
"type": "Base64 High Entropy String",
155-
"filename": "src/aws-location-mcp-server/tests/test_server.py",
156-
"hashed_secret": "d70eab08607a4d05faa2d0d6647206599e9abc65",
157-
"is_verified": false,
158-
"line_number": 157,
159-
"is_secret": false
160-
},
161-
{
162-
"type": "Secret Keyword",
163-
"filename": "src/aws-location-mcp-server/tests/test_server.py",
164-
"hashed_secret": "d70eab08607a4d05faa2d0d6647206599e9abc65",
165-
"is_verified": false,
166-
"line_number": 157,
167-
"is_secret": false
168-
}
169-
],
170136
"src/bedrock-kb-retrieval-mcp-server/README.md": [
171137
{
172138
"type": "Base64 High Entropy String",
@@ -204,5 +170,5 @@
204170
}
205171
]
206172
},
207-
"generated_at": "2025-05-01T21:57:42Z"
173+
"generated_at": "2025-05-06T15:59:56Z"
208174
}

src/aws-location-mcp-server/README.md

Lines changed: 231 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,40 @@ A Model Context Protocol (MCP) server that provides access to AWS Location Servi
55
## Features
66

77
- Search for places using geocoding
8-
- Get coordinates for locations
8+
- Get details for specific places by PlaceId
9+
- Reverse geocode coordinates to addresses
10+
- Search for places near a location
11+
- Search for places that are currently open
912

1013
## Prerequisites
1114

1215
Before using this MCP server, you need to:
1316

1417
1. Have an AWS account with AWS Location Service enabled
15-
2. Create a Place Index in AWS Location Service (or the server will attempt to use an existing one)
16-
3. Configure AWS CLI with your credentials and profile
18+
2. Configure AWS CLI with your credentials and profile
1719

1820
## Installation
1921

22+
There are two ways to install and configure the AWS Location MCP server:
23+
24+
### Option 1: Using uvx (Recommended)
25+
26+
This is the standard way to install MCP servers and is consistent with other AWS MCP servers:
27+
28+
```bash
29+
# Install the package using uvx
30+
uvx awslabs.aws-location-mcp-server@latest
31+
```
32+
33+
### Option 2: Local Development Installation
34+
35+
If you're developing or modifying the server, or if Option 1 doesn't work:
36+
2037
```bash
38+
# Clone the repository (if you haven't already)
39+
git clone https://github.com/awslabs/mcp.git
40+
cd mcp/src/aws-location-mcp-server
41+
2142
# Create a virtual environment
2243
python -m venv .venv
2344
source .venv/bin/activate # On Windows: .venv\Scripts\activate
@@ -30,20 +51,97 @@ pip install -e .
3051

3152
Configure the server in your MCP settings:
3253

54+
### Option 1: Standard Configuration (Recommended)
55+
3356
```json
3457
{
3558
"mcpServers": {
36-
"awslabs.aws-location-mcp-server": {
59+
"github.com/awslabs/mcp/tree/main/src/aws-location-mcp-server": {
60+
"autoApprove": [
61+
"search_places",
62+
"get_place",
63+
"reverse_geocode",
64+
"search_nearby",
65+
"search_places_open_now"
66+
],
67+
"disabled": false,
68+
"timeout": 60,
3769
"command": "uvx",
38-
"args": ["awslabs.aws-location-mcp-server@latest"],
70+
"args": [
71+
"awslabs.aws-location-mcp-server@latest"
72+
],
73+
"env": {
74+
"AWS_PROFILE": "your-aws-profile",
75+
"AWS_REGION": "us-east-1",
76+
"FASTMCP_LOG_LEVEL": "ERROR"
77+
},
78+
"transportType": "stdio"
79+
}
80+
}
81+
}
82+
```
83+
84+
### Option 2: Local Development Configuration - Direct Python Executable (Recommended for local development)
85+
86+
This approach directly uses the Python executable from the virtual environment:
87+
88+
```json
89+
{
90+
"mcpServers": {
91+
"github.com/awslabs/mcp/tree/main/src/aws-location-mcp-server": {
92+
"autoApprove": [
93+
"search_places",
94+
"get_place",
95+
"reverse_geocode",
96+
"search_nearby",
97+
"search_places_open_now"
98+
],
99+
"disabled": false,
100+
"timeout": 60,
101+
"command": "/path/to/mcp/src/aws-location-mcp-server/.venv/bin/python",
102+
"args": [
103+
"-m",
104+
"awslabs.aws_location_server.server"
105+
],
39106
"env": {
40107
"AWS_PROFILE": "your-aws-profile",
41108
"AWS_REGION": "us-east-1",
42-
"FASTMCP_LOG_LEVEL": "ERROR",
43-
"AWS_LOCATION_PLACE_INDEX": "your-place-index-name"
109+
"FASTMCP_LOG_LEVEL": "ERROR"
44110
},
111+
"transportType": "stdio"
112+
}
113+
}
114+
}
115+
```
116+
117+
### Option 3: Local Development Configuration - Using bash
118+
119+
An alternative approach using bash to activate the virtual environment:
120+
121+
```json
122+
{
123+
"mcpServers": {
124+
"github.com/awslabs/mcp/tree/main/src/aws-location-mcp-server": {
125+
"autoApprove": [
126+
"search_places",
127+
"get_place",
128+
"reverse_geocode",
129+
"search_nearby",
130+
"search_places_open_now"
131+
],
45132
"disabled": false,
46-
"autoApprove": []
133+
"timeout": 60,
134+
"command": "bash",
135+
"args": [
136+
"-c",
137+
"cd /path/to/mcp/src/aws-location-mcp-server && source .venv/bin/activate && python -m awslabs.aws_location_server.server"
138+
],
139+
"env": {
140+
"AWS_PROFILE": "your-aws-profile",
141+
"AWS_REGION": "us-east-1",
142+
"FASTMCP_LOG_LEVEL": "ERROR"
143+
},
144+
"transportType": "stdio"
47145
}
48146
}
49147
}
@@ -56,17 +154,17 @@ Configure the server in your MCP settings:
56154
- `AWS_PROFILE`: AWS CLI profile to use for credentials
57155
- `AWS_REGION`: AWS region to use (default: us-east-1)
58156
- `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`: Explicit AWS credentials (alternative to AWS_PROFILE)
59-
- `AWS_LOCATION_PLACE_INDEX`: Name of the AWS Location Service Place Index to use (default: ExamplePlaceIndex)
60157

61158
## Tools
62159

63160
### search_places
64161

65-
Search for places using AWS Location Service geocoding.
162+
Search for places using AWS Location Service geo-places search_text API.
66163

67164
**Parameters:**
68165
- `query` (required): Search query (address, place name, etc.)
69166
- `max_results` (optional): Maximum number of results to return (1-50, default: 5)
167+
- `mode` (optional): Output mode: 'summary' (default) or 'raw' for all AWS fields
70168

71169
**Example:**
72170
```json
@@ -76,25 +174,134 @@ Search for places using AWS Location Service geocoding.
76174
}
77175
```
78176

79-
### get_coordinates
177+
### get_place
178+
179+
Get details for a place using AWS Location Service geo-places get_place API.
180+
181+
**Parameters:**
182+
- `place_id` (required): The unique PlaceId for the place
183+
- `mode` (optional): Output mode: 'summary' (default) or 'raw' for all AWS fields
184+
185+
**Example:**
186+
```json
187+
{
188+
"place_id": "AQAAAIAADsn1T3KdrRWeaXLeVEyjNx_JfeTsMB0TKUYrAJkOQH-9Cb-I",
189+
"mode": "summary"
190+
}
191+
```
192+
193+
### reverse_geocode
194+
195+
Reverse geocode coordinates to an address using AWS Location Service geo-places reverse_geocode API.
196+
197+
**Parameters:**
198+
- `longitude` (required): Longitude of the location
199+
- `latitude` (required): Latitude of the location
200+
201+
**Example:**
202+
```json
203+
{
204+
"longitude": -73.9857,
205+
"latitude": 40.7484
206+
}
207+
```
208+
209+
### search_nearby
210+
211+
Search for places near a location using AWS Location Service geo-places search_nearby API.
212+
213+
**Parameters:**
214+
- `longitude` (required): Longitude of the center point
215+
- `latitude` (required): Latitude of the center point
216+
- `max_results` (optional): Maximum number of results to return (1-50, default: 5)
217+
- `query` (optional): Optional search query
218+
- `radius` (optional): Search radius in meters (default: 500)
219+
- `max_radius` (optional): Maximum search radius in meters for expansion (default: 10000)
220+
- `expansion_factor` (optional): Factor to expand radius by if no results (default: 2.0)
221+
- `mode` (optional): Output mode: 'summary' (default) or 'raw' for all AWS fields
222+
223+
**Example:**
224+
```json
225+
{
226+
"longitude": -73.9857,
227+
"latitude": 40.7484,
228+
"radius": 1000,
229+
"max_results": 10
230+
}
231+
```
232+
233+
### search_places_open_now
80234

81-
Get coordinates for a specific location.
235+
Search for places that are open now using AWS Location Service geo-places search_text API and filter by opening hours.
82236

83237
**Parameters:**
84-
- `location` (required): Location name (city, address, landmark, etc.)
238+
- `query` (required): Search query (address, place name, etc.)
239+
- `max_results` (optional): Maximum number of results to return (1-50, default: 5)
240+
- `initial_radius` (optional): Initial search radius in meters for expansion (default: 500)
241+
- `max_radius` (optional): Maximum search radius in meters for expansion (default: 50000)
242+
- `expansion_factor` (optional): Factor to expand radius by if no open places (default: 2.0)
85243

86244
**Example:**
87245
```json
88246
{
89-
"location": "Quebec City, Canada"
247+
"query": "restaurants, New York",
248+
"max_results": 5
90249
}
91250
```
92251

93-
**Response includes:**
94-
- Location name
95-
- Formatted address
96-
- Coordinates (longitude, latitude)
97-
- Country, region, and municipality information
252+
## Output Structure
253+
254+
All tools that return places (e.g., search_places, search_nearby, get_place) return a standardized structure for each place:
255+
256+
```
257+
{
258+
"place_id": string, // Unique identifier for the place (or 'Not available')
259+
"name": string, // Name of the place (or 'Not available')
260+
"address": string, // Full address (or 'Not available')
261+
"contacts": {
262+
"phones": [string], // List of phone numbers (may be empty)
263+
"websites": [string], // List of website URLs (may be empty)
264+
"emails": [string], // List of email addresses (may be empty)
265+
"faxes": [string] // List of fax numbers (may be empty)
266+
},
267+
"categories": [string], // List of categories (may be empty)
268+
"coordinates": {
269+
"longitude": float or 'Not available',
270+
"latitude": float or 'Not available'
271+
},
272+
"opening_hours": [ // List of opening hours entries (may be empty)
273+
{
274+
"display": [string], // Human-readable display strings (e.g., 'Mon-Fri: 08:00 - 17:00')
275+
"components": [object], // Raw AWS components for each period (may be empty)
276+
"open_now": bool or null, // True/False if currently open, or null if unknown
277+
"categories": [string] // Categories for this period (may be empty)
278+
}
279+
]
280+
}
281+
```
282+
283+
- All fields are always present. If data is missing, the field is an empty list or 'Not available'.
284+
- The `mode` parameter can be set to 'summary' (default, standardized output) or 'raw' (full AWS response for each place).
285+
- The `max_results` parameter controls the number of results returned (default 5, can be set per request).
286+
287+
## Example Usage
288+
289+
```
290+
# Search for hospitals in Boston, MA, return up to 5 results
291+
await search_places(ctx, query="hospital, Boston, MA", max_results=5)
292+
293+
# Get full AWS response for a place
294+
await get_place(ctx, place_id="...", mode="raw")
295+
296+
# Reverse geocode coordinates
297+
await reverse_geocode(ctx, longitude=-73.9857, latitude=40.7484)
298+
299+
# Search for places near a location
300+
await search_nearby(ctx, longitude=-73.9857, latitude=40.7484, radius=1000)
301+
302+
# Search for restaurants that are open now
303+
await search_places_open_now(ctx, query="restaurants, New York")
304+
```
98305

99306
## Development
100307

@@ -128,12 +335,11 @@ python -m pytest tests/ -v --cov=awslabs --cov-report=term-missing
128335

129336
## AWS Location Service Resources
130337

131-
This server uses the following AWS Location Service resource:
132-
133-
**Place Index**: Used for geocoding and place search
134-
- Create in AWS Console: Amazon Location Service > Place indexes > Create place index
135-
- Recommended data provider: Esri or HERE
136-
- If not specified, the server will attempt to use an existing place index
338+
This server uses the AWS Location Service geo-places API for:
339+
- Geocoding (converting addresses to coordinates)
340+
- Reverse geocoding (converting coordinates to addresses)
341+
- Place search (finding places by name, category, etc.)
342+
- Place details (getting information about specific places)
137343

138344
## Security Considerations
139345

0 commit comments

Comments
 (0)