Skip to main content
Glama

ojp-mcp

MCP server for Swiss public transport, backed by the OJP 2.0 API of opentransportdata.swiss. Runs locally over stdio with your own API token.

Proof of concept. This project is not actively maintained. Feel free to reuse and fork it under the MIT license.

Token

  1. Register at https://api-manager.opentransportdata.swiss.

  2. Subscribe to the OJP 2.0 API and copy your token.

  3. Pass it as OJP_TOKEN (environment only; it never appears in tool output or logs).

Related MCP server: Zügli MCP Server

Setup

Requires Node ≥ 20.

git clone https://github.com/d3orn/ojp-mcp.git
cd ojp-mcp
npm install

Claude Code:

claude mcp add ojp -e OJP_TOKEN=<your-token> -- node /absolute/path/to/ojp-mcp/src/index.js

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "ojp": {
      "command": "node",
      "args": ["/absolute/path/to/ojp-mcp/src/index.js"],
      "env": { "OJP_TOKEN": "<your-token>" }
    }
  }
}

Not yet published to npm. Once it is, npx -y ojp-mcp replaces node /absolute/path/to/ojp-mcp/src/index.js.

Tools

Tool

Purpose

search_locations

Stops, addresses, POIs, towns by name or lat/lon (+ radius)

plan_trip

Trips from → to (optional via), time, arriveBy, limit

get_departures

Departure/arrival board for a stop

get_trip_details

All calls of one journey (journeyRef + operatingDay from the tools above)

Places accept a name or an id from search_locations; ambiguous names return candidate ids instead of guessing. Times are Europe/Zurich (input without offset is local time). All tools take language (de default, fr, it, en).

Limits & errors

The OJP API allows 50 calls per minute and 20 000 calls per day per token. Most tools use 1 call. plan_trip uses 1 more for each place given as a name, so up to 4. Pass ids from search_locations to save calls.

Error

Meaning

OJP_TOKEN is invalid or not authorized for OJP 2.0

Token wrong, expired, or not subscribed to OJP 2.0

OJP service error: HTTP 500

Upstream temporarily unavailable. Retry shortly

OJP service error: HTTP 429 (or other status)

Rate limit or other upstream rejection. Wait and retry

OJP service timed out

No answer within 15 s

… is ambiguous … Use one of these ids

Retry with one of the listed ids

Development

npm install
npm test

License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time Swiss railway information including departures, connections, train composition, occupancy forecasts, disruptions, and pricing, accessible via natural language in over 100 languages.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables querying Swiss public transport data (stations, departures, connections) from the Transport Open Data API via natural language through an MCP gateway.
    15 npm
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Connects AI assistants to Swiss Federal Railways (SBB/CFF/FFS) data: train schedules, station search, ticket prices, and direct ticket purchase links.
    6
    25 npm
    -