SBB Open Data MCP Server
This server connects AI models to Swiss Federal Railways (SBB) open data from data.sbb.ch β no API key required. It enables:
π Passenger frequency β Retrieve daily average boardings/alightings (DTV, DWV, DNWV) by station, canton, or year.
π¨ Live rail disruptions β Fetch real-time Swiss rail traffic messages (titles, descriptions, causes, affected lines), updated every 5 minutes.
ποΈ Infrastructure projects β Browse active SBB station and line construction projects, filterable by city or project type.
π’ Real estate projects β Explore SBB property developments (residential/commercial), filterable by city or phase (planning, construction, completed).
π Train counts per segment β Get yearly train counts per route for operators like SBB, BLS, SOB, and DB, including passenger and freight traffic.
π€οΈ Platform data β Look up platform length, area, type (e.g. Mittelperron), and step-free accessibility for any SBB station.
π Rolling stock β Retrieve technical specs on trains/railcars including seating capacity (1st/2nd class), year built, length, and weight.
π Station comparison β Side-by-side comparison of up to 10 stations across passenger frequency and platform capacity datasets.
π Stop search β Search the full Swiss DiDok register (all public transport operators) by name or canton, returning UIC numbers, coordinates, and operator info.
π¦ Dataset catalogue β Discover all ~89 available SBB open datasets with IDs, titles, record counts, and update frequencies.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SBB Open Data MCP ServerAre there any current disruptions on the Swiss rail network?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π sbb-opendata-mcp
π¨π Part of the Swiss Public Data MCP Portfolio
MCP server connecting AI models to Swiss Federal Railways (SBB) open data β passenger frequency, live rail disruptions, infrastructure & real-estate projects, train counts, platform data, rolling stock and station search from data.sbb.ch. No API key required.
Demo
Overview
sbb-opendata-mcp gives AI assistants like Claude direct access to public SBB data β no copy-pasting or manual API calls. A question like "How many passengers passed through ZΓΌrich HB every day in 2024?" is answered with real measured data.
The SBB Open Data portal speaks the OpenDataSoft REST API (v2.1). This server
translates it into clean Markdown and JSON for the AI model, and adds MCP
structuredContent alongside the human-readable text so programmatic clients can
consume the underlying records without re-parsing. The server is model-agnostic
and works with any MCP-compatible client.
Anchor demo query: "Compare ZΓΌrich HB, Bern and Basel SBB by passenger frequency and platform capacity." β More use cases by audience β
Related MCP server: mcp-swiss
Features
π Passenger frequency β boardings/alightings by station and year (daily averages)
π¨ Live rail disruptions β traffic messages, updated every 5 minutes
ποΈ Infrastructure projects β station and line construction
π’ Real-estate projects β SBB property development (daily updates)
π Trains per segment β train counts per route (SBB, BLS, SOB β¦)
π€οΈ Platform data β length, type, area, step-free access
π Rolling stock β capacity and year built
π Station comparison β up to 10 stations across multiple datasets
π Stop search β Swiss DiDok register (all of Switzerland)
π¦ Dataset catalogue β list all ~89 SBB open datasets
π No API key β all data is public and free to use
βοΈ Dual transport β stdio for Claude Desktop, Streamable HTTP for cloud deployment
Prerequisites
Python 3.11+
No API key β all data comes from the public data.sbb.ch portal
Install uv (recommended):
curl -LsSf https://astral.sh/uv/install.sh | shInstallation
From PyPI:
pip install sbb-opendata-mcpOr with uvx (no permanent installation):
uvx sbb-opendata-mcpFor local development, install from a clone in editable mode:
git clone https://github.com/malkreide/sbb-opendata-mcp.git
cd sbb-opendata-mcp
pip install -e ".[dev]"Quickstart
# Start the server (stdio mode for Claude Desktop)
sbb-opendata-mcpTry it immediately in Claude Desktop:
"How many people boarded at ZΓΌrich HB daily in 2024?" "Are there any current disruptions on the Swiss rail network?"
Configuration
Environment Variables
The server needs no configuration to run over stdio. The variables below tune the optional Streamable HTTP transport, logging and observability.
Variable | Effect | Default |
| Bind host for the HTTP transport. Keep |
|
| Port for the HTTP transport. |
|
| Comma-separated host allow-list for DNS-rebinding protection (e.g. | localhost only |
| Comma-separated browser-origin allow-list (e.g. | (none) |
| Log verbosity ( |
|
|
|
|
π DNS-rebinding / Origin protection is always on; localhost is allow-listed so local HTTP development works out of the box. Logs go to stderr β stdout is reserved for the stdio JSON-RPC channel.
Claude Desktop Configuration
{
"mcpServers": {
"sbb-opendata": {
"command": "uvx",
"args": ["sbb-opendata-mcp"]
}
}
}Config file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Restart Claude Desktop β the server is downloaded automatically on first use.
Other MCP Clients
Works with Cursor, Windsurf, VS Code + Continue, LibreChat, Cline and self-hosted
models via mcp-proxy β same configuration as above.
Cloud Deployment (Streamable HTTP)
For use via claude.ai in the browser or remote servers (e.g. Render.com). The cloud transport is Streamable HTTP (endpoint /mcp).
Docker (recommended):
# Build + run with explicit resource limits (see docker-compose.yml)
docker compose up --build
# β http://127.0.0.1:8000/mcpThe image is a multi-stage build running as a non-root user; docker-compose.yml
adds read_only, no-new-privileges and memory/CPU/PID limits.
Manual / Render.com:
pip install -e .
# Bind publicly (behind a rate-limiting reverse proxy) and configure
# DNS-rebinding / Origin protection for your hostname:
export MCP_HOST=0.0.0.0
export MCP_ALLOWED_HOSTS="your-app.onrender.com,your-app.onrender.com:*"
export MCP_ALLOWED_ORIGINS="https://your-app.onrender.com"
python -m sbb_opendata_mcp.server --http --port 8000β οΈ Binding: In a network transport the server binds to
127.0.0.1by default so a locally started server is not exposed to your whole network. SetMCP_HOST=0.0.0.0only in a container/cloud environment where binding to all interfaces is intended (the Docker image does this for you), and place the server behind a reverse proxy that enforces rate limiting (and authentication, if the endpoint should not be public). SeeSECURITY.md.
Available Tools
Tool | Description | Data Update |
| Boardings/alightings by station and year (daily avg.) | Annual |
| Live rail traffic messages | Every 5 min. |
| Infrastructure construction (stations, lines) | Ongoing |
| SBB real estate development projects | Daily |
| Train counts per route segment (SBB, BLS, SOB β¦) | Annual |
| Platform data (length, type, area) | Ongoing |
| Rolling stock (capacity, year built) | Ongoing |
| Compare up to 10 stations (multi-dataset) | β |
| Search stops (Swiss DiDok register, all CH) | Ongoing |
| List all ~89 SBB open datasets | β |
All tools support response_format: "markdown" (human-readable) and "json"
(machine-readable), plus pagination. Every tool also returns MCP structuredContent
(the underlying records/metadata) alongside the rendered text.
Example Use Cases
Query | Tool |
"How many people boarded at ZΓΌrich HB daily in 2024?" |
|
"Are there any current disruptions on the Swiss rail network?" |
|
"Compare ZΓΌrich HB, Bern and Basel SBB" |
|
"Which SBB construction projects are active in ZΓΌrich?" |
|
"How many trains run yearly on the ZΓΌrichβWinterthur route?" |
|
"Which stops exist in WΓ€denswil?" |
|
β More use cases by audience
Architecture
βββββββββββββββββββ βββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ
β Claude / AI ββββββΆβ SBB Open Data MCP ββββββΆβ data.sbb.ch β
β (MCP Host) βββββββ (MCP Server) βββββββ β
βββββββββββββββββββ β β β OpenDataSoft REST v2.1 β
β 10 Tools β β (public, no API key) β
β Stdio | Streamable HTTP β β β
β β β passagierfrequenz β
β Shared httpx client β β rail-traffic-information β
β (pooled, lifespan-managed)β β construction-projects β
β ODSQL escaping + Pydantic β β perron Β· rollmaterial β
β validation β β zugzahlen Β· dienststellenβ
βββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββProject Structure
sbb-opendata-mcp/
βββ src/sbb_opendata_mcp/
β βββ __init__.py
β βββ server.py # FastMCP server, all 10 tool definitions
βββ tests/
β βββ test_server.py # Unit + live API smoke tests
βββ audits/ # MCP best-practice audit evidence
βββ docs/assets/demo.svg # README demo asset
βββ .github/workflows/ci.yml # GitHub Actions (Python 3.11/3.12/3.13)
βββ Dockerfile # Multi-stage, non-root runtime image
βββ docker-compose.yml # Local run with resource limits
βββ claude_desktop_config.json # Example Claude Desktop config
βββ pyproject.toml
βββ CHANGELOG.md
βββ CONTRIBUTING.md
βββ SECURITY.md
βββ EXAMPLES.md
βββ LICENSE
βββ README.md # This file (English)
βββ README.de.md # German versionSafety & Limits
Read-only: All 10 tools perform read-only HTTP GET requests β no data is written, modified, or deleted upstream.
No personal data: Queries are transient and not stored. The portal returns aggregated statistics, infrastructure and operational metadata. No PII is processed or retained.
No API key: Data is public and free. There is no authentication and no secret to manage.
Injection-hardened:
year/cantonare regex-validated and every value interpolated into an ODSQLwhereclause is escaped via a central helper.Data freshness: Real-time tools (disruptions) reflect the upstream source at query time; statistical datasets update annually/daily (see the tool table).
Terms of service: Data is published under the data.sbb.ch licence (NonCommercialAllowed-CommercialAllowed-ReferenceRequired).
No guarantees: This server is a community project, not affiliated with SBB. Availability depends on the upstream API.
See SECURITY.md for the full security posture.
Known Limitations
Passenger frequency: Updated annually; the latest full year may lag by some months.
Rail disruptions: Returns all current Swiss rail messages β use
limitand pagination.Trains per segment: Counts are yearly aggregates, not real-time.
Station search: Covers the full Swiss DiDok register (all operators), not just SBB.
No rate limiting of its own: Place a public HTTP deployment behind a rate-limiting reverse proxy.
Testing
No API key is required.
# Unit tests (no network required)
PYTHONPATH=src pytest tests/ -m "not live"
# Live API smoke tests (require network access to data.sbb.ch)
PYTHONPATH=src pytest tests/ -m liveChangelog
See CHANGELOG.md
Contributing
See CONTRIBUTING.md
License
MIT License β see LICENSE
Author
Hayal Oezkan Β· github.com/malkreide
Credits & Related Projects
Data: data.sbb.ch β Swiss Federal Railways (SBB) Open Data, OpenDataSoft REST API v2.1
Protocol: Model Context Protocol β Anthropic / Linux Foundation
Related:
swiss-transport-mcp β real-time timetables, journeys & disruptions (opentransportdata.swiss)
swiss-road-mobility-mcp β micromobility & EV charging
zurich-opendata-mcp β MCP server for Zurich city open data
Portfolio: Swiss Public Data MCP Portfolio
Installation
Run via uv's uvx β no clone or manual install needed. Add to your MCP client config (mcpServers for Claude Desktop, Cursor and Windsurf; use a top-level servers key for VS Code in .vscode/mcp.json):
{
"mcpServers": {
"sbb-opendata-mcp": {
"command": "uvx",
"args": [
"sbb-opendata-mcp"
]
}
}
}Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/malkreide/sbb-opendata-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server