Integrations
Supports configuration through .env files for storing API credentials and server settings.
Handles content licensed under Creative Commons Attribution 4.0 International License (CC BY 4.0), ensuring proper attribution for Deutsche Bahn timetable data.
Provides access to Deutsche Bahn timetable data, including current schedules, planned timetables, schedule changes, and station search functionality through the Deutsche Bahn API.
DB Timetable MCP Server
A Model Context Protocol (MCP) server for the Deutsche Bahn Timetable API. The server provides MCP tools and resources for accessing timetable data, station information, and train changes.
Obligation to name:
This project provides Deutsche Bahn timetable data, which is publicly available under the Creative Commons Attribution 4.0 International License (CC BY 4.0) .
Further information about the API and license terms can be found at developers.deutschebahn.com . API requests are subject to the license terms.
Functions
- Current timetables : Retrieve current timetable data for a station
- Timetable changes : Tracking the latest changes
- Planned timetables : Access to planned timetable data for a specific time
- Station search : Search for train stations by name or code
Requirements
- Node.js 18 or higher
- API credentials for the DB Timetable API (client ID and client secret)
installation
- Clone repository:Copy
- Install dependencies:Copy
- Compile TypeScript code:Copy
configuration
Create an .env
file in the root directory of the project with the following environment variables:
Configuration options
DB_TIMETABLE_CLIENT_ID
: Client ID for the DB API (required)DB_TIMETABLE_CLIENT_SECRET
: Client secret for the DB API (required)TRANSPORT_TYPE
: Transport type for the MCP server (stdio
orsse
, default:stdio
)PORT
: Port for the SSE server (default:8080
)SSE_ENDPOINT
: Endpoint for SSE connections (default:/sse
)LOG_LEVEL
: Logging level (debug
,info
,warn
,error
, default:info
)
use
Start server
In stdio mode (for CLI testing and debugging):
In SSE mode (for web clients):
Test with Inspect mode
The server can be tested with the FastMCP Inspector:
MCP tools
The server provides the following tools:
- getCurrentTimetable : Retrieves current timetable data for a station
- Parameter:
evaNo
- EVA number of the station (e.g. 8000105 for Frankfurt Hbf)
- Parameter:
- getRecentChanges : Retrieves recent changes for a station
- Parameter:
evaNo
- EVA number of the station (e.g. 8000105 for Frankfurt Hbf)
- Parameter:
- getPlannedTimetable : Retrieves planned timetable data for a station
- Parameter:
evaNo
- EVA number of the station (e.g. 8000105 for Frankfurt Hbf)date
- Date in YYMMDD format (e.g. 230401 for 01.04.2023)hour
- hour in HH format (e.g. 14 for 2 p.m.)
- Parameter:
- findStations : Searches for stations using a search pattern
- Parameter:
pattern
- search pattern (e.g. "Frankfurt" or "BLS")
- Parameter:
MCP resources
The server provides the following resources:
- Current timetable data :
db-api:timetable/current/{evaNo}
- Current timetable changes :
db-api:timetable/changes/{evaNo}
- Planned timetable data :
db-api:timetable/planned/{evaNo}/{date}/{hour}
- Station search :
db-api:station/{pattern}
Development
Project structure
NPM scripts
npm run build
: Compiles the TypeScript codenpm start
: Starts the servernpm run dev
: Starts the server in development mode with automatic reloadingnpm test
: Runs tests
Extensibility
Potential extensions
- Data processing and enrichment
- Semantic timetable data processing: XML to structured JSON with semantic enrichment
- Historical data analysis for delays and disruptions
- Integration of multimodal transport connections
- Advanced MCP tools
- Route planning between stations
- AI-based delay and capacity forecasts
- Travel disruption analysis
- Accessibility check for stations and connections
License
MCP Server: MIT License
DB Timetable API: Creative Commons Attribution 4.0 International License
This server cannot be installed
Provides access to Deutsche Bahn train timetables, station information, and schedule changes through Model Context Protocol tools and resources.