Skip to main content
Glama

db-mcp-server

An MCP server that exposes the Deutsche Bahn public transport API to any MCP-compatible client (Claude Desktop, Cursor, Cline, Continue, etc.). Six tools cover station search, departures, journey planning, trip details, station info, and nearby stations.

Built on the v6.db.transport.rest API, which is free and requires no authentication. ~400 lines of Python.

Tools

Tool

Purpose

search_station

Find German train stations by name. Returns IDs needed by the other tools.

get_departures

Upcoming departures from a station with line, direction, platform, delay.

plan_journey

Connection between two stations with duration, transfers, platforms.

get_trip_details

Full stop-by-stop schedule for one specific train.

get_station_info

Address, coordinates, and facilities (lifts, accessible toilets, etc.) for a station.

nearby_stations

Stations near a lat/lon coordinate.

Related MCP server: BVG MCP Server

Transports

# stdio (default — what every MCP client expects)
uv run db-mcp

# HTTP / SSE for browser-resident clients and curl debugging
uv run db-mcp --transport sse --port 8765
uv run db-mcp --transport streamable-http --port 8765

Install via uvx (no clone needed)

If your client supports it, you can run the server straight from this repo with no install step:

{
  "mcpServers": {
    "deutsche-bahn": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Amor216/db-mcp-server", "db-mcp"]
    }
  }
}

Claude Desktop setup

Put the snippet above into your claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Restart Claude Desktop. The tools appear under the hammer icon. Try asking:

When is the next ICE from Berlin Hbf to Munich?

Local development

git clone https://github.com/Amor216/db-mcp-server
cd db-mcp-server
uv sync
uv run pytest -q

To run the server against stdin/stdout directly:

uv run db-mcp

That's the same thing your MCP client will spawn under the hood.

Layout

src/db_mcp/
  server.py        FastMCP server, 5 tools
  client.py        thin httpx wrapper around transport.rest
  formatters.py    API JSON -> compact text the LLM can read

tests/
  test_client.py     httpx mocked with respx
  test_formatters.py snapshot-style assertions
  test_server.py     tool-call smoke tests

Why the formatter layer

The transport.rest API returns deeply nested JSON. Handing that straight to an LLM wastes context and confuses the model. The formatters turn each response into compact text, one departure or one journey per line, so the model reads it the way a human reads a station board.

Rate limits

The upstream API allows 100 requests/minute (200 burst). The server makes one request per tool call, so a normal conversation stays well under the limit. There's no caching layer right now since the data (delays, platforms) is real-time and would lose value if stale.

License

MIT.

Available Tools

6 tools
get_departuresA

Get upcoming departures from a German train station.

Returns one line per departure: time, train line, direction, platform, delay.

ParametersJSON Schema
NameRequiredDescriptionDefault
station_idYesStation ID from search_station, e.g. '8011160'
minutes_aheadNoTime window in minutes (10-180)
limitNoMax departures (1-20)

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description carries full burden. It states the output format but does not mention data source, refresh rate, rate limits, or edge cases (e.g., no departures found). Behavior is adequately described for a simple read operation but lacks depth.

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, no redundancy. Purpose and return format are front-loaded. Every word contributes meaning.

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 tool's simplicity and the presence of an output schema, the description covers the essential information. It lacks some context about error handling or inclusion criteria (e.g., only departures, no arrivals), but is largely complete for its intended use.

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 parameter descriptions. The main description adds output context but no additional parameter semantics beyond what the schema already provides. Baseline 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 tool retrieves upcoming departures from a German train station and lists the output fields (time, train line, direction, platform, delay). This distinguishes it from siblings like search_station or get_station_info.

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 purpose is clear, so usage context is well implied. However, explicit when-to-use or when-not-to-use guidance relative to siblings (e.g., 'Use this over get_trip_details when you need only departures') is missing, preventing a top score.

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

get_station_infoA

Get full details for a German train station: address, coordinates, facilities (lifts, accessible toilets, parking, taxis, dining, shops, etc.).

ParametersJSON Schema
NameRequiredDescriptionDefault
station_idYesStation ID from search_station, e.g. '8011160'

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description covers expected outputs (address, coordinates, facilities). It does not mention side effects, auth, or errors, but for a read-only information retrieval tool, this is sufficient.

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

Conciseness4/5

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

The description is a single sentence that is front-loaded with the main purpose. It is concise, though slightly longer due to the list of facilities, but still efficient.

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 presence of an output schema, the description does not need to detail return values. It covers key aspects of the tool (address, coordinates, facilities) and is adequate for its single-parameter simplicity.

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% and the schema already describes the station_id as coming from search_station. The description adds no further parameter details beyond confirming the station is German, so baseline of 3 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 'Get full details for a German train station' and lists specific details such as address, coordinates, facilities. This distinguishes it from sibling tools like get_departures or search_station.

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 implies usage when station details are needed after obtaining a station ID. It does not explicitly state when not to use or provide alternatives, but context from sibling tools makes it reasonably clear.

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

get_trip_detailsB

Get the full stop-by-stop schedule for a specific train trip, including real-time delays.

ParametersJSON Schema
NameRequiredDescriptionDefault
trip_idYesTrip ID from a journey leg or departure

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.2/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 full burden. It mentions real-time delays but does not disclose side effects, permissions, or behavior on invalid trip_id.

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

