swiss-rail-mcp

swiss-rail-mcp

A zero-authentication MCP server for Swiss public transport, enabling users to query train connections, disruptions, station facilities, and plan journeys using natural language.

Category
访问服务器

README

swiss-rail-mcp

A zero-auth MCP server for Swiss public transport. Wraps transport.opendata.ch and data.sbb.ch into a single MCP server with 12 tools, 3 resources, and 4 prompts.

PyPI Python License

What it does

Lets an MCP client (Claude Desktop, Claude Code, …) answer real Swiss transport questions without an API key:

  • "When's the next train from Regensdorf to Zürich HB?"
  • "What's the last realistic train home from Bern tonight?"
  • "Any disruptions on the Gotthard line?"
  • "Does Lugano have step-free access and WiFi?"

Communication is stdio only. No keys, no accounts, no rate-limited proxy — just two public, unauthenticated upstream APIs.

Install

Run on demand without installing globally:

uvx swiss-rail-mcp

Or install it as a persistent uv tool:

uv tool install swiss-rail-mcp

Both options pull from PyPI and expose the swiss-rail-mcp console script. Requires Python 3.11+.

Use with Claude Desktop

Add the server to your claude_desktop_config.json:

{
  "mcpServers": {
    "swiss-rail": {
      "command": "uvx",
      "args": ["swiss-rail-mcp"]
    }
  }
}

Restart Claude Desktop. The tools, resources, and /swiss-rail:* slash-commands should appear in the picker.

Use with Claude Code

claude mcp add swiss-rail -- uvx swiss-rail-mcp

Tools

Core (timetable, via transport.opendata.ch)

Tool Purpose
find_station(query) Resolve a place name to canonical stations.
get_connections(from_station, to_station, limit=4, time=None, date=None) Connections between two stations.
get_stationboard(station, limit=10) Next departures from a station.

SBB open data (via data.sbb.ch)

Tool Purpose
get_disruptions(scope=None, limit=10) Active rail-traffic disruptions, optionally filtered.
get_station_facilities(station) Elevator, WiFi, step-free access, waiting room.
get_passenger_frequency(station) Most recent average daily passenger count.

Conversational (compose the above)

Tool Purpose
last_train_home(home_station, current_station, after_time=None) Latest realistic train tonight.
plan_evening_out(from_station, to_station, latest_return_time) Outbound options plus latest safe return.
commuter_summary(home_station, work_station) Next connections + disruption verdict for a daily commute.
journey_with_layover(from_station, to_station, layover_station, layover_minutes) Two-leg journey with a deliberate stop.
accessible_route(from_station, to_station, limit=3) Connections annotated with endpoint accessibility.
bike_friendly_route(from_station, to_station, limit=3) Connections annotated with a per-leg bike-allowed heuristic.

All datetimes returned by the tools are ISO 8601 with a Europe/Zurich offset.

Resources

Read-only URIs the client can fetch. Useful for letting the LLM pull formatted markdown views of live data without a tool call.

URI Returns
transport://disruptions/active Markdown list of all active disruptions.
transport://station/{name}/board Markdown table of the next departures.
transport://station/{name}/info Markdown summary of facilities + frequency.

Prompts

Slash-commands in Claude Desktop (/swiss-rail:<name>) and callable prompts in other MCP clients.

Prompt Use case
plan_weekend_trip(from_station, max_hours=8) Day-trip planner with disruption check.
morning_commute_check(home_station, work_station) Quick sanity-check before leaving the house.
last_train_check(home_station, current_station=None) "What's the last train home?" from where you are.
evening_out_planner(home_station, destination_city) Plan a night out with a safe return.

Example sessions

Real responses from Claude with this MCP server wired up, captured via claude -p --mcp-config … against the live upstream APIs. Reproduce with the snippet at the bottom of this section.

Q: When's the next train from Bern to Zürich HB?

A: Next IR from Bern at 03:00, arriving Zürich HB at 04:11 (direct, 71 min, platform 5).

Q: When's the last realistic train home from Bern to Regensdorf tonight?

A: Your last realistic option is the IC at 23:02 from Bern (platform 6) → Zürich HB 00:16 → SN to Regensdorf-Watt, arriving 00:49. After that you're into Nachtnetz SN trains (last one departs Bern 01:06, arrives 02:49) which usually carry a night surcharge.

Q: Are there any active disruptions on the Swiss rail network right now? Give me just the headline count and the most severe one.

A: 10 active events on the feed. The most severe is a critical interruption on the Basel Bad Bf–Freiburg line between Haltingen and Efringen-Kirchen (accident involving a person), affecting ICE, ECE, EC, NJ, RE 7 and RB 27 — service has since resumed but residual delays/cancellations are possible through 05:00.

Q: Does Zürich HB have step-free access and WiFi?

A: Yes — Zürich HB has both step-free access and WiFi (elevators are also available).

Q: How busy is Lugano station compared to Bern?

A: Bern is much busier, averaging ~177,000 daily passengers in 2025 versus ~32,300 at Lugano — roughly 5.5× the foot traffic.

Q: I'm in Bern and want to grab a coffee in Olten for 30 minutes on my way to Basel SBB. Plan the journey.

A: Take the IR from Bern at 03:00 (platform 5), arriving Olten 03:27. Note: the next onward train to Basel SBB isn't until 04:48 (platform 10AB, arriving 05:26), so your "30 min" coffee stretches to about 81 minutes at this hour — if you're traveling later in the day, ask again with a specific time and I'll find a tighter 30-min layover.

Reproduce

cat > /tmp/swiss-mcp.json <<'EOF'
{ "mcpServers": { "swiss-rail": {
    "command": "uvx", "args": ["swiss-rail-mcp"]
}}}
EOF

claude -p \
  --mcp-config /tmp/swiss-mcp.json \
  "When's the next train from Bern to Zürich HB?"

Times and disruption counts will differ on each run — these were captured live.

Data sources

Two zero-auth sources. Both are unaffiliated with this project.

  • transport.opendata.ch — proxies SBB's HAFAS timetable endpoints. Community-funded; be considerate with request volume.
  • data.sbb.ch — SBB's public Opendatasoft Explore API. Disruptions, station facilities, passenger frequency.

For SBB data that requires an API key (real-time delays, occupancy, fares, train compositions, OJP, SIRI), see malkreide/swiss-transport-mcp. This server stays zero-auth on purpose; see LIMITATIONS.md for the full list of what that excludes and the heuristics used in its place.

Development

uv sync
uv run pytest                          # all tests (hits live APIs)
uv run pytest -m "not integration"     # offline only
uv run ruff check
uv run ruff format --check

Enable verbose HTTP logging with SWISS_TRANSPORT_DEBUG=1.

License

MIT — see LICENSE.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选