Skip to main content

An MCP-compatible server for querying public transport data in Europe (UK, CH, BE).

Project description

mcp-server-public-transport

An MCP-compatible 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 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

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

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

  1. Clone the repository

    git clone https://github.com/mirodn/mcp-server-public-transport.git
    cd mcp-server-public-transport
    
  2. Install dependencies

    uv sync
    
  3. Set environment variables

    cp .env.example .env
    
  4. 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 main branch

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

MIT 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

mcp_server_public_transport-0.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_public_transport-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_public_transport-0.1.1.tar.gz.

File metadata

File hashes

Hashes for mcp_server_public_transport-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b6d34c4811a1fe026cf42109cf2b8699e70add937970371248259760245956cb
MD5 bf466d67acee6a277ff2a83213aeab83
BLAKE2b-256 c641ad153e38d39f91715f35fa40368a36668173d8cea033f268501ad5356dbf

See more details on using hashes here.

File details

Details for the file mcp_server_public_transport-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_public_transport-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc600d7a225ccff770073fabc4c26fb0dfcedc2342a997b3750b4f3daa76293b
MD5 e4bddd3d47aecb1077bbae47036acf8f
BLAKE2b-256 8144d690efeb3daec50dad334290b3d986d868d16d39aebcaa8aabf4cb3ebbc3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page