Skip to main content
Glama
metrotransit-mcp

metrotransit-mcp

by aminamos

metrotransit-mcp

npm version License: MIT

A unified Model Context Protocol (MCP), Command Line Interface (CLI), and Agent Capabilities Protocol (ACP) toolkit for Metro Transit in the Minneapolis–Saint Paul metropolitan area.

Connect your AI assistants (Claude Desktop, Cursor, Antigravity, custom agents) or query directly from your terminal for real-time bus & light rail departures, station search, route schedules, and live alerts.

Zero API keys or signups required — built on Metro Transit's open public REST API.


What's Included

  • 🔌 MCP Server: Stdio server implementing the official Model Context Protocol for Claude, Cursor, Antigravity, and other MCP clients.

  • 💻 Interactive CLI: Beautiful terminal tool for departures, routes, directions, stops, and incident reports.

  • 🤖 ACP (Agent Capabilities Protocol): Ready-to-use function calling declarations and execution handlers for OpenAI, Anthropic Claude, and Google Gemini agents.

  • 📜 Downloaded OpenAPI / Swagger Specs: Full OpenAPI 3.0.4 definitions for NexTrip v2, Alerts v1, Trip Planner v1, and Schedule v1 included in spec/.


Related MCP server: BusTime MCP

1. CLI Usage

You can run commands directly using npx metrotransit-mcp <command> or by installing globally (npm i -g metrotransit-mcp).

# List all routes or search by name/number
metrotransit routes
metrotransit routes green
metrotransit routes 94

# Show route travel directions
metrotransit directions 902

# List stops for a route in a specific direction (0 = EB/NB, 1 = WB/SB)
metrotransit stops 902 0

# Search for a station on a route
metrotransit search 902 "U.S. Bank"
metrotransit search 902 "Nicollet"

# Live countdown departure board by Stop ID (posted at bus stops & platforms)
metrotransit departures 51408

# Live countdown departure board by Route + Direction + Place Code
metrotransit departures 902 0 5SNI

# Check active detours, service advisories, and closures
metrotransit alerts
metrotransit alerts 902
metrotransit alerts 94 --keyword detour

# Inspect downloaded OpenAPI / Swagger specs
metrotransit spec

2. Model Context Protocol (MCP) Setup

Run via NPX

npx metrotransit-mcp

(When launched by an MCP client or without arguments on a piped stdio, it automatically starts the MCP server).

Claude Desktop Configuration

Add to your claude_desktop_config.json:

macOS / Linux

{
  "mcpServers": {
    "metrotransit": {
      "command": "npx",
      "args": ["-y", "metrotransit-mcp"]
    }
  }
}

Windows

{
  "mcpServers": {
    "metrotransit": {
      "command": "cmd.exe",
      "args": ["/c", "npx", "-y", "metrotransit-mcp"]
    }
  }
}

Cursor / Antigravity / Other MCP Clients

{
  "mcpServers": {
    "metrotransit": {
      "command": "node",
      "args": ["/path/to/metrotransit-mcp/dist/index.js", "mcp"]
    }
  }
}

MCP Tools Provided

  1. list_routes – List or search all Twin Cities transit routes.

  2. get_route_directions – Get directional travel options (Eastbound/Westbound, Northbound/Southbound).

  3. get_route_stops – Get all stations/stops and place codes for a route.

  4. search_stops – Fuzzy search stations along a route.

  5. get_departures – Live GPS countdowns, departure times, and stop alerts by 4–5 digit Stop ID or Route + Place Code.

  6. get_service_alerts – Check active detours, stop closures, or incident advisories.


3. Agent Capabilities Protocol (ACP)

Need to equip a custom agent with Metro Transit tools without MCP?

Run:

# Output OpenAI function definitions
metrotransit acp --format openai

# Output Anthropic tool definitions
metrotransit acp --format anthropic

# Output Google Gemini tool declarations
metrotransit acp --format gemini

Or import directly in TypeScript / JavaScript:

import {
  getOpenAITools,
  getAnthropicTools,
  getGeminiTools,
  executeAgentTool,
} from "metrotransit-mcp";

// 1. Pass tool definitions to your model
const tools = getOpenAITools();

// 2. Execute when tool is called
const result = await executeAgentTool("metrotransit_get_departures", {
  stop_id: 51408,
});

4. OpenAPI / Swagger Specs

The repository includes the official OpenAPI 3.0.4 schemas directly in the spec/ folder:


Development & Testing

# Install dependencies
npm install

# Build
npm run build

# Run unit tests
npm test

# Test CLI
node dist/index.js departures 51408

License

MIT © Amin

Available Tools

6 tools
get_departuresA

Get real-time departure predictions, vehicle countdowns, and stop alerts for a Metro Transit stop or station. You can query either by a 4-5 digit Stop ID, or by Route ID + Direction ID + Place Code.

Inputs: stop_id, route_id, place_code, direction_id.

get_route_directionsA

Get valid travel directions for a specific route (e.g., Eastbound/Westbound, Northbound/Southbound) and their direction IDs.

Inputs: route_id (required).

get_route_stopsA

Get all scheduled stops for a route in a specific direction, including their place codes and station descriptions.

Inputs: route_id (required), direction_id (required).

get_service_alertsA

Get active service alerts, detours, stop closures, and disruptions across the Metro Transit network, optionally filtered by route ID or keyword.

Inputs: keyword, route_id.

list_routesA

Get all Metro Transit routes in the Minneapolis-St. Paul metro area (METRO Blue/Green/Gold/Orange/Red/A/B/C/D/E lines and bus routes). Supports optional filtering by search query.

Inputs: query.

search_stopsA

Search for stops/stations along a specific route by keyword or station name (e.g., search 'Stadium' or 'Nicollet' on the Green Line).

Inputs: query (required), route_id (required), direction_id.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool targets a distinct transit resource (routes, directions, stops, departures, alerts), but get_route_stops and search_stops overlap in purpose—one returns all stops while the other filters them by keyword. Descriptions are clear enough to differentiate, though minor boundary ambiguity exists.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern (list_routes, get_route_directions, get_departures, search_stops). No mixed conventions or vague verbs, making the set highly predictable.

    Tool Count5/5

    Six tools is well-scoped for a transit information server, covering route discovery, stop lookup, departures, and alerts without unnecessary bloat. Each tool earns its place in the workflow.

    Completeness4/5

    The core transit query surface is covered: routes, directions, stops, departures, and alerts. Minor gaps exist such as no route-by-ID lookup or stop details endpoint, but agents can achieve common tasks with the provided operations.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Wraps the CTA Bus Tracker API to provide live access to bus routes, stops, predictions, vehicle locations, patterns, and detours via MCP clients.
      11
      -