Get the FREE Ultimate OpenClaw Setup Guide →

db

A comprehensive Model Context Protocol (MCP) server that provides unified access to Deutsche Bahn (DB) and German mobility APIs.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio paulvonberg-db-mcp-server python main.py \
  --env DB_API_KEY="your_deutsche_bahn_api_key" \
  --env DB_API_HOST="https://api.deutschebahn.com" \
  --env ENVIRONMENT="production" \
  --env DB_API_SECRET="your_deutsche_bahn_api_secret"

How to use

This MCP server provides unified access to Deutsche Bahn and German mobility APIs via the Model Context Protocol. Built with Python and FastAPI, it exposes a range of MCP tools and interactive prompts that let you search stations, retrieve timetables and disruptions, query parking information, and check accessibility services. Once running, you can connect to it from Claude Desktop or Claude.ai Web using the MCP URL and the server name defined in the config (deutschebahn). The included tools cover station data, timetables and disruptions, parking information, and accessibility services, while the interactive prompts offer streamlined workflows for common tasks like nearby stations, real-time delays, and station facilities. To verify connectivity, you can ping the MCP endpoint or request a health check, and then start issuing tool calls or natural language prompts to fetch up-to-date German rail data.

How to install

Prerequisites:

  • Python 3.11+ installed
  • Deutsche Bahn API credentials
  • Optional: Google Cloud account for deployment
  1. Clone the repository and set up a virtual environment
git clone <repository-url>
cd deutsche-bahn-mcp-server
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
  1. Create and configure environment variables
cp .env.example .env

Edit the .env file to include your DB API credentials and any required configuration (API key/secret, host, etc.).

  1. Run the server locally for development
python main.py
# Server available at http://localhost:8080
  1. Optional: Deploy to the cloud following your preferred workflow (Cloud Run, VM, or container) using the same environment variables and the same entry point.

  2. Validate health and MCP endpoints

curl http://localhost:8080/health
curl http://localhost:8080/mcp/ping

Additional notes

Tips and common issues:

  • Ensure your Deutsche Bahn API credentials are valid; incorrect credentials will block API access.
  • If you modify environment variables, restart the server to apply changes.
  • The MCP rate limiter is in place to prevent abuse; if you hit limits, wait briefly before retrying.
  • When deploying, consider containerizing the app and setting a robust secret management strategy for API keys.
  • For Claude integrations, verify that the server URL is reachable from the client and that the MCP server name matches the one configured (deutschebahn).
  • If you encounter connectivity issues, test endpoints with curl (health, ping) to verify reachability before debugging MCP client setup.

Related MCP Servers

Sponsor this space

Reach thousands of developers