MCP server exposing live Deutsche Bahn data: journeys, delays, disruptions, strikes, and alternative routes.
Project description
mcp-deutsche-bahn
An MCP server that gives any MCP-compatible AI assistant (Claude Desktop, Claude Code, Cursor, etc.) live access to Deutsche Bahn data: journey planning, real-time delays, disruptions, construction works, strikes, and alternative routes.
Status: v0.1.0 — alpha. Backed by the open
transport.restAPI — no API key required.
What it does
Six tools, available to your LLM:
| Tool | Answers |
|---|---|
search_journeys |
"How do I get from Berlin Hbf to München Hbf tomorrow at 9am?" |
station_departures |
"What's leaving Hamburg Hbf in the next hour?" |
journey_status |
"Has my booked journey been delayed?" |
get_disruptions |
"Any construction on the Köln–Frankfurt corridor?" |
detect_strike |
"Is there a strike going on right now?" |
find_alternatives |
"Route me around Hannover Hbf if it's blocked." |
Quickstart (3 steps, ~2 min)
You need Python 3.10+ and uv (one-line install: curl -LsSf https://astral.sh/uv/install.sh | sh).
# 1. Clone & install
git clone https://github.com/heykay/mcp-deutsche-bahn.git
cd mcp-deutsche-bahn
uv sync
# 2. Sanity-check the server starts
uv run mcp-deutsche-bahn --help 2>&1 | head -1 || echo "server module loaded ✓"
# 3. Note the full path — you'll paste it into the config below
pwd
Then wire it into your MCP client (pick one):
Claude Desktop
Open ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows). Add:
{
"mcpServers": {
"deutsche-bahn": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/FROM/STEP-3",
"run",
"mcp-deutsche-bahn"
]
}
}
}
Restart Claude Desktop. A tool icon appears in the input bar → click → confirm deutsche-bahn is listed.
Claude Code
claude mcp add deutsche-bahn -- uv --directory /ABSOLUTE/PATH/FROM/STEP-3 run mcp-deutsche-bahn
Cursor / other MCP clients
Same shape — command: uv, args: ["--directory", "<path>", "run", "mcp-deutsche-bahn"].
Try it
Ask your assistant:
What are my options getting from Berlin Hbf to Munich tomorrow at 8am, and is there any construction on that route?
It will call search_journeys and get_disruptions and stitch a human answer.
Optional: standalone CLI agent
If you want a plain-English REPL without Claude Desktop, the project also ships an anthropic-powered front-end that drives the MCP server directly:
export ANTHROPIC_API_KEY=sk-ant-...
uv run mcp-deutsche-bahn-agent # interactive
uv run mcp-deutsche-bahn-agent "next trains out of Hamburg" # one-shot
Configuration
| Env var | Default | Purpose |
|---|---|---|
DB_TRANSPORT_API |
https://v6.db.transport.rest |
Point at a self-hosted transport.rest for reliability. |
ANTHROPIC_API_KEY |
(unset) | Only needed for the optional CLI agent above. |
Local development
uv sync --extra dev
uv run pytest -m live # smoke tests, hit the real API
uv run ruff check .
Run the server in inspector mode to poke individual tools without an MCP client:
npx @modelcontextprotocol/inspector uv run mcp-deutsche-bahn
Known limits
- Community backend.
transport.restis an open wrapper around DB data, not an official DB product. The public instance has no uptime SLA and rate-limits. For reliability, self-host (Docker image available) and pointDB_TRANSPORT_APIat it. - Strike detection is heuristic. There is no machine-readable "is there a strike?" API. The tool stacks signals from route remarks and DB's construction RSS feed and returns a confidence score. Confirm via bahn.de/service/aktuell, GDL, or EVG before acting.
- Read-only. Tells you about journeys; doesn't buy tickets.
- Station resolution is best-effort. "Berlin Hbf" is reliable; "berlin" picks the first match. Be specific for edge cases.
Roadmap
- v0.2: hosted/remote MCP variant (HTTP + SSE) for non-CLI users
- v0.2: richer strike signal — wire to a real news API
- v0.3: ticket-price comparison via DB API Marketplace
Contributing
PRs welcome. File issues with the query that broke and the JSON the tool returned.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_deutsche_bahn-0.1.0.tar.gz.
File metadata
- Download URL: mcp_deutsche_bahn-0.1.0.tar.gz
- Upload date:
- Size: 80.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dcfcea587b108cd05a371c639eb801eca295d6ce01a69aaa8c17ca614af36b7
|
|
| MD5 |
3c5c92508936e4b8fb4ff625af8045ee
|
|
| BLAKE2b-256 |
b3458e174681f80d38ed7c193ad8a10390ce2d08e20273fd1fbff7ba5c27fe7c
|
File details
Details for the file mcp_deutsche_bahn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_deutsche_bahn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f28537c638e8638347ce0ca36c50eed788562d1132b36c2d52ffebefbaea57b0
|
|
| MD5 |
98d4950fe98efc0014dcf5d3d045e129
|
|
| BLAKE2b-256 |
dd7f7720722ffed4e19de141df04b613cfccb3a67ee68187acb0f07227fe592f
|