Google Maps MCP Server for Cloud Run

Google Maps MCP Server for Cloud Run

Provides Google Maps functionality through Cloud Run, enabling route calculation, traffic analysis, route comparison, and trip cost estimation with rate-limited public access.

Category
访问服务器

README

Google Maps MCP Server for Cloud Run

A Google Maps Model Context Protocol (MCP) server designed for deployment on Google Cloud Run with public access. This server provides Google Maps functionality to Claude Desktop clients through a secure, rate-limited API.

Features

  • Route Calculation: Optimal driving routes with real-time traffic data
  • Route Comparison: Compare multiple routing alternatives with different options
  • Live Traffic: Current traffic conditions and travel time analysis
  • Cost Estimation: Trip cost calculations including fuel and toll estimates
  • Public Access: No authentication required for easy sharing
  • Rate Limiting: 50 requests per hour per IP address
  • Cloud Run Optimized: Designed for serverless deployment on GCP

Prerequisites

  • Google Cloud Platform account with billing enabled
  • Google Cloud CLI (gcloud) installed and configured
  • Node.js 18+ for local development
  • Google Maps API key with required APIs enabled

Required Google Maps APIs

Before deployment, enable these APIs in your GCP project:

  1. Directions API - For route calculations
  2. Geocoding API - For address resolution
  3. Maps JavaScript API - For polyline encoding (optional)

Enable APIs via Google Cloud Console or CLI:

gcloud services enable directions-backend.googleapis.com
gcloud services enable geocoding-backend.googleapis.com
gcloud services enable maps-backend.googleapis.com

Quick Start

1. Get Google Maps API Key

  1. Go to Google Cloud Console > Credentials
  2. Create a new API key or use an existing one
  3. Restrict the key to the required APIs listed above
  4. Note your API key for deployment

2. Deploy to Cloud Run

# Clone the repository
git clone <your-repo-url>
cd google-maps-mcp-cloudrun

# Set your Google Maps API key
export GOOGLE_MAPS_API_KEY="your-api-key-here"

# Deploy using the provided script
./simple-deploy.sh your-gcp-project-id us-central1

3. Extract Service URL

After deployment, extract your service URL:

# Get the service URL
SERVICE_URL=$(gcloud run services describe google-maps-mcp \
  --region us-central1 \
  --format="value(status.url)")

echo "Your MCP Server URL: $SERVICE_URL/sse"

Manual Deployment

If you prefer manual deployment:

# Set your project
gcloud config set project YOUR_PROJECT_ID

# Enable required services
gcloud services enable run.googleapis.com cloudbuild.googleapis.com

# Deploy
gcloud run deploy google-maps-mcp \
  --source . \
  --region us-central1 \
  --platform managed \
  --allow-unauthenticated \
  --set-env-vars GOOGLE_MAPS_API_KEY="your-api-key-here" \
  --memory 1Gi \
  --cpu 1 \
  --max-instances 10 \
  --timeout 300 \
  --port 8080

Claude Desktop Configuration

Add this configuration to your Claude Desktop settings:

{
  "mcpServers": {
    "google-maps": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://YOUR-SERVICE-URL.run.app/sse"
      ]
    }
  }
}

Replace YOUR-SERVICE-URL.run.app with your actual Cloud Run service URL.

Finding Your Claude Desktop Config

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%/Claude/claude_desktop_config.json

Available Tools

The MCP server provides these tools to Claude:

  1. calculate_route - Calculate optimal driving routes with traffic
  2. compare_routes - Compare multiple route alternatives
  3. get_live_traffic - Get current traffic conditions
  4. estimate_costs - Calculate trip costs (fuel + tolls)

Service Endpoints

  • MCP Endpoint: https://your-service.run.app/sse
  • Health Check: https://your-service.run.app/health
  • Usage Stats: https://your-service.run.app/stats

Local Development

# Install dependencies
npm install

# Copy environment template
cp .env.example .env

# Edit .env with your API key
# GOOGLE_MAPS_API_KEY=your-api-key-here

# Start development server
npm run dev

# Test locally
npm test

Troubleshooting

Common Deployment Issues

1. Permission Denied

# Error: Permission denied
gcloud auth login
gcloud config set project YOUR_PROJECT_ID

2. API Not Enabled

# Error: API not enabled
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com

3. Billing Not Enabled

4. Invalid API Key

# Check API key restrictions in Console
# Ensure Directions API and Geocoding API are enabled

5. Service Won't Start

# Check logs for errors
gcloud run services logs read google-maps-mcp --region us-central1 --limit 50

Common Runtime Issues

Rate Limiting

  • Each IP is limited to 50 requests per hour
  • Check /stats endpoint for current usage
  • Consider implementing user authentication for higher limits

API Quota Exceeded

  • Monitor your Google Maps API usage in GCP Console
  • Increase quotas if needed
  • Consider implementing caching for repeated requests

Testing Your Deployment

# Test health endpoint
curl "https://your-service.run.app/health"

# Test stats endpoint
curl "https://your-service.run.app/stats"

# Test with Claude Desktop
# Add the configuration and try asking Claude to calculate a route

Security Considerations

  • API key is stored as environment variable (secure)
  • Service allows public access (no authentication required)
  • Rate limiting prevents abuse (50 requests/hour per IP)
  • No sensitive data is logged or stored

Cost Management

  • Cloud Run: Pay-per-request pricing
  • Google Maps API: Pay-per-API-call pricing
  • Monitoring: Use GCP billing alerts to track costs

Set up billing alerts:

# Set up billing budget alerts in GCP Console
# Billing > Budgets & Alerts

Documentation Links

Support and Troubleshooting Resources

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Note: This server is designed for development and testing purposes. For production use with high traffic, consider implementing additional security measures and monitoring.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选