mcp-server-public-transport
mcp-server-public-transport
一个提供欧洲实时公共交通数据的 MCP 服务器。
关于
mcp-server-public-transport 是一个兼容 Model Context Protocol (MCP) 的本地服务器,提供对欧洲各地公共交通数据的访问。 目前,它集成了英国、瑞士、挪威、比利时以及柏林/勃兰登堡地区的 API,允许您检索火车连接、实时出发信息和公交车位置。
Related MCP server: BVG MCP Server
功能实现状态
支持的国家/地区
国家/地区 | API 基础 URL | 状态 |
英国 | ✅ | |
瑞士 | ✅ | |
比利时 | ✅ | |
挪威 | ✅ | |
柏林/勃兰登堡 | ✅ |
各国功能
功能 | API 路径 | 状态 |
英国 | ||
实时出发 |
| ✅ |
瑞士 | ||
搜索连接 |
| ✅ |
车站查询 |
| ✅ |
出发看板 |
| ✅ |
附近车站 |
| ✅ |
比利时 | ||
实时出发 |
| ✅ |
车站查询 |
| ✅ |
附近车站 |
| ✅ |
挪威 | ||
地点搜索 |
| ✅ |
实时出发 |
| ✅ |
行程规划 |
| ✅ |
最近站点 |
| ✅ |
柏林/勃兰登堡 | ||
地点搜索 |
| ✅ |
实时出发 |
| ✅ |
实时到达 |
| ✅ |
行程规划 |
| ✅ |
附近车站 |
| ✅ |
设置
环境变量
设置以下环境变量:
UK_TRANSPORT_APP_ID=your_uk_app_id
UK_TRANSPORT_API_KEY=your_uk_api_key在 Claude Desktop 中使用
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"mcp-server-public-transport": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/mcp-server-public-transport",
"run",
"server.py"
],
"env": {
"UK_TRANSPORT_APP_ID": "your-uk-app-id",
"UK_TRANSPORT_API_KEY": "your-uk-api-key"
}
}
}
}
将 /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-server-public-transport 替换为您克隆存储库的实际路径。
注意:您可能需要在命令字段中填写
uv可执行文件的完整路径。您可以通过在 MacOS/Linux 上运行which uv或在 Windows 上运行where uv来获取该路径。
开发
设置开发环境
克隆存储库
git clone https://github.com/mirodn/mcp-server-public-transport.git cd mcp-server-public-transport安装依赖
uv sync设置环境变量
cp .env.example .env运行服务器
uv run server.py
运行测试
该项目使用 pytest 进行测试,可使用以下命令:
# Run all tests
make test代码质量
# Run linting
make lint
# Run code formatting
make format持续集成
该项目包含一个 GitHub Actions 工作流 (.github/workflows/test.yml),它会自动:
在 Python 3.10、3.11 和 3.12 上运行测试
使用
ruff执行代码检查在每次推送到
main分支或提交拉取请求时运行
CI 流水线确保在合并任何更改之前,代码在支持的 Python 版本中保持高质量和兼容性。
贡献
欢迎贡献!请随时提交拉取请求 (Pull Request)。
当 pyproject.toml 中的 project.version 更新时,该包会自动部署到 PyPI。
版本控制请遵循 semver 规范。
许可证
Available Tools
13 toolsbe_get_departuresB
Get live departure board for a Belgian train station.
| Name | Required | Description | Default |
|---|---|---|---|
| station | Yes | ||
| limit | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
be_get_vehicleA
Get details about a specific Belgian train vehicle by its ID.
| Name | Required | Description | Default |
|---|---|---|---|
| vehicle_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
be_search_connectionsB
Search train connections in Belgium between two stations. Powered by iRail API for real-time routes and schedules.
| Name | Required | Description | Default |
|---|---|---|---|
| origin | Yes | ||
| destination | Yes | ||
| results | No | ||
| date | No | ||
| time | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
be_search_stationsB
Search for Belgian train stations by name.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
ch_get_departuresC
Get departure board for a Swiss train station with real-time information.
| Name | Required | Description | Default |
|---|---|---|---|
| station | Yes | ||
| limit | No | ||
| datetime | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
ch_nearby_stationsC
Find nearby Swiss train stations based on coordinates (latitude, longitude).
| Name | Required | Description | Default |
|---|---|---|---|
| latitude | Yes | ||
| longitude | Yes | ||
| distance | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
ch_search_connectionsA
Search for train connections in Switzerland between two stations. Uses transport.opendata.ch API to provide real-time connection data including departure times, duration, platforms, and transfers.
| Name | Required | Description | Default |
|---|---|---|---|
| origin | Yes | ||
| destination | Yes | ||
| limit | No | ||
| date | No | ||
| time | No | ||
| is_arrival_time | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
ch_search_stationsC
Search for Swiss train stations by name or location.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| type | No | station |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
no_nearest_stopsB
Find nearest StopPlaces for a coordinate (lat, lon) within a radius in meters.
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | ||
| lon | Yes | ||
| radius | No | ||
| limit | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
no_search_placesC
Autocomplete search across stops/addresses/POIs in Norway via Entur Geocoder.
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| lang | No | en | |
| size | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
no_stop_departuresB
Upcoming departures for a StopPlace ID (e.g., 'NSR:StopPlace:58368').
| Name | Required | Description | Default |
|---|---|---|---|
| stop_place_id | Yes | ||
| limit | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
no_tripC
Door-to-door trip planning between two StopPlaces (NSR IDs).
| Name | Required | Description | Default |
|---|---|---|---|
| from_id | Yes | ||
| to_id | Yes | ||
| date_time | No | ||
| results | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
uk_live_departuresA
Get live departure information for a UK train station using its CRS code (e.g., 'PAD' for London Paddington, 'MAN' for Manchester Piccadilly). Uses the TransportAPI station timetables endpoint with live data.
| Name | Required | Description | Default |
|---|---|---|---|
| station_code | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v1.0.0- Added
no_nearest_stops - Added
no_search_places - Added
no_stop_departures - Added
no_trip - Added
uk_live_departures
8 tool updates
- First observed
be_get_departures - First observed
be_get_vehicle - First observed
be_search_connections - First observed
be_search_stations - First observed
ch_get_departures - First observed
ch_nearby_stations - First observed
ch_search_connections - First observed
ch_search_stations
TDQS
Scored across 13 tools
Tools are clearly distinguished by country prefix (be_, ch_, no_, uk_) and specific functions like departures, connections, stations, and trips, with minimal overlap. However, some tools like be_get_departures and uk_live_departures serve similar purposes across different regions, which could cause minor confusion if an agent doesn't prioritize the country prefix.
Naming follows a consistent pattern of country prefix + verb_noun (e.g., be_get_departures, ch_search_connections), with all tools using snake_case. Minor deviations include no_nearest_stops (using 'nearest' instead of 'search' or 'get') and no_trip (using a noun instead of verb_noun), but overall the convention is predictable and readable.
With 13 tools, the count is well-scoped for a public transport server covering multiple countries (Belgium, Switzerland, Norway, UK). Each tool earns its place by providing distinct functionality per region, such as departures, connections, station searches, and trip planning, without being overly bloated or sparse.
The toolset offers comprehensive coverage for public transport queries across four countries, including core operations like searching stations, getting departures, and planning connections. Minor gaps exist, such as no tool for vehicle details outside Belgium or real-time alerts, but agents can work around these with the available tools for most common use cases.
Maintenance
Related MCP Connectors
An MCP server for Georgian public data, read from the organizations that publish it.
MCP server with quote and live cryptocurrency price tools, local and cloud-deployed transports.
MCP server for Travel & Transportation
MCP server for China Railway 12306 ticket availability: schedules and seats by Chinese station name.
21
Related MCP Servers
- FlicenseDqualityDmaintenanceProvides access to Berlin's public transport data through the VBB API, enabling users to search stops, get departures, and plan journeys across Berlin-Brandenburg.36-
- AlicenseNot gradedqualityDmaintenanceAn 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
- AlicenseAqualityDmaintenanceA zero-authentication MCP server for Swiss public transport, enabling users to query train connections, disruptions, station facilities, and plan journeys using natural language.121MIT
- AlicenseAqualityDmaintenanceMCP server for Swiss public transport — connections, stationboards, real-time delays, and direct booking links for SBB.426 PyPI1MIT