Mcp Server Tfl

io.github.oneill9由 GitHub 账号 oneill9 发布v1.4.0更新于 Oct 24, 2026

Community-built server providing real-time London transport data via the TfL Unified API

已验证STDIO仅桌面位置与生活效率与工作流

概览

AI 生成的概览

社区构建的 MCP 服务器,通过 TfL 统一 API 让助手获取伦敦交通实时数据:线路状态、到站、行程规划、共享单车、拥挤度和票价。

可以做什么
查询伦敦各交通方式的当前运行状态和中断情况,支持界面的客户端还能显示交互式状态面板。按站名查询公交和地铁的实时到站信息。规划两点之间的行程。列出 Santander Cycles 共享单车停放点。查询车站实时拥挤度和两个指定站点之间的票价信息。站名会自动解析为 NaPTAN 编号。
适用场景
适合让助手回答日常伦敦出行问题,例如某条线路是否正常运行、下一班公交何时到站、如何从一处前往另一处,并使用 TfL 实时数据而非通用知识。
运行要求
以 Node.js 22 及以上版本在本地运行(npm 包、MCPB 包或 Docker 镜像),使用 stdio 传输;也提供 Streamable HTTP 模式。强烈建议使用免费的 TfL API 密钥,通过 TFL_APP_KEY 环境变量传入;TFL_APP_ID 仅旧版注册需要。需要能访问 TfL 统一 API 的网络。
安装前请注意
未设置 TFL_APP_KEY 时,TfL 会施加严格限流,影响大多数实际使用。密钥通过环境变量提供,请勿放入共享配置。查询会转发至 TfL 统一 API,TfL 可看到使用数据。可选的 HTTP 模式没有服务端身份验证,只应部署在可信访问层之后。该项目由社区构建,与伦敦交通局无关联。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Server Tfl,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

TfL MCP Server

[TfL MCP Server logo]

Disclaimer: This is a community-built project. It is not affiliated with, endorsed by, or connected to Transport for London (TfL). This project consumes the publicly available TfL Unified API.

[GitHub release] [License: MIT]

An MCP server that exposes the TfL (Transport for London) Unified API as tools, allowing AI assistants like Claude to query live London transport data.

Version 2 is a single Node.js 22 implementation using the MCP 2026-07-28 protocol revision. It supports stdio for local hosts, npm, and MCPB, plus stateless Streamable HTTP at /mcp for remote deployments.

Protocol compatibility: Streamable HTTP is modern-only MCP 2026-07-28. The stdio entry point also accepts 2025-era initialization for desktop hosts such as Codex, while modern stdio clients continue to negotiate 2026-07-28. Legacy HTTP/SSE is not supported.

Getting Started

Step 1 — Add to Claude Desktop

Open your Claude Desktop config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Option A: Node.js MCPB (recommended)

Download tfl-mcp-server.mcpb from GitHub Releases and install it in Claude Desktop.

Option B: npm

With Node.js 22 or later installed, point Claude Desktop at the published package:

json
{  "mcpServers": {    "tfl-mcp-server": {      "command": "npx",      "args": ["-y", "@oneill9/[email protected]"],      "env": { "TFL_APP_KEY": "your_key_here" }    }  }}

Option C: Docker

json
{  "mcpServers": {    "tfl-mcp-server": {      "command": "docker",      "args": ["run", "-i", "--rm", "-e", "TFL_APP_KEY", "ghcr.io/oneill9/tfl-mcp-server:latest"]    }  }}

Step 2 — Add a TfL API key (recommended)

Without a key, TfL applies strict rate limits that will impact most real-world usage. Register a free key and pass it via the TFL_APP_KEY environment variable. The Docker example's -e TFL_APP_KEY forwards this value into the container:

json
"env": { "TFL_APP_KEY": "your_key_here" }

Step 3 — Restart Claude Desktop and start asking questions

Example: "Is the Central line running normally?", "When is the next bus from Oxford Circus?"

For source, Docker, and Streamable HTTP options, see docs/installation.md.

Tools

ToolDescriptionTfL Endpoint
service_statusCurrent status and disruptions by modeGET /Line/Mode/{modes}/Status
arrivalsLive arrivals at a stop by nameGET /StopPoint/{naptan}/Arrivals
journeyPlan a journey between two pointsGET /Journey/JourneyResults/{from}/to/{to}
bike_pointsList Santander Cycles docking stationsGET /BikePoint
crowdingLive station crowding level by nameGET /Crowding/{naptan}/Live
faresFare information between two named stopsGET /StopPoint/{id}/FareTo/{targetId}

