Skip to main content
Glama
zzuisa

DB Timetable MCP Server

by zzuisa

DB Timetable MCP Server

A standardized Model Context Protocol (MCP) server that provides seamless access to Deutsche Bahn's timetable data through MCP tools and resources. This server enables AI assistants and applications to query real-time train schedules, station information, and timetable changes for German railway stations.

Overview

This MCP server bridges the gap between AI applications and Deutsche Bahn's timetable API, offering:

  • Real-time timetable access - Get current train schedules and platform information

  • Change tracking - Monitor real-time updates, delays, and platform changes

  • Station search - Find stations by name or EVA number

  • Planned schedules - Access future timetable data for trip planning

Built with the standard @modelcontextprotocol/sdk, this server supports both stdio and SSE (Server-Sent Events) transport modes, making it compatible with various MCP clients including Cursor IDE.

Related MCP server: Deutsche Bahn MCP Server

Data Source & License

This project provides timetable data from Deutsche Bahn, 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. All API requests are subject to the license terms.

Key Features

  • Real-time Timetables - Get current train schedules with platform assignments, delays, and real-time updates

  • Change Tracking - Monitor live timetable changes including delays, cancellations, and platform modifications

  • Planned Schedules - Access future timetable data for specific dates and times

  • Station Discovery - Search and find German railway stations by name, code, or pattern matching

  • Dual Transport Modes - Support for both stdio (CLI) and SSE (HTTP) transport protocols

  • Cursor IDE Integration - Ready-to-use configuration for seamless Cursor IDE integration

Prerequisites

  • Node.js 18 or higher

  • API credentials for the DB Timetable API (Client ID and Client Secret)

Installation

  1. Clone the repository:

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

    npm install
  3. Compile TypeScript code:

    npm run build

Configuration

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

DB_TIMETABLE_CLIENT_ID=your-client-id
DB_TIMETABLE_CLIENT_SECRET=your-client-secret
TRANSPORT_TYPE=sse
PORT=3000
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: 3000)

  • 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 tests and debugging):

npm start

In SSE mode (for web clients):

TRANSPORT_TYPE=sse npm start

Or use the dev script:

npm run dev:sse

MCP Tools

The server provides the following tools:

  1. getCurrentTimetable: Retrieves current timetable data for a station

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

  2. getRecentChanges: Retrieves recent changes for a station

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

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

  4. findStations: Searches for stations by pattern

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

MCP Resources

The server provides the following resources:

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

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

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

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

Development

Project Structure

db-timetable-mcp/
├── src/
│   ├── api/             # API client and types
│   ├── tools/           # MCP tools
│   ├── resources/       # MCP resources
│   ├── utils/           # Utility functions
│   ├── config.ts        # Configuration
│   └── index.ts         # Main entry point
├── dist/                # Compiled files
├── .env                 # Environment variables
├── package.json
├── tsconfig.json
└── README.md

NPM Scripts

  • npm run build: Compiles TypeScript code

  • npm start: Starts the server

  • npm run dev: Starts the server in development mode

  • npm run dev:sse: Starts the server in SSE mode (development)

  • npm test: Runs tests

  • npm run check-env: Checks environment variable configuration

Cursor Integration

This server can be integrated with Cursor IDE. See CURSOR_CONFIG.md for detailed configuration instructions.

Quick Setup

  1. Start the server in SSE mode:

    npm run dev:sse
  2. Add to Cursor's MCP configuration:

    {
      "mcpServers": {
        "db-timetable": {
          "url": "http://localhost:3000/sse",
          "transport": "sse"
        }
      }
    }

REST API Endpoints

The server also provides REST API endpoints for testing:

  • GET /health - Health check

  • GET /tools - List all tools

  • GET /resources - List all resources

  • POST /tools/call - Call a tool (REST API)

  • GET /sse - SSE connection endpoint

  • POST /sse - Send MCP messages via SSE (JSON-RPC 2.0)

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 operational 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

Available Tools

4 tools
findStationsA

Durchsucht das Verzeichnis der Bahnhofsstationen anhand eines gegebenen Suchmusters. Dies kann der Name der Station oder die EVA-Nummer sein. Das Tool liefert eine Liste von Stationen, die dem Suchmuster entsprechen.

ParametersJSON Schema
NameRequiredDescriptionDefault
patternYesSuchmuster für Stationen (z.B. Frankfurt oder 8000105)

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so the description must disclose behavioral traits. It only states it returns a list of matching stations without detailing behavior like case sensitivity, matching logic, or limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two clear sentences with no superfluous information. Efficiently conveys the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity, the description covers basic purpose and parameter. However, it omits return format and error handling, leaving some gaps for a complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single parameter, and the description adds little beyond what the schema already provides (both mention pattern can be name or EVA number). Minimal added value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches the station directory by pattern (name or EVA number). This purpose is distinct from sibling tools which are timetable-related.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description specifies the input can be station name or EVA number but provides no guidance on when to use this tool versus alternatives. Usage context is implied by the tool's purpose, but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

getCurrentTimetableB

