英国列车实时查询 MCP 服务

提供英国铁路实时出发、到达与列车停靠站详情查询的 MCP 服务,适用于需要实时列车运行数据的 MCP 客户端。

  • by henricook
  • JavaScript
  • 混合部署
  • 5 星标
  • 更新于
在 GitHub 查看 henricook/mcp-national-rail-ng

使用说明

mcp-national-rail-ng

MCP server for live UK train data. Query departures, arrivals, and service details from any MCP client using the Realtime Trains NG API.

You'll need a free refresh token from api-portal.rtt.io. Sign up, then click on the UUID shown on the dashboard to reveal your refresh token (a long JWT starting with eyJ...). The UUID itself is not the token.

Use the hosted server

The quickest way to get started. No installation needed.

Claude Code

claude mcp add --transport http national-rail https://rtt-mcp.henricook.com/mcp \
  --header "Authorization: Bearer <your-rtt-refresh-token>"

OpenAI Codex

Set your refresh token as an env var:

export RTT_REFRESH_TOKEN="<your-rtt-refresh-token>"

Then add the server in ~/.codex/config.toml:

[mcp_servers.national-rail]
url = "https://rtt-mcp.henricook.com/mcp"
bearer_token_env_var = "RTT_REFRESH_TOKEN"

Then just ask

  • "What are the next departures from King's Cross?"
  • "Show me arrivals at Clapham Junction from Waterloo"
  • "Get the full calling points for service gb-nr:C40827:2026-03-29"

Self-host (run from source)

git clone https://github.com/henricook/mcp-national-rail-ng.git
cd mcp-national-rail-ng
npm install && npm run build

HTTP mode (remote clients)

Each connecting client provides their own RTT refresh token via the Authorization header.

PORT=3456 npm run start:http

Stdio mode (local clients)

For local MCP clients like Claude Desktop or nanoclaw.

RTT_REFRESH_TOKEN=<your-token> npm start

Or add to Claude Desktop's config:

{
  "mcpServers": {
    "national-rail": {
      "command": "node",
      "args": ["/path/to/mcp-national-rail-ng/dist/index.js"],
      "env": {
        "RTT_REFRESH_TOKEN": "<your-token>"
      }
    }
  }
}

Tools

Tool Description
get_departures Live departures from a station, optionally filtered by destination
get_arrivals Live arrivals at a station, optionally filtered by origin
get_service Full calling points for a specific service

Station codes are 3-letter CRS codes (e.g. KGX, PAD, CLJ) or longer TIPLOC codes. The gb-nr: namespace prefix is added automatically.

Rate limits

The RTT NG API has rate limits per token: 30/min, 750/hr, 9,000/day, 30,000/week. Each user's token is rate-limited independently.

Credits

Train data is provided by Realtime Trains, an independent project by swlines ltd. Realtime Trains has been providing live running information for the GB rail network since 2012 and is not affiliated with National Rail or any train operator. If you find the data useful, consider supporting the project.