Guide · Amazon Location Service · Geocoding & Place Search
Amazon Location Service for MCP Servers — Geocoding, Place Search, and Geospatial APIs
Amazon Location Service gives MCP servers a managed geocoding and geospatial layer without requiring a third-party API key or external billing relationship. It supports place search (text-to-coordinates), reverse geocoding (coordinates-to-address), nearby search (points of interest around a location), route calculation, geofencing, and device tracking — all within your AWS account's IAM boundary. This guide covers the @aws-sdk/client-location SDK, how to create place indexes, how to run search and geocoding operations, and common patterns for surfacing geospatial context in MCP tool responses.
TL;DR
Amazon Location Service uses named persistent resources (place indexes, route calculators, trackers, geofence collections) that you create once and reference by name. Install @aws-sdk/client-location. All coordinates use GeoJSON convention: [longitude, latitude] — longitude first, latitude second. This is the reverse of what many APIs expect and is the most common source of bugs. Data sources are Esri, HERE, and Open Data (free tier); the data source is locked at index creation time and cannot be changed.
Why MCP servers need geospatial APIs
LLM agents receiving natural-language queries frequently need to resolve location references to coordinates or structured place data. A query like "find coffee shops near the main conference center in Seattle" requires geocoding the venue, performing a nearby place search, and returning structured results the agent can reason about. Without a geospatial layer, the MCP server must either hardcode location data, call an external API (Google Maps, Mapbox) with a separate billing account, or return empty results.
Amazon Location Service solves this within the AWS account boundary:
- Place search:
SearchPlaceIndexForTextCommandresolves a free-text query to a ranked list of places with coordinates, address components, and place categories. - Reverse geocoding:
SearchPlaceIndexForPositionCommandturns GPS coordinates into a human-readable address. - Place lookup:
GetPlaceCommandretrieves full details for a known place identifier. - Nearby search:
SearchPlaceIndexForTextCommandwith aBiasPositionorFilterBBoxbiases results toward a geographic area.
All operations authenticate via IAM — no API keys to rotate, no separate billing, no data leaving your VPC if you use a VPC endpoint.
Creating a place index
A place index is a named, persistent resource that specifies a data source and storage configuration. You create it once; calls to SearchPlaceIndexForTextCommand reference it by name:
npm install @aws-sdk/client-location
import {
LocationClient,
CreatePlaceIndexCommand,
DataSourceName,
} from "@aws-sdk/client-location";
const location = new LocationClient({ region: "us-east-1" });
// Create once — this is a persistent named resource
await location.send(new CreatePlaceIndexCommand({
IndexName: "my-mcp-place-index",
DataSource: "Esri", // "Esri" | "HERE" | "Grab" | "Open"
Description: "Place index for MCP server geocoding",
DataSourceConfiguration: {
IntendedUse: "SingleUse", // "SingleUse" (no caching) | "Storage" (can store results)
},
Tags: { "mcp-server": "true" },
}));
Data source comparison
| Data source | Coverage | Search price (per 1K requests) | Notes |
|---|---|---|---|
Esri |
Global, strong in North America and Europe | $0.50 | Best address accuracy; supports Storage intended use |
HERE |
Global, strong in Europe and Asia | $0.50 | Better POI coverage than Esri in some regions |
Grab |
Southeast Asia only | $0.50 | Required for accurate coverage in SG, MY, TH, ID, PH, VN |
Open |
Global (OpenStreetMap-based) | Free | No Storage intended use; weaker address accuracy |
Important: the data source is locked at index creation time — you cannot change it. Create a new index to switch data sources. The IntendedUse: "Storage" option allows you to cache results in your own systems; SingleUse results must not be stored (data provider license restriction).
Place search (text-to-place)
Use SearchPlaceIndexForTextCommand for free-text place and address search:
import {
SearchPlaceIndexForTextCommand,
type SearchForTextResult,
} from "@aws-sdk/client-location";
const result = await location.send(new SearchPlaceIndexForTextCommand({
IndexName: "my-mcp-place-index",
Text: "Space Needle, Seattle",
MaxResults: 5, // 1–50; default 50
Language: "en", // BCP 47 language tag for result labels
}));
for (const place of result.Results ?? []) {
const { Label, Geometry, AddressNumber, Street, Municipality, Region, Country } = place.Place!;
const [lon, lat] = Geometry!.Point!; // GeoJSON: [longitude, latitude]
console.log(Label, lat, lon);
}
The Geometry.Point array is [longitude, latitude] — GeoJSON convention. Longitude is index 0, latitude is index 1. This is the reverse of many location APIs that use (lat, lon) tuples. Store coordinates correctly from the first search call or every downstream operation (routing, geofencing, map rendering) will be subtly wrong.
Biasing results toward a region
Provide a BiasPosition to rank results near a known coordinate, or a FilterBBox to restrict results to a bounding box:
// Bias toward Seattle downtown (lon, lat)
const nearbyResult = await location.send(new SearchPlaceIndexForTextCommand({
IndexName: "my-mcp-place-index",
Text: "coffee",
BiasPosition: [-122.3321, 47.6062], // [longitude, latitude]
MaxResults: 10,
}));
// Or restrict to a bounding box: [westLon, southLat, eastLon, northLat]
const bboxResult = await location.send(new SearchPlaceIndexForTextCommand({
IndexName: "my-mcp-place-index",
Text: "hospital",
FilterBBox: [-122.45, 47.55, -122.25, 47.70],
MaxResults: 20,
}));
BiasPosition and FilterBBox are mutually exclusive — use one or the other. BiasPosition biases ranking without excluding distant results; FilterBBox excludes results outside the box entirely.
Country filtering
Filter results to specific countries using ISO 3166-1 alpha-3 codes — three-letter codes, not the two-letter codes used by most other APIs:
const usResult = await location.send(new SearchPlaceIndexForTextCommand({
IndexName: "my-mcp-place-index",
Text: "Springfield",
FilterCountries: ["USA"], // Three-letter alpha-3: "USA" not "US"
MaxResults: 10,
}));
Common gotcha: passing "US" instead of "USA" returns a validation error. The filter accepts an array — pass multiple codes for multi-country searches like ["USA", "CAN", "MEX"].
Reverse geocoding (coordinates-to-address)
Use SearchPlaceIndexForPositionCommand to look up the address for a GPS coordinate:
import { SearchPlaceIndexForPositionCommand } from "@aws-sdk/client-location";
const reverseResult = await location.send(new SearchPlaceIndexForPositionCommand({
IndexName: "my-mcp-place-index",
Position: [-122.3321, 47.6062], // [longitude, latitude]
MaxResults: 1,
Language: "en",
}));
const topResult = reverseResult.Results?.[0];
if (topResult) {
const { Label, AddressNumber, Street, Municipality, Region, PostalCode, Country } = topResult.Place!;
console.log("Address:", Label);
console.log("City:", Municipality, "State:", Region, "ZIP:", PostalCode);
}
Reverse geocoding returns ranked results — the first result is usually the most specific address match. For MCP tool responses, return Label (the formatted full address string) and separately expose Municipality, Region, and PostalCode for structured downstream use.
Place lookup by ID
When a previous search result includes a PlaceId, you can retrieve full place details without a new search:
import { GetPlaceCommand } from "@aws-sdk/client-location";
// placeId from a prior SearchPlaceIndexForTextCommand result
const placeDetail = await location.send(new GetPlaceCommand({
IndexName: "my-mcp-place-index",
PlaceId: "AQAAABQAP...",
Language: "en",
}));
const { Label, Geometry, Categories, TimeZone, UnitNumber, UnitType } = placeDetail.Place!;
PlaceId values are data-source specific and have limited lifetimes — they are not persistent identifiers suitable for long-term storage. Use them within a session to avoid re-searching, but do not store them in a database as stable references.
Listing and managing place indexes
To discover existing place indexes (useful when multiple MCP tools share one account):
import { ListPlaceIndexesCommand } from "@aws-sdk/client-location";
let nextToken: string | undefined;
do {
const resp = await location.send(new ListPlaceIndexesCommand({
MaxResults: 100,
NextToken: nextToken,
}));
for (const idx of resp.Entries ?? []) {
console.log(idx.IndexName, idx.DataSource, idx.Description);
}
nextToken = resp.NextToken;
} while (nextToken);
IAM policy for MCP server roles
Grant the MCP server's execution role read-only access to Location Service operations:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"geo:SearchPlaceIndexForText",
"geo:SearchPlaceIndexForPosition",
"geo:GetPlace",
"geo:ListPlaceIndexes"
],
"Resource": "arn:aws:geo:us-east-1:123456789012:place-index/my-mcp-place-index"
}
]
}
Location Service IAM actions use the geo: prefix, not location:. The resource ARN format for place indexes is arn:aws:geo:{region}:{account}:place-index/{IndexName}. Lock down the resource to the specific index name rather than * — this prevents an MCP server from accidentally querying (and paying for) indexes intended for different services.
Pricing and free tier
- Place search and geocoding: $0.50 per 1,000 requests (Esri or HERE). First 10,000 requests per month are free.
- Open Data search: Free (unlimited, OpenStreetMap-backed)
- Place index creation: Free — you pay per request, not per index
For MCP servers handling user-initiated queries, the free tier (10K/month) covers moderate traffic. For background batch geocoding jobs (address normalization, bulk location enrichment), scope to off-peak hours and monitor AWS/Location/SearchRequests CloudWatch metrics to avoid unexpected charges.