transit-mcp
MCP server for Japanese public transit journey planning with interactive map UI, enabling station search, route planning, and departure lookups via natural language.
README
transit-mcp
MCP server for Japanese public transit transfer / journey planning, with a map-based iframe UI rendered inside Claude and ChatGPT through the Model Context Protocol Apps SDK.
Built on Cloudflare Workers (Hono) + @modelcontextprotocol/sdk (Streamable
HTTP transport) + @modelcontextprotocol/ext-apps + React + MapLibre GL. It
wraps the public Transit API (api.transit.ls8h.com) behind the Cloudflare
Cache and exposes four tools to MCP clients.
Features
Four tools are exposed over MCP:
search_places— fuzzy place / station search by free-text query.plan_journey— point-to-point journey planning from free-textfrom/to. Returns a map-based iframe HTML resource with the route drawn over a MapLibre map.station_departures— upcoming departures for a station at a given time.station_detail— full detail of a single station (lines served, exits, etc.).
Only plan_journey returns an MCP UI resource (_meta.ui.resourceUri); the
other three return JSON only.
Quick start (clients)
The server speaks the Streamable HTTP MCP transport. Once deployed it is
reachable at https://transit-mcp.tori-dev.com/mcp.
Claude Desktop
Edit your claude_desktop_config.json:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Add a transit-mcp entry under mcpServers:
{
"mcpServers": {
"transit-mcp": {
"type": "http",
"url": "https://transit-mcp.tori-dev.com/mcp"
}
}
}
Restart Claude Desktop. The four tools appear in the tool picker. Try:
- 「渋谷から東京駅までの経路を教えて」 →
plan_journeyruns and an interactive map iframe is embedded directly in the chat. - 「新宿駅の次の発車は?」 →
station_departuresreturns the next trains. - "Plan a route from Shibuya to Tokyo Station" → English summary, same map.
- "What's the next train from Shinjuku?" →
station_departures.
If you self-host you can point at http://localhost:8787/mcp for local
development.
ChatGPT (Apps SDK)
The MCP Apps SDK in ChatGPT discovers servers by URL exactly like Claude Desktop:
- Open ChatGPT settings → Apps & Connectors → Add MCP Server.
- Enter the server URL:
https://transit-mcp.tori-dev.com/mcp. - Choose transport: Streamable HTTP.
- Approve the four tools when prompted.
The iframe HTML resource is served from /ui/plan on the same Worker and is
rendered inline in ChatGPT just like in Claude Desktop.
Custom GPT (Actions) fallback
If you need to register transit-mcp inside a Custom GPT before Apps SDK is available in your tier, wrap the tools as OpenAI Actions:
- Create a Custom GPT in the ChatGPT builder.
- Under Actions → Create new action, import an OpenAPI 3.1 schema that
POSTs to
/mcpwith the standard MCP envelope. (A minimal example schema lives inexamples/openai-actions/— TODO for v0.2.) - Note: Custom GPT Actions cannot render the
_meta.ui.resourceUriiframe; only the textual summary will be displayed.
For the richest experience, prefer the Apps SDK path.
Local development
pnpm install
pnpm dev # Wrangler dev server on http://localhost:8787
pnpm inspect # MCP Inspector against the local server
Useful scripts:
pnpm test/pnpm test:watch— Vitest (65 tests at time of writing)pnpm typecheck—tsc --noEmitpnpm lint/pnpm format— Biomepnpm build:ui— bundle the iframe UI with esbuildpnpm generate:types— regenerate Transit API types from its OpenAPI
To exercise tools locally with the MCP Inspector:
pnpm dev # terminal 1
pnpm inspect # terminal 2 → http://localhost:6274
# In the Inspector, click `connect`, then `tools/call`:
# { "name": "plan_journey", "arguments": { "from": "渋谷", "to": "東京" } }
# Copy the returned _meta.ui.resourceUri into a browser tab — the iframe HTML
# will render the route on a MapLibre map.
Deployment
pnpm build:ui
pnpm dlx wrangler@latest deploy
Pre-flight: the KV namespace UI_CACHE must exist before deploy.
pnpm dlx wrangler@latest kv namespace create UI_CACHE
# Copy the returned id into wrangler.toml under [[kv_namespaces]].
A dry-run is also wired into CI for every PR:
pnpm dlx wrangler@latest deploy --dry-run
Configuration
| Var | Where | Default |
|---|---|---|
TRANSIT_API_BASE |
wrangler.toml [vars] |
https://api.transit.ls8h.com |
MAP_STYLE_URL |
wrangler.toml [vars] |
OpenFreeMap public style URL |
DEFAULT_LANG |
wrangler.toml [vars] |
ja |
UI_CACHE |
KV binding | created per env (wrangler kv namespace create) |
CLOUDFLARE_API_TOKEN |
GitHub Actions secret | required by deploy job |
CLOUDFLARE_ACCOUNT_ID |
GitHub Actions secret | required by deploy job |
Attribution
Required attribution is surfaced in the iframe footer:
- Transit data: per-feed credits returned by
/api/v1/feedsand/api/v1/operators(cached in KV for 1 hour). - Map tiles: © OpenStreetMap contributors, served via © OpenFreeMap.
Override MAP_STYLE_URL if you self-host MapTiler / Protomaps and want their
attribution shown instead — the iframe reads it from the worker env at render
time.
License
MIT.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。