Note: The server uses the /StopPoint/Search/{query} endpoint internally to automatically resolve stop names to NaPTAN IDs for the arrivals, crowding, and fares tools.

MCP Apps UI

The service_status tool includes MCP Apps support as a progressive enhancement. UI-capable hosts (e.g. Claude Desktop) can render an interactive service status board alongside the text response. Non-UI hosts continue to receive the standard text output.

  • The UI is self-contained (inline HTML/CSS, no external assets)
  • Structured JSON data is returned alongside the text fallback
  • No additional setup is required — host support is detected automatically

See docs/tools.md for full details.

Authentication

The MCPB and default container mode use stdio transport. The optional Streamable HTTP mode does not implement OAuth or any other server-side authentication; deploy it only behind an appropriate trusted access layer.

The TfL API uses a simple API key (TFL_APP_KEY) that you supply as an environment variable. A key is strongly recommended — without one, TfL applies strict rate limits that will impact most real-world usage. Registration is free. No OAuth flow, login, or account beyond the TfL portal is required to use this MCP server.

Configuration

Environment VariableDefaultDescription
TFL_APP_KEY(none)TfL API key — register at api-portal.tfl.gov.uk
TFL_APP_ID(none)TfL App ID — only needed for older API registrations that issued both an ID and key
MCP_MAX_REQUEST_BODY_BYTES1048576Maximum JSON request body size accepted by Streamable HTTP
MCP_REQUEST_TIMEOUT_MS30000Streamable HTTP request timeout in milliseconds
MCP_HEADERS_TIMEOUT_MS10000Streamable HTTP header timeout in milliseconds; must not exceed the request timeout

An API key is strongly recommended — without one, TfL's strict rate limits will impact most real-world usage. Registration is free at api-portal.tfl.gov.uk.

Running from source

Node.js 22 or later is required. Install from the lockfile and build before starting the server.

sh
cd nodenpm cinpm run buildnode dist/index.js

That starts stdio transport. For stateless Streamable HTTP:

sh
cd nodeHOST=127.0.0.1 PORT=8080 node dist/index.js --http

Connect an MCP 2026-07-28 client to http://127.0.0.1:8080/mcp. Set MCP_ALLOWED_HOSTS to a comma-separated hostname allowlist when serving under other hostnames.

For use with Claude Desktop, see docs/installation.md.

Testing

Unit tests use a mock HTTP server — no network access or API key required:

sh
cd node && npm test

The Streamable HTTP acceptance tests are included in npm test. Run the official frozen MCP 2026-07-28 requirement set separately (optional extension probes outside that set are not scored):

sh
cd node && npm run test:conformance

The conformance fixture registers the real production TfL tools and resource through the shared modern-only HTTP adapter. It also adds test-only diagnostic tools, resources, prompts, and flows needed by the referee's hard-coded probes; those diagnostics are not exposed by the production entry point.

Contract tests call the live TfL API:

sh
cd node && TFL_APP_KEY=your_key_here npm run contractTest

Build and smoke-test the packed npm CLI, MCPB, and container distributions with bash scripts/test-distributions.sh. The script skips container checks when Docker is unavailable.

Support

For questions, bug reports, or feature requests, please open an issue on GitHub Issues.

Privacy Policy

This MCP server acts as a local proxy between your AI assistant and the TfL Unified API. It does not collect, store, or transmit any personal data beyond what is required to forward your queries to TfL.

  • Data collection: No analytics or telemetry is collected. Limited operational diagnostics are written to standard error but are not persisted by the server; a host may retain them under its own logging policy.
  • Usage and storage: Queries are forwarded to TfL in real time and responses are returned immediately. No query history or results are persisted.
  • Third-party sharing: Requests are forwarded to the TfL Unified API (api.tfl.gov.uk). See TfL's privacy policy for how TfL handles API usage data.
  • Data retention: The server retains no data and holds no state between requests. Host-managed standard-error retention is outside the server's control.
  • Contact: For privacy concerns, open an issue at https://github.com/oneill9/tfl-mcp-server/issues.

The full privacy policy is available at PRIVACY.md.

Compliance

This server has been reviewed for compliance with the Anthropic Software Directory Terms and Anthropic Software Directory Policy. See COMPLIANCE.md for the full compliance statement and maintainer commitments.

TfL API Reference

来源:README.md,提交 bbe1b96

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.4.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分