TfL MCP Server

TfL MCP Server

Enables AI assistants to query live Transport for London data, including service status, arrivals, journey planning, bike points, crowding, and fares.

Category
访问服务器

README

TfL MCP Server

<img src="docs/logo.svg" alt="TfL MCP Server logo" width="80" align="right"/>

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:

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

Option C: Docker

{
  "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:

"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

Tool Description TfL Endpoint
service_status Current status and disruptions by mode GET /Line/Mode/{modes}/Status
arrivals Live arrivals at a stop by name GET /StopPoint/{naptan}/Arrivals
journey Plan a journey between two points GET /Journey/JourneyResults/{from}/to/{to}
bike_points List Santander Cycles docking stations GET /BikePoint
crowding Live station crowding level by name GET /Crowding/{naptan}/Live
fares Fare information between two named stops GET /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 Variable Default Description
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_BYTES 1048576 Maximum JSON request body size accepted by Streamable HTTP
MCP_REQUEST_TIMEOUT_MS 30000 Streamable HTTP request timeout in milliseconds
MCP_HEADERS_TIMEOUT_MS 10000 Streamable 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.

cd node
npm ci
npm run build
node dist/index.js

That starts stdio transport. For stateless Streamable HTTP:

cd node
HOST=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:

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):

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:

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选