Deutsche Bahn Timetable MCP server

Connects to Deutsche Bahn timetable API for retrieving real-time railway information, planned schedules, recent changes, and station searches across Germany's rail network.
Back to servers
Provider
Nils Jorek
Release date
Mar 24, 2025
Language
TypeScript
Stats
1 star

The DB Timetable MCP Server provides access to Deutsche Bahn's timetable data, station information, and train changes through the Model Context Protocol (MCP). It acts as an interface to the official DB Timetable API, making it easier to retrieve and work with German railway schedule information.

Requirements

  • Node.js 18 or higher
  • API credentials for the DB Timetable API (client ID and client secret)

Installation

Clone the repository and install dependencies:

git clone <repository-url>
cd db-mcp
npm install

Compile the TypeScript code:

npm run build

Configuration

Create a .env file in the root directory with the following environment variables:

DB_TIMETABLE_CLIENT_ID=your-client-id
DB_TIMETABLE_CLIENT_SECRET=your-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)

Usage

Starting the Server

In stdio mode (for CLI testing and debugging):

npm start

In SSE mode (for web clients):

TRANSPORT_TYPE=sse npm start

Testing 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:

  • getCurrentTimetable: Retrieves current timetable data for a station

    • Parameter: evaNo - EVA number of the station (e.g., 8000105 for Frankfurt Hbf)
  • getRecentChanges: Retrieves recent changes for a station

    • Parameter: evaNo - EVA number of the station (e.g., 8000105 for Frankfurt Hbf)
  • getPlannedTimetable: Retrieves planned timetable data for a station

    • Parameters:
      • evaNo - EVA number of the station (e.g., 8000105 for Frankfurt Hbf)
      • date - Date in YYMMDD format (e.g., 230401 for April 1, 2023)
      • hour - Hour in HH format (e.g., 14 for 2 PM)
  • findStations: Searches for stations based on a search pattern

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

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}

Attribution Notice

This project provides Deutsche Bahn timetable data which is publicly available under the Creative Commons Attribution 4.0 International License (CC BY 4.0). For more information about the API and license terms, visit developers.deutschebahn.com. API requests are subject to the terms of the license.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later