Ruft die aktuellen Fahrplandaten einer bestimmten Bahnhofsstation ab. Dies beinhaltet Informationen zu Ankunfts- und Abfahrtszeiten, Gleisbelegungen, Verspätungen und weitere Echtzeitinformationen für den aktuellen Betriebstag.

ParametersJSON Schema
NameRequiredDescriptionDefault
evaNoYesEVA-Nummer der Station (z.B. 8000105 für Frankfurt Hbf)

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It discloses that results include real-time info like delays, but omits behavioral traits such as data freshness, rate limits, or error handling (e.g., missing station). Minimal added context beyond tool name.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with action and resource, no unnecessary words. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and no output schema, the description covers the basic functionality and output contents. However, it lacks usage guidance and behavioral details that would help an agent decide when to invoke it, especially given sibling tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a well-described parameter (evaNo). The description does not add meaning beyond the schema's example and format. Baseline 3 is appropriate as the schema handles the documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'Ruft ab' (retrieves) and the resource 'aktuellen Fahrplandaten einer bestimmten Bahnhofsstation' (current timetable data of a specific station). It differentiates from siblings by implying real-time vs planned timetable, but does not explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. The description does not mention when not to use it or provide any context for selection among siblings like getPlannedTimetable or getRecentChanges.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

getPlannedTimetableA

Holt die geplanten Fahrplandaten für eine angegebene Bahnhofsstation zu einem bestimmten Datum und einer bestimmten Stunde ein. Diese Funktion ist nützlich, um Fahrpläne im Voraus zu planen und Informationen über zukünftige Zugverbindungen zu erhalten.

ParametersJSON Schema
NameRequiredDescriptionDefault
dateYesDatum im Format YYMMDD (z.B. 230401 für 01.04.2023)
hourYesStunde im Format HH (z.B. 14 für 14 Uhr)
evaNoYesEVA-Nummer der Station (z.B. 8000105 für Frankfurt Hbf)

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It only states the purpose without disclosing behavioral traits such as side effects, authentication needs, error conditions, or performance characteristics. The agent cannot assess safety or cost of invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences in German, front-loaded with the primary purpose, and includes a secondary sentence on usage context. Every sentence contributes value without redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (3 required parameters, no output schema, no annotations), the description provides the core information: what data is fetched and for what purpose. Minor gaps include lack of output format hints and comparison with siblings, but it is largely sufficient for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear descriptions and examples for each parameter (date, hour, evaNo). The description adds no extra meaning beyond what the schema already provides, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Holt die geplanten Fahrplandaten') and the resource (planned timetable data for a station, date, and hour). It differentiates from siblings by highlighting 'planned' nature, contrasting with 'current' or 'recent changes'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states it is useful for planning ahead and getting future train info, providing clear usage context. However, it does not explicitly exclude use when real-time data is needed or name alternatives like 'getCurrentTimetable'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

getRecentChangesA

Ermittelt die neuesten Fahrplanänderungen für eine spezifische Bahnhofsstation. Dazu gehören Verspätungen, Gleisänderungen, Ausfälle und andere kurzfristige Anpassungen im Betriebsablauf, die in Echtzeit aktualisiert werden.

ParametersJSON Schema
NameRequiredDescriptionDefault
evaNoYesEVA-Nummer der Station (z.B. 8000105 für Frankfurt Hbf)

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Since no annotations are provided, the description carries the full burden. It mentions that the tool retrieves real-time updates and lists types of changes, but does not disclose permissions, rate limits, or side effects. The read-only nature is implied but not explicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long, front-loaded with the main action and resource. Every sentence adds value, and there is no unnecessary text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple tool with one parameter and no output schema or annotations, the description adequately covers the tool's purpose and data type. However, it does not describe the return format or pagination, which could be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the description adds no extra information about the evaNo parameter beyond what the schema already includes. The schema already provides an example, so baseline score applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'ermittelt' (retrieves) and the resource 'neuesten Fahrplanänderungen' (latest schedule changes) for a specific station. It also lists examples like delays, platform changes, and cancellations. This distinguishes it from siblings like getCurrentTimetable and getPlannedTimetable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when real-time changes are needed, but does not explicitly state when to use it versus alternatives. No 'when not to use' or comparison to siblings is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 4 tool updatesv1.0.0
    • First observedfindStations
    • First observedgetCurrentTimetable
    • First observedgetPlannedTimetable
    • First observedgetRecentChanges

TDQS

A3.8/5.0
Disambiguation5/5

Each tool targets a distinct function: station search, real-time timetable, planned timetable, and recent changes. There is no overlap in purpose, making selection unambiguous.

Naming Consistency5/5

All tool names follow a consistent verb_noun camelCase pattern (findStations, getCurrentTimetable, etc.), which is uniform and predictable.

Tool Count5/5

Four tools cover the core functionalities of a timetable server (search, current, planned, changes) without redundancy or shortage.

Completeness4/5

The set covers essential station and timetable operations. Minor gaps like a generic station list or multi-station queries are absent but not critical for the stated purpose.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

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/zzuisa/db-support'

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