GO
OfficialLocation

Google Maps Platform Code Assist MCP Server Documentation

Explore MCP server documentation for Google Maps Platform Code Assist with official guides and code samples to ground agents for accurate geo-related guidance.

Overview

The Google Maps Platform Code Assist MCP Server provides a lightweight, MCP-compliant HTTP service that surfaces Google Maps Platform capabilities as tools and resources for LLM-based agents. It acts as a grounding layer: agents query the MCP server to discover available geo-aware operations (geocoding, places, directions, etc.), then call those operations through well-typed, auditable endpoints. This reduces hallucination and ensures responses reference live Maps Platform data.

Designed for developers building agent-enabled assistants, the server packages Maps APIs into a standardized toolset and enforces request patterns, parameter validation, and quota-safe access. It is particularly useful when you need reliable, verifiable geographic reasoning inside code assistants, chatbots, or automated workflows that rely on accurate location data.

Features

  • MCP-compliant HTTP server exposing Maps Platform functionality as tools/resources
  • Predefined toolset: Geocoding, Reverse Geocoding, Place Search, Place Details, Directions, Distance Matrix, Elevation, Time Zone, Static Maps
  • Parameter validation and typed request/response shapes for safer agent calls
  • Configurable API key, CORS, and logging
  • Example clients and code samples for quick integration
  • Local dev mode for testing without production credentials

Installation / Configuration

Clone and install from the Code Assist package in the official repo:

git clone https://github.com/googlemaps/platform-ai.git
cd platform-ai/packages/code-assist
npm install

Create a .env file (or export environment variables) with your Maps API key and preferred port:

PORT=3000
GOOGLE_MAPS_API_KEY=YOUR_GOOGLE_MAPS_API_KEY
ALLOWED_ORIGINS=http://localhost:5173
LOG_LEVEL=info

Start the server (development):

npm run dev
# or
npm start

By default the server exposes MCP-style endpoints. You can configure additional options in the package’s configuration file or via environment variables listed above.

Available Tools / Resources

The server maps common Google Maps Platform capabilities to named tools. Example tool names and parameter shapes:

Tool namePurposeTypical parameters
geocodeConvert address to coordinatesaddress (string)
reverseGeocodeConvert coordinates to addresslat (number), lng (number)
placeSearchFind places matching queryquery (string), location, radius
placeDetailsFetch details of a placeplace_id (string), fields (array)
directionsRoute planning between pointsorigin, destination, mode
distanceMatrixCompute travel times/distancesorigins, destinations, mode
elevationGet elevation for coordslocations (array)
timeZoneGet time zone for coordslocation, timestamp
staticMapGenerate static map URLscenter, zoom, markers, size

The MCP server serves a discovery endpoint that returns metadata for each tool (name, description, input schema), enabling agents to introspect and call tools safely.

Example: Discover and Call a Tool

Fetch the tool list (example):

curl -H "Authorization: Bearer $GOOGLE_MAPS_API_KEY" \
     http://localhost:3000/mcp/tools

Call the geocode tool:

curl -X POST http://localhost:3000/mcp/tool/geocode \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GOOGLE_MAPS_API_KEY" \
  -d '{"address":"1600 Amphitheatre Parkway, Mountain View, CA"}'

The server will return a typed JSON response containing coordinates and structured address components, using live Maps Platform results.

Use Cases

  • Code assistants that generate or validate location-based code (e.g., autocomplete for map pins, addresses, or routing snippets) can call the MCP server to obtain authoritative data rather than relying on LLM memory.
  • Customer support chatbots can verify user-entered addresses, suggest nearby branches, or provide directions with accurate travel-time estimates.
  • Automated testing or CI pipelines can use the MCP server in staging to validate geo-related logic against current Maps responses.
  • Content generation tools that include maps or location facts can embed static map URLs or place metadata that are guaranteed to match Maps Platform outputs.
  • GitHub: https://github.com/googlemaps/platform-ai/tree/main/packages/code-assist
  • Configure Google Maps Platform credentials in the Cloud Console and enable the APIs your agents will use (Geocoding, Places, Directions, etc.).

If you need to extend the toolset, the server is designed to be modular: add new tool handlers that validate input, call the relevant Maps API, and return standardized responses for agents to consume.