Conciseness4/5

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

One sentence, 12 words, no wasted text. Front-loaded with key info, though could briefly elaborate on usage.

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?

Has output schema, but missing usage guidance and behavioral transparency. Adequate for a simple single-parameter tool, but could be more complete.

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 already provides 100% coverage with description 'Trip ID from a journey leg or departure'. The tool description adds no extra parameter context, so baseline 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 verb 'Get' and the resource 'full stop-by-stop schedule for a specific train trip', distinguishing it from sibling tools like get_departures or plan_journey.

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. It implies having a trip_id but does not mention prerequisites (e.g., from get_departures) or when not to use it.

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

nearby_stationsC

Find train stations near a geographic coordinate.

ParametersJSON Schema
NameRequiredDescriptionDefault
latitudeYesLatitude in WGS84
longitudeYesLongitude in WGS84
radius_mNoSearch radius in meters (100-10000)
limitNoMax results (1-12)

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/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 no behavioral traits such as result ordering, pagination, empty result behavior, or data freshness.

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

Conciseness4/5

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

Single sentence, very concise. However, it lacks any contextual or behavioral expansion that might be expected for a spatial search tool with multiple parameters.

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?

With output schema present, description need not detail return values. However, it provides no usage context or hints about tool output, and does not differentiate from similar 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 description coverage is 100%, so baseline is 3. Description adds no additional information beyond what the schema already provides for the four parameters.

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?

Description clearly states verb (find) and resource (train stations) with spatial criterion (near a geographic coordinate). Does not explicitly differentiate from sibling search_station, but the coordinate-based approach is implicit.

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 guidance on when to use this tool versus alternatives like search_station or get_station_info. No exclusions or prerequisites mentioned.

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

plan_journeyA

Plan a train journey between two German stations.

Returns one block per option: departure / arrival times, platforms, duration, transfers, lines used.

ParametersJSON Schema
NameRequiredDescriptionDefault
from_station_idYesOrigin station ID from search_station
to_station_idYesDestination station ID from search_station
departureNoISO-8601 departure time, e.g. '2026-06-06T14:00:00+02:00'. Omit for now.
resultsNoNumber of options (1-5)

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description must carry the full burden. It explains the output format, but lacks details on side effects, rate limits, or required permissions.

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, starts with the core purpose, and contains no filler. Every sentence adds value.

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 presence of an output schema, the description sufficiently summarizes what is returned. It mentions the German station context, but could include more on error handling or usage constraints.

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

Parameters4/5

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

Schema coverage is 100%. The description adds value by noting that from_station_id and to_station_id come from search_station and that departure is optional, enhancing understanding beyond the schema.

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 plans a train journey between two German stations, with specific verb and resource. It lists the returned fields, distinguishing it from siblings like get_departures or get_trip_details.

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 mentions using station IDs from search_station and that departure is optional, but does not explicitly guide when to use this tool versus alternatives or when not to use it.

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

search_stationA

Find German train stations by name. Returns one line per match with the station ID and full name.

The station ID is what you pass to get_departures or plan_journey.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesStation name or fragment, e.g. 'Berlin Hbf'
limitNoMax results (1-10)

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

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

No annotations are provided, so description carries the burden. It implies a read-only search but does not explicitly state behavioral traits like read-only nature, rate limits, or error handling. Adequate for a simple search but could be more transparent.

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 concise sentences covering purpose and usage. No redundancy, all information is relevant and front-loaded.

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

Completeness5/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 the essential: what the tool does, output format, and how the output is used. No missing information for effective agent selection and invocation.

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%, so baseline is 3. Description adds that results contain station ID and full name, which is already implied by schema. Does not enhance parameter meaning beyond schema.

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?

Clearly states the tool finds German train stations by name and returns station ID and full name. Distinguishes from siblings by focusing on search rather than departures, info, or journey planning.

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?

Explicitly explains that the station ID is used for get_departures or plan_journey, providing context for when to use this tool. Does not state negative cases or alternatives, but is sufficient.

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

TDQS

A3.8/5.0
Disambiguation5/5

All tools have distinct purposes: station search, station details, departures, journey planning, trip details, and nearby stations. No overlapping responsibilities.

Naming Consistency5/5

All names follow snake_case with a consistent verb_noun pattern (e.g., get_departures, search_station). 'nearby_stations' is a minor deviation but still clear and consistent in style.

Tool Count5/5

Six tools is appropriate for a German railway information server, covering essential operations without unnecessary clutter.

Completeness4/5

Covers core CRUD-like operations for stations and journeys, but missing some advanced features like real-time delay feeds or station board filtering. Still functional for most use cases.

Maintenance

ActivityInactive
ResponsivenessSyncing

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

  • A
    license
    A
    quality
    C
    maintenance
    An MCP server that enables AI assistants to interact with the Netherlands Railways (NS) API for route planning, pricing, and real-time departure information. It provides tools for searching stations, planning trips with connections, and viewing real-time departure boards.
    3
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server for interacting with the Berlin Public Transport (BVG) API to search for locations and plan journeys. It provides real-time access to departures, arrivals, trip details, and vehicle tracking within Berlin's transit network.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    A Claude skill + MCP server that tells you how Deutsche Bahn delays will affect your trip — not just whether your train is late.
    MIT

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/Amor216/db-mcp-server'

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