DB Timetable MCP Server
Provides access to Deutsche Bahn's timetable data through MCP, enabling real-time train schedules, station search, and change tracking for German railway stations.
README
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.
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
-
Clone the repository:
git clone <repository-url> cd db-timetable-mcp -
Install dependencies:
npm install -
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 (stdioorsse, 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:
-
getCurrentTimetable: Retrieves current timetable data for a station
- Parameters:
evaNo- EVA number of the station (e.g., 8000105 for Frankfurt Hbf)
- Parameters:
-
getRecentChanges: Retrieves recent changes for a station
- Parameters:
evaNo- EVA number of the station (e.g., 8000105 for Frankfurt Hbf)
- Parameters:
-
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)
- Parameters:
-
findStations: Searches for stations by pattern
- Parameters:
pattern- Search pattern (e.g., "Frankfurt" or "BLS")
- Parameters:
MCP Resources
The server provides the following resources:
- Current Timetable:
db-api:timetable/current/{evaNo} - Recent Changes:
db-api:timetable/changes/{evaNo} - Planned Timetable:
db-api:timetable/planned/{evaNo}/{date}/{hour} - 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 codenpm start: Starts the servernpm run dev: Starts the server in development modenpm run dev:sse: Starts the server in SSE mode (development)npm test: Runs testsnpm 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
-
Start the server in SSE mode:
npm run dev:sse -
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 checkGET /tools- List all toolsGET /resources- List all resourcesPOST /tools/call- Call a tool (REST API)GET /sse- SSE connection endpointPOST /sse- Send MCP messages via SSE (JSON-RPC 2.0)
Extensibility
Potential extensions:
-
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
-
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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。