An MCP-compatible server for querying public transport data in Europe (UK, CH, BE, NO).
Project description
mcp-server-public-transport
An MCP Server providing real-time public transport data across Europe.
About
mcp-server-public-transport is a Model Context Protocol (MCP)-compatible local server that provides access to public transport data across Europe. Currently, it integrates APIs from UK, Switzerland, Norway and Belgium, allowing you to retrieve train connections, live departures, and bus locations.
Feature Implementation Status
Supported Countries
| Country | API Base URL | Status |
|---|---|---|
| United Kingdom | https://transportapi.com | ✅ |
| Switzerland | https://transport.opendata.ch | ✅ |
| Belgium | https://api.irail.be | ✅ |
| Norway | https://api.entur.io | ✅ |
Features by Country
| Feature | API Path | Status |
|---|---|---|
| United Kingdom | ||
| Live Departures | /uk/train/station_timetables/{station_code}.json |
✅ |
| Switzerland | ||
| Search Connections | /connections |
✅ |
| Station Lookup | /locations |
✅ |
| Departure Board | /stationboard |
✅ |
| Nearby Stations | /locations?x={lon}&y={lat} |
✅ |
| Belgium | ||
| Live Departures | /departures |
✅ |
| Station Lookup | /stations |
✅ |
| Nearby Stations | /stations/nearby |
✅ |
| Norway | ||
| Place Search | /geocoder/v1/autocomplete |
✅ |
| Live Departures | GraphQL: stopPlace(id) { estimatedCalls(...) } |
✅ |
| Trip Planning | GraphQL: trip(from, to, dateTime, numTripPatterns, ...) |
✅ |
| Nearest Stops | GraphQL: nearest(latitude, longitude, maximumDistance, ...) |
✅ |
Setup
Environment Variables
Set the following environment variables:
UK_TRANSPORT_APP_ID=your_uk_app_id
UK_TRANSPORT_API_KEY=your_uk_api_key
Usage with Claude Desktop
Add to your 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"
}
}
}
}
Replace /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-server-public-transport with the actual path where you've cloned the repository.
Note: You may need to put the full path to the uv executable in the command field. You can get this by running which uv on MacOS/Linux or where uv on Windows.
Development
Setting up Development Environment
-
Clone the repository
git clone https://github.com/mirodn/mcp-server-public-transport.git cd mcp-server-public-transport
-
Install dependencies
uv sync -
Set environment variables
cp .env.example .env
-
Run the server
uv run server.py
Running Tests
The project uses pytest for testing with the following commands available:
# Run all tests
make test
Code Quality
# Run linting
make lint
# Run code formatting
make format
Continuous Integration
The project includes a GitHub Actions workflow (.github/workflows/test.yml) that automatically:
- Runs tests on Python 3.10, 3.11, and 3.12
- Executes linting checks using ruff
- Runs on every push and pull request to
mainbranch
The CI pipeline ensures code quality and compatibility across supported Python versions before any changes are merged.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
The package is deployed automatically to PyPI when project.version is updated in pyproject.toml.
Follow semver for versioning.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_public_transport-0.1.3.tar.gz.
File metadata
- Download URL: mcp_server_public_transport-0.1.3.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75f02c89b6ce0f110b3bb6a206a9c917abc6069e4fd1e5bd3b739ce67683d989
|
|
| MD5 |
7d6b46ef619e3738176991a492a82e6b
|
|
| BLAKE2b-256 |
e22019be251091d355b5ca302bb065cbcf44ad38f2ce53fcfd1a4cde51219c97
|
File details
Details for the file mcp_server_public_transport-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mcp_server_public_transport-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0112d581b5bdfcd8a46390aa7aa8d0d8c67783724d433883f6eb4aac0e5b4298
|
|
| MD5 |
588c7e4c2a7e6b78666843dc6c0c15a2
|
|
| BLAKE2b-256 |
f8d2546ec85b463932daefe241bfe67b17c83de8ef18851429e2d67a4d8d4982
|