返回市场
谷歌地图

谷歌地图

作者:modelcontextprotocol150 星标更新:2025-05-29

项目介绍

Google Maps MCP Server

用于Google Maps API的MCP服务器。

工具

  1. maps_geocode

    • 将地址转换为坐标
    • 输入:address(字符串)
    • 返回值:位置、格式化地址、地点ID
  2. maps_reverse_geocode

    • 将坐标转换为地址
    • 输入:
      • latitude(数字)
      • longitude(数字)
    • 返回值:格式化地址、地点ID、地址组件
  3. maps_search_places

    • 使用文本查询搜索地点
    • 输入:
      • query(字符串)
      • location(可选):{ latitude: 数字, longitude: 数字 }
      • radius(可选):数字(米,最大50000)
    • 返回值:包含名称、地址、位置的地点数组
  4. maps_place_details

    • 获取地点的详细信息
    • 输入:place_id(字符串)
    • 返回值:名称、地址、联系方式、评分、评论、营业时间
  5. maps_distance_matrix

    • 计算点之间的距离和时间
    • 输入:
      • origins(字符串数组)
      • destinations(字符串数组)
      • mode(可选):"driving" | "walking" | "bicycling" | "transit"
    • 返回值:距离和持续时间矩阵
  6. maps_elevation

    • 获取地点的高程数据
    • 输入:locations({latitude, longitude} 数组)
    • 返回值:每个点的高程数据
  7. maps_directions

    • 获取点之间的路线
    • 输入:
      • origin(字符串)
      • destination(字符串)
      • mode(可选):"driving" | "walking" | "bicycling" | "transit"
    • 返回值:包含步骤、距离、持续时间的路线详情

配置

API密钥

按照此处的说明获取Google Maps API密钥。

与Claude Desktop一起使用

在你的claude_desktop_config.json中添加以下内容:

Docker

{
  "mcpServers": {
    "google-maps": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GOOGLE_MAPS_API_KEY",
        "mcp/google-maps"
      ],
      "env": {
        "GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}

NPX

{
  "mcpServers": {
    "google-maps": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-google-maps"],
      "env": {
        "GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}

与VS Code一起使用

快速安装,请使用下面的一个一键安装按钮...

通过NPX在VS Code中安装 通过NPX在VS Code Insiders中安装

通过Docker在VS Code中安装 通过Docker在VS Code Insiders中安装

手动安装,请在VS Code的用户设置(JSON)文件中添加以下JSON块。你可以通过按Ctrl + Shift + P并键入Preferences: Open User Settings (JSON)来完成此操作。

可选地,你可以将其添加到工作区中的.vscode/mcp.json文件中。这将允许你与其他人员共享配置。

注意,在.vscode/mcp.json文件中不需要mcp键。

{
  "mcp": {
    "inputs": [
      {
        "type": "promptString",
        "id": "maps_api_key",
        "description": "Google Maps API Key",
        "password": true
      }
    ],
    "servers": {
      "google-maps": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-google-maps"],
        "env": {
          "GOOGLE_MAPS_API_KEY": "${input:maps_api_key}"
        }
      }
    }
  }
}

对于Docker安装:

{
  "mcp": {
    "inputs": [
      {
        "type": "promptString",
        "id": "maps_api_key",
        "description": "Google Maps API Key",
        "password": true
      }
    ],
    "servers": {
      "google-maps": {
        "command": "docker",
        "args": ["run", "-i", "--rm", "mcp/google-maps"],
        "env": {
          "GOOGLE_MAPS_API_KEY": "${input:maps_api_key}"
        }
      }
    }
  }
}

构建

Docker构建:

docker build -t mcp/google-maps -f src/google-maps/Dockerfile .

许可证

此MCP服务器根据MIT许可证发布。这意味着你可以自由地使用、修改和分发该软件,但需遵守MIT许可证的条款和条件。更多详情,请参见项目存储库中的LICENSE文件。