mapbox-mcp-server

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides navigation and geocoding capabilities through the Mapbox API, including routing between coordinates or place names, calculating travel time and distance matrices, and converting place names to coordinates.

Mapbox MCP 服务器

Mapbox API 的 MCP 服务器。

特征

导航工具

  1. mapbox_directions
    • 获取坐标之间的方向
    • 输入:
      • coordinates ({纬度:数字,经度:数字}[])
      • profile (可选):“驾驶交通”,“驾驶”,“步行”,“骑自行车”
    • 返回:路线详情,包括步数、距离、持续时间
  2. mapbox_directions_by_places
    • 使用地点名称获取地点之间的路线
    • 输入:
      • places (string[]):地名数组
      • profile (可选):“驾驶交通”,“驾驶”,“步行”,“骑自行车”
      • language (可选):两个字母的语言代码(例如“zh”、“en”)
    • 返回:
      • 每个地点的地理编码结果
      • 路线详情,包括步数、距离、持续时间
      • 处理过程中发生的任何错误
  3. mapbox_matrix
    • 计算坐标之间的行程时间和距离矩阵
    • 输入:
      • coordinates ({纬度:数字,经度:数字}[])
      • profile (可选):“驾驶”、“步行”、“骑自行车”
      • annotations (可选):“持续时间”、“距离”、“持续时间,距离”
      • sources (可选):源坐标的索引
      • destinations (可选):目的地坐标的索引
    • 返回:点之间的持续时间和/或距离的矩阵
  4. mapbox_matrix_by_places
    • 使用地点名称计算地点之间的旅行时间和距离矩阵
    • 输入:
      • places (string[]): 地名数组(2-25 个地点)
      • profile (可选):“驾驶”、“步行”、“骑自行车”
      • annotations (可选):“持续时间”、“距离”、“持续时间,距离”
      • language (可选):两个字母的语言代码
      • sources (可选):来源地索引
      • destinations (可选):目的地索引
    • 返回:
      • 每个地点的地理编码结果
      • 持续时间和/或距离矩阵
      • 处理过程中发生的任何错误

搜索工具

  1. mapbox_geocoding
    • 搜索地点并将地址转换为坐标
    • 输入:
      • searchText (字符串):要搜索的地点或地址
      • limit (可选):最大结果数(1-10)
      • types (可选):按地点类型(国家、地区、地点等)进行过滤
      • language (可选):两个字母的语言代码
      • fuzzyMatch (可选):启用/禁用模糊匹配
    • 返回:详细的位置信息,包括坐标和属性

Claude 桌面集成

将此配置添加到您的 Claude Desktop 配置文件(通常位于~/Library/Application Support/Claude/claude_desktop_config.json ):

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

设置

先决条件

  • Node.js 16 或更高版本
  • TypeScript 4.5 或更高版本
  • 有效的 Mapbox API 密钥

API 密钥

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

将您的 API 密钥设置为环境变量:

export MAPBOX_ACCESS_TOKEN=your_api_key_here

速率限制

  • 路线 API:每分钟 300 个请求
  • 矩阵 API:
    • 每分钟 60 个驾驶/步行/骑行请求
    • 每分钟 30 个驾驶交通请求
  • 地理编码 API:每分钟 600 个请求

部署

结构

在 mapbox-mcp-server 中,我们使用以下结构来管理服务器的处理程序:

  • src/server/handlers/base.ts :所有处理程序的基类
  • src/server/registry.ts :所有处理程序的注册表
  • src/server/main.ts :服务器的主入口点

每个功能模块都遵循以下结构:

src/ ├── types/ # Type definitions ├── schemas/ # Zod schemas for validation ├── tools/ │ ├── definitions/ # Tool definitions │ └── handlers/ # Tool implementations └── server/ └── handlers/ # Handler classes

类图


流程图

错误处理

所有工具都实现了全面的错误处理:

  • 输入验证错误
  • API 请求失败
  • 速率限制错误
  • 服务特定错误(例如,未找到路线、坐标无效)

执照

此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。

ID: ijqo60lj52