Google Maps MCP server with streamable HTTP transport support for location services, geocoding, and navigation
npm install @cablate/mcp-google-map
streamablehttp.
bash
Install globally
npm install -g @cablate/mcp-google-map
Run the server
mcp-google-map --port 3000 --apikey "your_api_key_here"
Using short options
mcp-google-map -p 3000 -k "your_api_key_here"
`
$3
> β οΈ Warning: Cannot be used directly in MCP Server Settings with stdio mode
Step 1: Launch HTTP Server in Terminal
`bash
Run in a separate terminal
npx @cablate/mcp-google-map --port 3000 --apikey "YOUR_API_KEY"
Or with environment variable
GOOGLE_MAPS_API_KEY=YOUR_API_KEY npx @cablate/mcp-google-map
`
Step 2: Configure MCP Client to Use HTTP
`json
{
"mcp-google-map": {
"transport": "http",
"url": "http://localhost:3000/mcp"
}
}
`
$3
`json
// This WILL NOT WORK - stdio mode not supported with npx
{
"mcp-google-map": {
"command": "npx",
"args": ["@cablate/mcp-google-map"]
}
}
`
$3
- Endpoint: http://localhost:3000/mcp
- Transport: HTTP (not stdio)
- Tools: 8 Google Maps tools available
$3
API keys can be provided in three ways (priority order):
1. HTTP Headers (Highest priority)
`json
// MCP Client config
{
"mcp-google-map": {
"transport": "streamableHttp",
"url": "http://localhost:3000/mcp",
// if your MCP Client support 'headers'
"headers": {
"X-Google-Maps-API-Key": "YOUR_API_KEY"
}
}
}
`
2. Command Line
`bash
mcp-google-map --apikey YOUR_API_KEY
`
3. Environment Variable (.env file or command line)
`env
GOOGLE_MAPS_API_KEY=your_api_key_here
MCP_SERVER_PORT=3000
`
Available Tools
The server provides the following tools:
$3
1. search_nearby - Search for nearby places based on location, with optional filtering by keywords, distance, rating, and operating hours
2. get_place_details - Get detailed information about a specific place including contact details, reviews, ratings, and operating hours
3. maps_geocode - Convert addresses or place names to geographic coordinates (latitude and longitude)
4. maps_reverse_geocode - Convert geographic coordinates to a human-readable address
5. maps_distance_matrix - Calculate travel distances and durations between multiple origins and destinations
6. maps_directions - Get detailed turn-by-turn navigation directions between two locations
7. maps_elevation - Get elevation data (height above sea level) for specific geographic locations
Development
$3
`bash
Clone the repository
git clone https://github.com/cablate/mcp-google-map.git
cd mcp-google-map
Install dependencies
npm install
Set up environment variables
cp .env.example .env
Edit .env with your API key
Build the project
npm run build
Start the server
npm start
Or run in development mode
npm run dev
`
$3
`
src/
βββ cli.ts # Main CLI entry point
βββ config.ts # Server configuration
βββ index.ts # Package exports
βββ core/
β βββ BaseMcpServer.ts # Base MCP server with streamable HTTP
βββ tools/
βββ maps/ # Google Maps tools
βββ toolclass.ts # Google Maps API client
βββ searchPlaces.ts # Maps service layer
βββ searchNearby.ts # Search nearby places
βββ placeDetails.ts # Place details
βββ geocode.ts # Geocoding
βββ reverseGeocode.ts # Reverse geocoding
βββ distanceMatrix.ts # Distance matrix
βββ directions.ts # Directions
βββ elevation.ts # Elevation data
`
Tech Stack
- TypeScript - Type-safe development
- Node.js - Runtime environment
- Google Maps Services JS - Google Maps API integration
- Model Context Protocol SDK - MCP protocol implementation
- Express.js - HTTP server framework
- Zod - Schema validation
Security Considerations
- API keys are handled server-side for security
- DNS rebinding protection available for production
- Input validation using Zod schemas
- Error handling and logging
License
MIT
Contributing
Community participation and contributions are welcome! Here's how you can contribute:
- βοΈ Star the project if you find it helpful
- π Submit Issues: Report bugs or provide suggestions
- π§ Create Pull Requests: Submit code improvements
- π Documentation: Help improve documentation
Contact
If you have any questions or suggestions, feel free to reach out:
- π§ Email: reahtuoo310109@gmail.com
- π» GitHub: CabLate
- π€ Collaboration: Welcome to discuss project cooperation
- π Technical Guidance: Sincere welcome for suggestions and guidance
Changelog
$3
- Error response improvements: Now all error messages are in English with more detailed information (previously in Chinese)
$3
- Added HTTP Header Authentication: Support for passing API keys via X-Google-Maps-API-Key` header in MCP Client config