SNCF API 的 MCP 服务接口

SNCF API 的 MCP 服务接口

为 SNCF API 提供模块化的 Python 封装,并通过 MCP 服务器与 Claude Desktop 集成,用于智能行程规划和列车信息检索。

快速入门

安装

  1. 克隆仓库: git clone https://github.com/Kryzo/mcp-sncf.git cd mcp-sncf
  2. 安装依赖: pip install -r requirements.txt

如果没有 requirements.txt 文件,安装以下包: pip install requests pandas mcp

获取 API 密钥

  1. 访问 SNCF API 门户 并注册。
  2. 订阅 Navitia API 服务并获取密钥。

配置

  1. 在 Claude Desktop 中设置配置文件(通常位于 %APPDATA%\Claude\claude_desktop_config.json): { "sncf": { "command": "py", "args": [ "<项目路径>/sncf_server.py", "--api-key=<你的API密钥>" ], "cwd": "<项目路径>" } }
  2. 保存文件并重启 Claude Desktop。

使用示例

  • 规划旅程:Plan a train journey from Paris to Lyon tomorrow morning at 8 AM.
  • 查询车站信息:What transport options are available at the main train station in Grenoble?
  • 检查列车时刻表:Show me the next 5 train departures from Paris Gare de Lyon.