Mapbox MCP Server

Mapbox MCP Server

镜像的

简介

Mapbox MCP 服务器为Claude提供导航和地理搜索功能,包括路线规划、距离矩阵计算和地点搜索。

设置

前提条件

  • Node.js 16+
  • TypeScript 4.5+
  • Mapbox API 密钥(从Mapbox控制台获取)

安装

  1. 设置API密钥:

    export MAPBOX_ACCESS_TOKEN=your_api_key_here
    
  2. 在Claude桌面配置文件中添加MCP服务器:

    {
      "mcpServers": {
        "mapbox-mcp-server": {
          "command": "node",
          "args": ["/absolute/path/to/mapbox-mcp-server/build/index.js"],
          "env": {
            "MAPBOX_ACCESS_TOKEN": "your-api-key"
          }
        }
      }
    }
    

可用工具

导航

1. mapbox_directions

获取坐标间路线:

// 输入
{
  "coordinates": [{latitude: number, longitude: number}, ...],
  "profile": "driving-traffic" | "driving" | "walking" | "cycling" // 可选
}

2. mapbox_directions_by_places

使用地点名称获取路线:

// 输入
{
  "places": ["地点1", "地点2", ...],
  "profile": "driving-traffic" | "driving" | "walking" | "cycling", // 可选
  "language": "zh" | "en" | ... // 可选
}

3. mapbox_matrix

计算坐标间距离/时间矩阵:

// 输入
{
  "coordinates": [{latitude: number, longitude: number}, ...],
  "profile": "driving" | "walking" | "cycling", // 可选
  "annotations": "duration" | "distance" | "duration,distance", // 可选
  "sources": [0, 1, ...], // 可选
  "destinations": [0, 1, ...] // 可选
}

4. mapbox_matrix_by_places

使用地点名称计算距离/时间矩阵:

// 输入
{
  "places": ["地点1", "地点2", ...], // 2-25个地点
  "profile": "driving" | "walking" | "cycling", // 可选
  "annotations": "duration" | "distance" | "duration,distance", // 可选
  "language": "zh" | "en" | ..., // 可选
  "sources": [0, 1, ...], // 可选
  "destinations": [0, 1, ...] // 可选
}

搜索

mapbox_geocoding

搜索地点并转换地址为坐标:

// 输入
{
  "searchText": "查询文本",
  "limit": 1-10, // 可选
  "types": ["country", "region", "place", ...], // 可选
  "language": "zh" | "en" | ..., // 可选
  "fuzzyMatch": true | false // 可选
}

速率限制

  • 方向API:300次/分钟
  • 矩阵API:
    • 驾车/步行/骑行:60次/分钟
    • 驾车交通:30次/分钟
  • 地理编码API:600次/分钟

错误处理

所有工具都包含全面错误处理,涵盖输入验证、API请求失败、速率限制和服务特定错误。

许可证

MIT许可证