Imagine you could ask questions about train connections, departure times, and station information using natural language. Like this one:
I'd like to go from Gross Gerau to the alt bischofsheim restaurant.
tomorrow evening.MCP servers are addons to LLMs that enable the users to ask questions on YOUR data (in DBs, APIs, fielsystems,…) with natural language. This MCP Server enables LLMs to use data on trains, stations and connections provided by RMV, Germany.
To be honest the above description does not tell the full story. The MCP inventor Anthropic has a full blown explanation on MCPs.
This MCP server enables you to query stations, connections and departures from an LLM like Claude. It is built using the FastMCP framework.
This example is build upon python3.13 and UV 0.8.13.
It usese Claude Desktop as LLM client and chat interface.
To access station and connection data, you need to acquire an API key. It can be requested free of charge from RMV at the RMV Open Data Portal.
Copy DOTEnv to .env and add the API key there.
FastMCP provides a development mode that allows us to run and test our MCP server locally.
Start the server in dev mode:
uv run fastmcp dev main.pyThis will start the MCP server and open the MCP Inspector in your browser. Allowing you to inspect and debug your MCP server.
-
Connect to your MCP sever (left column)
-
Select
Toolsfrom the top menu. -
Click
List Toolsbelow. It should revealsearch_stationsandget_connections. Select one of them. -
The right hand side enables you to run the tool and inspect the results.
How cool is that!
graph TD
subgraph RMV_MCP_Server
A[rmv_stdio.py] --> B[RMVService]
B[RMVService] --> C[RMV API]
end
subgraph Tests
D[test_rmv_stdio.py] --> A[rmv_stdio.py]
D[test_rmv_stdio.py] --> E[fastmcp.client.Client]
end
subgraph External_Services
C[RMV API]
end
subgraph FastMCP_Framework
A[rmv_stdio.py] --> F[FastMCP]
E[fastmcp.client.Client] --> F[FastMCP]
end
I’ll show you how to run the RMV MCP server locally using UV and how to connect it to Claude Desktop. To make the service known to Claude Desktop you need to add its configuration to the Claude Desktop config file (see below).
Once you have it, you can enter it in Claude’s config file.
Don’t forget to update the file with your API key!
{
"mcpServers": {
"my_rmv-mcp-server": {
"command": "/Users/volker/.local/bin/uv",
"args": [
"--directory",
"/Users/volker/Dev/mcp/fast_mcp/rmv-mcp-server",
"run",
"rmv_stdio.py"
],
"env": {
"RMV_API_KEY": "<YOUR_API_KEY>"
}
}
}
}After adding this restart Claude Desktop is needed.
You can tweak its settings and configuration in the
Settings→Connectorsmenu.
-
Diagram generate with Swark Mermaid Extension