The Google Maps MCP Server provides access to Google Maps API functionality through the Model Context Protocol (MCP), allowing you to perform various mapping operations like geocoding, place searches, and route calculations in your applications.
The Google Maps MCP Server provides several tools to interact with Google Maps services:
maps_geocode: Converts an address to coordinates
address
(string)maps_reverse_geocode: Converts coordinates to address
latitude
(number), longitude
(number)maps_search_places: Searches for places using text query
query
(string)location
(optional): { latitude: number, longitude: number }radius
(optional): number (meters, max 50000)maps_place_details: Gets detailed information about a place
place_id
(string)maps_distance_matrix: Calculates distances and times between points
origins
(string[])destinations
(string[])mode
(optional): "driving" | "walking" | "bicycling" | "transit"maps_directions: Gets directions between points
origin
(string)destination
(string)mode
(optional): "driving" | "walking" | "bicycling" | "transit"locations
(array of {latitude, longitude})Before setting up the server, you'll need a Google Maps API key:
Add the server configuration to your claude_desktop_config.json
using one of the following methods:
{
"mcpServers": {
"google-maps": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GOOGLE_MAPS_API_KEY",
"mcp/google-maps"
],
"env": {
"GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
{
"mcpServers": {
"google-maps": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-google-maps"],
"env": {
"GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
To manually configure the server in VS Code:
Ctrl + Shift + P
and type Preferences: Open User Settings (JSON)
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "maps_api_key",
"description": "Google Maps API Key",
"password": true
}
],
"servers": {
"google-maps": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-google-maps"],
"env": {
"GOOGLE_MAPS_API_KEY": "${input:maps_api_key}"
}
}
}
}
}
For Docker installation:
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "maps_api_key",
"description": "Google Maps API Key",
"password": true
}
],
"servers": {
"google-maps": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/google-maps"],
"env": {
"GOOGLE_MAPS_API_KEY": "${input:maps_api_key}"
}
}
}
}
}
Once configured, you can use the Google Maps MCP server tools in your applications. Here are some examples:
To convert an address to coordinates:
// Using maps_geocode
const result = await mcp.call("google-maps", "maps_geocode", {
address: "1600 Amphitheatre Parkway, Mountain View, CA"
});
console.log(result.location); // { lat: 37.4224764, lng: -122.0842499 }
To search for places near a location:
// Using maps_search_places
const places = await mcp.call("google-maps", "maps_search_places", {
query: "coffee shops",
location: { latitude: 37.4224764, longitude: -122.0842499 },
radius: 1000
});
console.log(places); // Array of coffee shops near the location
To get directions between two locations:
// Using maps_directions
const directions = await mcp.call("google-maps", "maps_directions", {
origin: "San Francisco, CA",
destination: "Mountain View, CA",
mode: "driving"
});
console.log(directions); // Route details with steps, distance, duration
To calculate distances between multiple origins and destinations:
// Using maps_distance_matrix
const distances = await mcp.call("google-maps", "maps_distance_matrix", {
origins: ["San Francisco, CA", "Oakland, CA"],
destinations: ["Mountain View, CA", "San Jose, CA"],
mode: "driving"
});
console.log(distances); // Matrix of distances and durations
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.