/ 目錄 / 演練場 / Google Maps
● 官方 modelcontextprotocol 🔑 需要你的金鑰

Google Maps

作者 modelcontextprotocol · modelcontextprotocol/servers-archived

Geocoding, place search, directions, distance matrix — Google Maps power for itineraries, store-locator features, and regional analyses.

The reference Google Maps MCP (now in modelcontextprotocol/servers-archived). Wraps key Maps APIs: geocoding, place search and details, directions, distance matrix, elevation. Useful for any agent task that needs real-world geography. Note: archived means no active maintenance — plan for community forks long-term.

為什麼要用

核心特性

即時演示

實際使用效果

google-maps.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "google-maps": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-google-maps"
      ]
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "google-maps": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-google-maps"
      ]
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "google-maps": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-google-maps"
      ]
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "google-maps": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-google-maps"
      ]
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "google-maps",
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-google-maps"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "google-maps": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@modelcontextprotocol/server-google-maps"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add google-maps -- npx -y @modelcontextprotocol/server-google-maps

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: Google Maps

Plan a day-trip itinerary with realistic travel times

👤 Travelers, anyone planning a multi-stop day ⏱ ~10 min beginner

何時使用: You have 5 places you want to hit in one day and need a realistic order, with travel times.

前置條件
  • Google Maps API key with relevant APIs enabled — console.cloud.google.com → enable Geocoding, Places, Directions APIs, then create key
步驟
  1. Geocode all stops
    Geocode these 5 places into lat/lng: <list>. Verify each address looks right.✓ 已複製
    → 5 coordinates with confidence
  2. Compute distance matrix
    Get drive times between every pair of stops at 10am on a weekday. Show as a matrix.✓ 已複製
    → 5×5 time matrix
  3. Order and add directions
    Suggest the order that minimizes total drive time. Then give me turn-by-turn directions stop-to-stop.✓ 已複製
    → Optimized route with directions

結果: An itinerary you can actually execute, not 'sounds nice' planning.

注意事項
  • Distance matrix doesn't account for parking time / walk to door — Pad each leg by 10-15 min for parking; longer for downtown destinations
  • Real-time traffic only available for certain modes/regions — Use departure_time to get traffic-aware estimates; 'now' may be excluded depending on plan
搭配使用: brave-search

Build store-locator data for a regional product

👤 Devs implementing a 'find a location' feature ⏱ ~30 min intermediate

何時使用: You're building a 'nearest store' feature and need to seed it with real coordinates and details.

步驟
  1. Geocode each store address
    I have a CSV of 50 store addresses at /data/stores.csv. Geocode each, return a new CSV with added lat, lng, place_id, and Google's normalized address.✓ 已複製
    → Enriched CSV; flag any addresses that didn't geocode cleanly
  2. Pull rich details for each
    For each place_id, fetch hours, phone, website. Add to the CSV.✓ 已複製
    → Per-store details, with missing-data flags where applicable
  3. Validate sample
    Pick 5 random rows and verify the geocoded coords visually look right (e.g. 'Stockholm address geocoded to Sweden, not Wisconsin').✓ 已複製
    → Sanity check pass; outliers flagged

結果: A clean store dataset ready to power a UI.

注意事項
  • Geocoding API has per-call cost — 50 addresses is a few cents but 50k is real money — Cache results aggressively; only re-geocode when address strings change
搭配使用: filesystem

Find which of your customers live within X minutes of a candidate location

👤 Ops, real-estate, growth analysts ⏱ ~25 min advanced

何時使用: You're evaluating a new store/office location and want to know how many existing customers it would serve.

步驟
  1. Geocode the candidate
    Geocode the candidate address: '1234 Market St, San Francisco'.✓ 已複製
    → Coordinate confirmed
  2. Distance matrix to customer ZIPs
    From the candidate, compute drive time to each of these 100 customer ZIP centroids: <list>. Use 9am weekday.✓ 已複製
    → Per-ZIP drive time
  3. Aggregate
    How many customers are within 15 min, 30 min, 60 min? Plot a histogram (ascii bars OK).✓ 已複製
    → Bucketed counts that inform the decision

結果: A data-grounded answer to 'should we open here?'

注意事項
  • ZIP centroid is a poor proxy for actual customer addresses — If you have actual addresses, use them; centroids skew suburban analyses
  • Distance matrix limits batch size — Google caps origins×destinations per call; chunk into multiple requests, but you'll pay per element either way
搭配使用: postgres · filesystem

組合

與其他 MCP 搭配,撬動十倍槓桿

google-maps + filesystem

Bulk-geocode a CSV and write the enriched file back

Read /data/customers.csv, geocode each address, write /data/customers_geo.csv with added lat/lng/place_id columns.✓ 已複製
google-maps + postgres

Geocode customer rows during onboarding

For every row in customers where lat IS NULL, geocode the address and update the row. Stop after 500 to manage cost.✓ 已複製
google-maps + brave-search

Brave finds candidate places → Google Maps gets the geocode + directions

Brave-search 'best ramen Mission SF'. For the top 3, get place_ids and walking directions from 16th St BART.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
maps_geocode address: str Address → coordinates $5 / 1000 calls
maps_reverse_geocode lat: number, lng: number Coordinates → address $5 / 1000 calls
maps_search_places query: str, location?, radius? Find places by name/category near a point $17-32 / 1000 (text search) or less for nearby
maps_place_details place_id: str Hydrate one place with full details $17 / 1000 base + add-ons per field
maps_distance_matrix origins[], destinations[], mode?, departure_time? Bulk distance/time between many points $5 / 1000 elements (origin×destination)
maps_directions origin, destination, mode?, waypoints? Turn-by-turn for one route $5 / 1000 calls
maps_elevation locations: [{lat, lng}] Elevation profile for a path or points $5 / 1000 calls

成本與限制

運行它的成本

API 配額
Per-API. Default project caps but raisable.
每次呼叫 Token 數
Small; cost is monetary not tokens
費用
Pay-per-call. Geocoding $5/1k. Place Details $17/1k. Distance Matrix $5/1k elements. $200/mo free credit historically — verify current Google policy.
提示
Cache geocoded addresses indefinitely (they don't change). Distance matrix is the easy way to blow $50 in one prompt — always compute origins × destinations before calling.

安全

權限、密鑰、影響範圍

憑證儲存: API key in env var GOOGLE_MAPS_API_KEY. Restrict the key by API and (if possible) by IP/referrer in Google Cloud console.
資料出站: All calls to maps.googleapis.com
切勿授予: unrestricted-everywhere keys — can be scraped from build artifacts and abused

故障排查

常見錯誤與修復

REQUEST_DENIED

API not enabled for your key, or billing not configured. Enable each API (Geocoding, Places, Directions) in Cloud console and set up billing.

OVER_QUERY_LIMIT

You hit the per-second or per-day cap. Add throttling; raise quota in Cloud console if needed.

ZERO_RESULTS on geocode

Address ambiguous or doesn't exist as written. Try adding country/state, or use Place Autocomplete instead.

Distance matrix INVALID_REQUEST

Check origins×destinations doesn't exceed the per-call element limit (varies by plan). Chunk the request.

替代方案

Google Maps 對比其他方案

替代方案何時用它替代權衡
OpenStreetMap (Nominatim) via fetchFree, no API key, willing to self-rate-limit and accept lower data qualitySparser POI data; usage policy for Nominatim restricts heavy use
Mapbox via custom MCPYou want a managed alternative with often better pricing for high volumeNo first-party MCP yet
HERE / TomTom APIs via custom MCPRouting/POI in regions where Google is weakNo first-party MCP

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills