Skip to main content
Glama

DB Timetable MCP Server

by jorekai

smithery badge

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

Related MCP server: DevDb MCP Server

Requirements

  • Node.js 18 or higher

  • API credentials for the DB Timetable API (client ID and client secret)

installation

  1. Clone repository:

    git clone <repository-url> cd db-mcp
  2. Install dependencies:

    npm install
  3. Compile TypeScript code:

    npm run build

configuration

Create an .env file in the root directory of the project with the following environment variables:

DB_TIMETABLE_CLIENT_ID=deine-client-id DB_TIMETABLE_CLIENT_SECRET=dein-client-secret TRANSPORT_TYPE=stdio PORT=8080 SSE_ENDPOINT=/sse LOG_LEVEL=info

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 or sse , 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):

npm start

In SSE mode (for web clients):

TRANSPORT_TYPE=sse npm start

Test with Inspect mode

The server can be tested with the FastMCP Inspector:

npx fastmcp inspect path/to/index.js

MCP tools

The server provides the following tools:

  1. getCurrentTimetable : Retrieves current timetable data for a station

    • Parameter: evaNo - EVA number of the station (e.g. 8000105 for Frankfurt Hbf)

  2. getRecentChanges : Retrieves recent changes for a station

    • Parameter: evaNo - EVA number of the station (e.g. 8000105 for Frankfurt Hbf)

  3. 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.)

  4. findStations : Searches for stations using a search pattern

    • Parameter: pattern - search pattern (e.g. "Frankfurt" or "BLS")

MCP resources

The server provides the following resources:

  1. Current timetable data : db-api:timetable/current/{evaNo}

  2. Current timetable changes : db-api:timetable/changes/{evaNo}

  3. Planned timetable data : db-api:timetable/planned/{evaNo}/{date}/{hour}

  4. Station search : db-api:station/{pattern}

Development

Project structure

db-mcp/ ├── src/ │ ├── api/ # API-Client und Typen │ ├── tools/ # MCP-Tools │ ├── resources/ # MCP-Ressourcen │ ├── utils/ # Hilfsfunktionen │ ├── config.ts # Konfiguration │ └── index.ts # Haupteinstiegspunkt ├── dist/ # Kompilierte Dateien ├── .env # Umgebungsvariablen ├── package.json ├── tsconfig.json └── README.md

NPM scripts

  • npm run build : Compiles the TypeScript code

  • npm start : Starts the server

  • npm run dev : Starts the server in development mode with automatic reloading

  • npm test : Runs tests

Extensibility

Potential extensions

  1. 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

  2. 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

-
security - not tested
A
license - permissive license
-
quality - not tested

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/jorekai/db-timetable-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server