OC Transpo MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add -e "Ocp_Apim_Subscription_Key=${Ocp_Apim_Subscription_Key}" oc-transpo -- uv run mcp-server.py
Required:Ocp_Apim_Subscription_Key
README.md

Provides real-time transit data for OC Transpo in Ottawa

OC Transpo MCP Server for Learning

A Model Context Protocol (MCP) server for OC Transpo Ottawa, providing real-time transit data to AI agents and developers.

Features

  • get_vehicle_positions: Retrieves real-time latitude, longitude, and trip info for all active buses and trains.
  • get_trip_updates: Fetches real-time arrival/departure delays and schedule updates.
  • get_service_alerts: (Coming Soon) Standardized access to service disruptions (pending OC Transpo API activation).
  • FastMCP Integration: Lightweight and easy to use with any MCP-compatible agent.
  • GTFS-RT Support: Native protocol buffer parsing for live transit feeds.

Prerequisites

Setup

  1. Clone the repository:

    git clone <repository-url>
    
  2. Configure environment variables: Create a .env file in the root directory:

    Ocp_Apim_Subscription_Key=your_key_here
    
  3. Install dependencies:

    uv sync
    

Usage

Running the MCP Server

Start the server using uv:

uv run mcp-server.py

Testing with MCP Inspector

You can visually test the tools using the MCP Inspector:

npx -y @modelcontextprotocol/inspector uv run mcp-server.py

Scripting Example

You can use the helper script check_route.py to filter vehicles by route ID:

uv run check_route.py 62

Deployment

Google Cloud Run

You can deploy this server to Google Cloud Run to make it accessible over the internet via HTTPS.

  1. Build and Deploy:

    gcloud run deploy octranspo-mcp \
      --source . \
      --region us-central1 \
      --allow-unauthenticated \
      --set-env-vars Ocp_Apim_Subscription_Key=YOUR_API_KEY
    
  2. Access the Server: The server is probably live at: https://octranspo-mcp-PROJECT_ID.us-central1.run.app/mcp

Project Structure

  • mcp-server.py: Main MCP server implementation.
  • octranspo.py: API helper for GTFS-RT fetching and parsing.
  • check_route.py: CLI tool for filtering live data.
  • test_api.py: Connectivity and data parsing verification script.

License

MIT

Made with ❤️ by Antigravity

Tools (3)

get_vehicle_positionsRetrieves real-time latitude, longitude, and trip info for all active buses and trains.
get_trip_updatesFetches real-time arrival/departure delays and schedule updates.
get_service_alertsStandardized access to service disruptions.

Environment Variables

Ocp_Apim_Subscription_KeyrequiredAPI subscription key from the OC Transpo Developer Portal

Configuration

claude_desktop_config.json
{"mcpServers": {"oc-transpo": {"command": "uv", "args": ["run", "mcp-server.py"], "env": {"Ocp_Apim_Subscription_Key": "YOUR_API_KEY"}}}}

Try it

Where is the bus for route 62 currently located?
Are there any delays for my trip today?
Check for any active service alerts in the OC Transpo network.
List the current real-time positions of all active transit vehicles.

Frequently Asked Questions

What are the key features of OC Transpo MCP Server?

Real-time vehicle position tracking with latitude and longitude. Live trip updates for arrival and departure delays. Native GTFS-RT protocol buffer parsing. FastMCP integration for compatibility with AI agents.

What can I use OC Transpo MCP Server for?

Commuters checking for real-time bus delays before leaving home. Developers building transit-aware AI assistants for Ottawa residents. Monitoring transit network performance and service disruptions.

How do I install OC Transpo MCP Server?

Install OC Transpo MCP Server by running: git clone https://github.com/dwdraju/OCTranspoMCP && cd OCTranspoMCP && uv sync

What MCP clients work with OC Transpo MCP Server?

OC Transpo MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep OC Transpo MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare