mcp server
google-maps-MCP
Octahaidra website backend code repository for google maps mcp server with testing
Set up
Runs on your computer. Pick your agent and operating system.
Before you start
- Node.js 20 or newer
{
"mcpServers": {
"octahaidra-google-maps-mcp": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-google-maps"
]
}
}
}same format Cursor, GitHub Copilot CLI, Junie, JetBrains AI Assistant, Augment (Auggie CLI), Factory Droid, Kiro, Devin CLI +12
Values in angle brackets are placeholders. Restart Claude Desktop after editing its config.Claude Desktop docs
README
synced Oct 23, 2026Google Maps MCP Server
A Model Context Protocol (MCP) server implementation for Google Maps APIs, providing geocoding, place search, directions, and other mapping functionalities.
Prerequisites
- Node.js 18 or higher
- Docker (for containerized deployment)
- Google Maps API key with the following APIs enabled:
- Geocoding API
- Places API
- Distance Matrix API
- Elevation API
- Directions API
Environment Setup
- Create a
.envfile in the project root:
GOOGLE_MAPS_API_KEY=your_api_key_here
- Install dependencies:
npm install
Development
Running the Server Locally
- Build the TypeScript files:
npm run build
- Start the server:
node dist/server.js
Testing
Running Tests Locally
- Make sure the server is built:
npm run build
- Run the test script:
node test-server.js
The test script will:
- Start the server
- Run test cases for geocoding, reverse geocoding, and place search
- Verify responses
- Clean up by stopping the server
Running Tests with Docker
- Make the test script executable:
chmod +x test-docker.sh
- Run the Docker test script:
./test-docker.sh
This will:
- Build the Docker image
- Start a container with your server
- Run the test script inside the container
- Clean up by stopping and removing the container
Docker Deployment
Building the Docker Image
docker build -t mcp-google-maps-server .
Running the Docker Container
docker run -d --env-file .env mcp-google-maps-server
API Endpoints
The server provides the following MCP endpoints:
Geocoding
- Endpoint:
/trpc/geocode - Method: POST
- Request Body:
{ "address": "1600 Amphitheatre Parkway, Mountain View, CA" }
Reverse Geocoding
- Endpoint:
/trpc/reverse_geocode - Method: POST
- Request Body:
{ "location": { "latitude": 49.26046, "longitude": 11.04339 } }
Place Search
- Endpoint:
/trpc/searchPlaces - Method: POST
- Request Body:
{ "query": "restaurants in Nürnberg", "location": { "latitude": 49.26046, "longitude": 11.04339 } }
Place Details
- Endpoint:
/trpc/placeDetails - Method: POST
- Request Body:
{ "place_id": "ChIJN1t_tDeuEmsRUsoyG83frY4" }
Distance Matrix
- Endpoint:
/trpc/distanceMatrix - Method: POST
- Request Body:
{ "origins": ["New York, NY"], "destinations": ["Boston, MA"], "mode": "driving" }
Elevation
- Endpoint:
/trpc/elevation - Method: POST
- Request Body:
{ "locations": [ { "latitude": 49.26046, "longitude": 11.04339 } ] }
Directions
- Endpoint:
/trpc/directions - Method: POST
- Request Body:
{ "origin": "New York, NY", "destination": "Boston, MA", "mode": "driving" }
Error Handling
The server includes comprehensive error handling for:
- Invalid API keys
- API request failures
- Invalid input parameters
- Network issues
Troubleshooting
Docker Build Issues
If you encounter issues during the Docker build:
- Make sure you have the latest version of Docker installed
- Try clearing Docker's build cache:
docker builder prune
- If npm install fails in the container:
- Check your package.json for any dependency issues
- Try running
npm install --legacy-peer-depslocally first - Make sure all dependencies are compatible with Node.js 18
Container Issues
If the container fails to start:
- Check the container logs:
docker logs <container_id>
-
Verify your .env file:
- Make sure it exists
- Check that GOOGLE_MAPS_API_KEY is set correctly
- Ensure there are no extra spaces or quotes
-
Test the container interactively:
docker run -it --env-file .env mcp-google-maps-server /bin/sh
Test Failures
If tests are failing:
- Check the test output for specific error messages
- Verify that your Google Maps API key has all required APIs enabled
- Try running the tests locally first:
npm run build
node test-server.js
- Check the server logs for any API-related errors
Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.