Google Maps MCP server

Access location data, geocoding, and place details through Maps API.
Back to servers
Provider
Anthropic
Release date
Nov 19, 2024
Language
TypeScript
Package
Stats
22.0K downloads
40.6K stars

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.

Features

The Google Maps MCP Server provides several tools to interact with Google Maps services:

Geocoding Tools

  • maps_geocode: Converts an address to coordinates

    • Input: address (string)
    • Returns: location, formatted_address, place_id
  • maps_reverse_geocode: Converts coordinates to address

    • Inputs: latitude (number), longitude (number)
    • Returns: formatted_address, place_id, address_components

Places Tools

  • maps_search_places: Searches for places using text query

    • Inputs:
      • query (string)
      • location (optional): { latitude: number, longitude: number }
      • radius (optional): number (meters, max 50000)
    • Returns: array of places with names, addresses, locations
  • maps_place_details: Gets detailed information about a place

    • Input: place_id (string)
    • Returns: name, address, contact info, ratings, reviews, opening hours

Route and Distance Tools

  • maps_distance_matrix: Calculates distances and times between points

    • Inputs:
      • origins (string[])
      • destinations (string[])
      • mode (optional): "driving" | "walking" | "bicycling" | "transit"
    • Returns: distances and durations matrix
  • maps_directions: Gets directions between points

    • Inputs:
      • origin (string)
      • destination (string)
      • mode (optional): "driving" | "walking" | "bicycling" | "transit"
    • Returns: route details with steps, distance, duration

Elevation Tool

  • maps_elevation: Gets elevation data for locations
    • Input: locations (array of {latitude, longitude})
    • Returns: elevation data for each point

Installation

Getting an API Key

Before setting up the server, you'll need a Google Maps API key:

  1. Follow the instructions at Google Maps Documentation to create an API key
  2. Make sure to enable the specific Google Maps APIs you plan to use

Installation with Claude Desktop

Add the server configuration to your claude_desktop_config.json using one of the following methods:

Using Docker

{
  "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>"
      }
    }
  }
}

Using NPX

{
  "mcpServers": {
    "google-maps": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-google-maps"],
      "env": {
        "GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}

Installation with VS Code

Manual Configuration

To manually configure the server in VS Code:

  1. Press Ctrl + Shift + P and type Preferences: Open User Settings (JSON)
  2. Add the following configuration:
{
  "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}"
        }
      }
    }
  }
}

Usage Examples

Once configured, you can use the Google Maps MCP server tools in your applications. Here are some examples:

Geocoding an Address

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 }

Finding Nearby Places

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

Getting Directions

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

Calculating Distance Matrix

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

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later