db-mcp
Provides tools for searching German train stations, retrieving departures, planning journeys, getting trip details, station info, and nearby stations via the Deutsche Bahn public transport API.
db-mcp-server
An MCP server that exposes the Deutsche Bahn public transport API to any MCP-compatible client (Claude Desktop, Cursor, Cline, Continue, etc.). Six tools cover station search, departures, journey planning, trip details, station info, and nearby stations.
Built on the v6.db.transport.rest API, which is free and requires no authentication. ~400 lines of Python.
Tools
Tool | Purpose |
| Find German train stations by name. Returns IDs needed by the other tools. |
| Upcoming departures from a station with line, direction, platform, delay. |
| Connection between two stations with duration, transfers, platforms. |
| Full stop-by-stop schedule for one specific train. |
| Address, coordinates, and facilities (lifts, accessible toilets, etc.) for a station. |
| Stations near a lat/lon coordinate. |
Related MCP server: Where's My DB?
Transports
# stdio (default — what every MCP client expects)
uv run db-mcp
# HTTP / SSE for browser-resident clients and curl debugging
uv run db-mcp --transport sse --port 8765
uv run db-mcp --transport streamable-http --port 8765Install via uvx (no clone needed)
If your client supports it, you can run the server straight from this repo with no install step:
{
"mcpServers": {
"deutsche-bahn": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Amor216/db-mcp-server", "db-mcp"]
}
}
}Claude Desktop setup
Put the snippet above into your claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Restart Claude Desktop. The tools appear under the hammer icon. Try asking:
When is the next ICE from Berlin Hbf to Munich?
Local development
git clone https://github.com/Amor216/db-mcp-server
cd db-mcp-server
uv sync
uv run pytest -qTo run the server against stdin/stdout directly:
uv run db-mcpThat's the same thing your MCP client will spawn under the hood.
Layout
src/db_mcp/
server.py FastMCP server, 5 tools
client.py thin httpx wrapper around transport.rest
formatters.py API JSON -> compact text the LLM can read
tests/
test_client.py httpx mocked with respx
test_formatters.py snapshot-style assertions
test_server.py tool-call smoke testsWhy the formatter layer
The transport.rest API returns deeply nested JSON. Handing that straight to an LLM wastes context and confuses the model. The formatters turn each response into compact text, one departure or one journey per line, so the model reads it the way a human reads a station board.
Rate limits
The upstream API allows 100 requests/minute (200 burst). The server makes one request per tool call, so a normal conversation stays well under the limit. There's no caching layer right now since the data (delays, platforms) is real-time and would lose value if stale.
License
MIT.
Available Tools
6 toolsget_departuresA
Get upcoming departures from a German train station.
Returns one line per departure: time, train line, direction, platform, delay.
Inputs: station_id (required), minutes_ahead, limit. Returns: result
get_station_infoA
Get full details for a German train station: address, coordinates, facilities (lifts, accessible toilets, parking, taxis, dining, shops, etc.).
Inputs: station_id (required). Returns: result
get_trip_detailsB
Get the full stop-by-stop schedule for a specific train trip, including real-time delays.
Inputs: trip_id (required). Returns: result
nearby_stationsC
Find train stations near a geographic coordinate.
Inputs: latitude (required), longitude (required), radius_m, limit. Returns: result
plan_journeyA
Plan a train journey between two German stations.
Returns one block per option: departure / arrival times, platforms, duration, transfers, lines used.
Inputs: from_station_id (required), to_station_id (required), departure, results. Returns: result
search_stationA
Find German train stations by name. Returns one line per match with the station ID and full name.
The station ID is what you pass to get_departures or plan_journey.
Inputs: query (required), limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
All tools have distinct purposes: station search, station details, departures, journey planning, trip details, and nearby stations. No overlapping responsibilities.
All names follow snake_case with a consistent verb_noun pattern (e.g., get_departures, search_station). 'nearby_stations' is a minor deviation but still clear and consistent in style.
Six tools is appropriate for a German railway information server, covering essential operations without unnecessary clutter.
Covers core CRUD-like operations for stations and journeys, but missing some advanced features like real-time delay feeds or station board filtering. Still functional for most use cases.
Maintenance
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Hosted MCP server for live public-data APIs and Skills for AI agents.
The Ferryhopper MCP server is a connector for LLMs and AI Agents in maritime travel that exposes ferry routes, schedules, and booking options. It enables AI assistants to search ports and connections across 33 countries and 190+ ferry operators, provide real-time ferry itineraries with indicative prices, and assist users with planning island-hopping or multi-leg journeys by processing natural language queries about ferry times, passenger counts, and travel durations.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that enables AI assistants to interact with the Netherlands Railways (NS) API for route planning, pricing, and real-time departure information. It provides tools for searching stations, planning trips with connections, and viewing real-time departure boards.31MIT
- AlicenseNot gradedqualityCmaintenanceA Claude skill + MCP server that tells you how Deutsche Bahn delays will affect your trip — not just whether your train is late.MIT
- FlicenseAqualityDmaintenanceMCP server for querying German public transport information, including station search, live departures/arrivals, and journey planning.51-
- AlicenseNot gradedqualityDmaintenanceMCP server for real-time German public transport data (HAFAS/VBN network). Enables querying departures, arrivals, journeys, and nearby stops using natural language.ISC