Google Maps MCP服务器

一个轻量级的Google Maps MCP服务器,通过stdio封装Google Maps REST API,适用于Claude Code和其他MCP兼容客户端。

  • by BrendanMartin
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 BrendanMartin/google-maps-mcp

使用说明

谷歌地图MCP服务器

轻量级 主控程序 将谷歌地图REST API封装在stdio上的服务器。内置Go,可与Claude Code和其他MCP兼容客户端一起使用。没有SDK或抽象层-只需直接对Google Maps API进行HTTP调用,结果格式为纯文本。

为什么选择Node.js/Docker替代品?

这 官方MCP谷歌地图服务器 (现已存档)和社区替代方案都需要Node.js或Docker。这是一个单一的静态二进制文件(约11MB),没有运行时依赖关系——否 node_modules,没有容器,没有 npx。它立即启动并使用最少的内存。

此服务器 Node.js替代方案
运行时 无(静态二进制) Node.js+npm
安装 下载二进制文件 npx 或Docker
二进制大小 ~11MB ~100MB+(带节点模块)
启动 即时 ~1-2s(Node.js冷启动)
依赖项 0 npm包

工具

工具 说明
maps_geocode 将地址转换为纬度/经度坐标
maps_reverse_geocode 将坐标转换为地址
maps_directions 通过逐步导航获取路线
maps_distance_matrix 计算多个出发地/目的地之间的距离和旅行时间
maps_search_places 通过文本查询搜索地点

设置

先决条件

安装

从以下网址下载适用于您平台的预构建二进制文件 发布,或从源代码构建:

# Option 1: go install
go install github.com/brendanmartin/google-maps-mcp@latest

# Option 2: build from source
git clone https://github.com/BrendanMartin/google-maps-mcp.git
cd google-maps-mcp
go build -o google-maps-mcp .

在Claude代码中配置

添加 ~/.claude.json 在...之下 mcpServers:

{
  "mcpServers": {
    "google-maps": {
      "type": "stdio",
      "command": "/path/to/google-maps-mcp",
      "env": {
        "GOOGLE_MAPS_API_KEY": "your-api-key"
      }
    }
  }
}

用法

配置后,Claude Code将可以访问地图工具。示例提示:

  • “从纽约到波士顿有多远?”
  • “在时代广场附近找咖啡店”
  • “40.7128-74.0060的地址是什么?”
  • “获取从洛杉矶国际机场到圣莫尼卡的过境路线”

示例:Claude代码代理

您可以创建一个在轻量级模型上运行的专用地图代理。将此另存为 ~/.claude/agents/maps.md:

---
name: maps
description: Location and maps agent for geocoding, directions, distances, and place search
model: haiku
tools: mcp__google-maps__maps_geocode, mcp__google-maps__maps_reverse_geocode, mcp__google-maps__maps_directions, mcp__google-maps__maps_distance_matrix, mcp__google-maps__maps_search_places, WebSearch, WebFetch
---

You are a location and maps assistant. Use the Google Maps MCP tools to answer questions about places, directions, distances, and coordinates.

## Available tools

- **maps_geocode** — Convert an address to lat/lng coordinates
- **maps_reverse_geocode** — Convert lat/lng to an address
- **maps_directions** — Get directions between two locations (supports driving, walking, bicycling, transit)
- **maps_distance_matrix** — Calculate distances and travel times between multiple origins and destinations
- **maps_search_places** — Search for places by text query (e.g. "coffee shops near Central Park")

## Guidelines

1. Use the most specific tool for the task
2. For directions, default to driving mode unless the user specifies otherwise
3. For distance_matrix, batch multiple origins/destinations into a single call when possible
4. Use WebSearch/WebFetch to supplement maps data with additional context when helpful (hours, reviews, menus, etc.)
5. Return concise, well-formatted results
6. When comparing options, present results in a clear table or list

Multiple instances of this agent can be launched in parallel for independent location queries.

然后在您的 CLAUDE.md:

## Maps & Location
When the user asks about directions, distances, travel times, place search, geocoding, or anything
location-related, use the `maps` agent which runs on Haiku. Spawn multiple agents in parallel for
independent location queries.

许可证

麻省理工学院