Skip to main content
Glama

chitransit

Chicago transit data for AI agents and people. chitransit is a command-line tool and an MCP server built on the official CTA and City of Chicago feeds:

  • 'L' trains: arrivals at any station, live positions of every train, follow one train by run number

  • The Loop: trains on the elevated ring by line and track, downtown subway trains, line status and downtown alerts, in one call

  • Buses: arrival predictions, live GPS positions, routes, directions and stops (Bus Tracker API v3)

  • Alerts: delays, planned work, reroutes, station closures and elevator outages

  • Divvy: live bikes, e-bikes, scooters and open docks near a place

  • Ridership: daily and monthly 'L' station entries and bus route boardings (Chicago Data Portal)

  • History: a small recorder that logs train positions to SQLite, then reports headways, gaps, bunching and delay rates. CTA only serves the present, so this is how you answer "how bad was the Brown Line this morning?"

It talks to CTA directly with your own free keys: no proxy, no account with anyone else.

Install

Python 3.10 or newer. With uv:

uv tool install git+https://github.com/vayllon301/chitransit
chitransit doctor

Or run it without installing: uvx --from git+https://github.com/vayllon301/chitransit chitransit loop.

Related MCP server: transport-gzm

API keys

Feature

Key

Get it

'L' arrivals, positions, follow, loop trains, record

CTA_TRAIN_API_KEY

Train Tracker API (free)

Bus arrivals, vehicles, routes, stops

CTA_BUS_API_KEY

Bus Tracker API (free, sign in at ctabustracker.com)

Alerts, line status, stations, Divvy, ridership, GTFS bus stop search

none

Set them as environment variables (see .env.example). Each key allows 100,000 requests a day. Keys travel in the query string, so chitransit never logs request URLs or puts them in errors.

Command line

chitransit loop                                  # the Loop right now
chitransit arrivals "Clark/Lake"                 # next trains (names are fuzzy: "clark and lake" works)
chitransit arrivals western --line brown         # several stations share a name; pick by line
chitransit positions --line red --line blue      # every train on those lines
chitransit follow 412                            # one train's upcoming stops
chitransit status                                # CTA's status line for each 'L' line
chitransit alerts --station "Washington/Wabash"  # alerts for a station (or --line, --bus-route, --elevators)
chitransit stations library                      # search stations; --near LAT,LON; --loop
chitransit bus arrivals 1850 --route 22          # bus predictions at stop ids
chitransit bus vehicles 22 36                    # live buses on routes
chitransit bus stops 22 Northbound               # stop ids for a route and direction
chitransit sync --gtfs                           # once: download CTA GTFS (~50 MB) for bus stop search
chitransit bus find "Michigan & Washington"      # bus stops by name, or --near
chitransit divvy "Clark/Lake"                    # Divvy near a station or LAT,LON
chitransit nearby 41.8789,-87.6359               # 'L', Divvy and bus stops around a point
chitransit ridership station "Clark/Lake"        # latest 30 published days; --monthly, --from, --to
chitransit ridership bus 22

Every command takes --json for machine-readable output.

MCP server

chitransit mcp runs an MCP server on stdio with 16 read-only tools:

Tool

What it answers

loop_status

What is happening in the Loop right now?

train_arrivals

When is the next train at a station?

train_positions

Where is every train (optionally near a place, or on the Loop)?

follow_train

Where is run 412 going and when does it get there?

find_station

Which station is "the library"? Ids, lines, platforms, accessibility

line_status, service_alerts

Is the Blue Line OK? Is the elevator at Clark/Lake working?

bus_arrivals, bus_vehicles, bus_route_info, find_bus_stops

Buses

nearby, divvy_near

What is around this corner? Are there bikes?

ridership_history

How busy is a station or bus route, historically?

history_summary, station_headways

How did service actually run (needs the recorder)

Claude Code:

claude mcp add chitransit \
  --env CTA_TRAIN_API_KEY=your-train-key --env CTA_BUS_API_KEY=your-bus-key \
  -- uvx --from git+https://github.com/vayllon301/chitransit chitransit mcp

Claude Desktop or any client with a JSON config:

{
  "mcpServers": {
    "chitransit": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/vayllon301/chitransit", "chitransit", "mcp"],
      "env": { "CTA_TRAIN_API_KEY": "your-train-key", "CTA_BUS_API_KEY": "your-bus-key" }
    }
  }
}

Codex (~/.codex/config.toml):

[mcp_servers.chitransit]
command = "uvx"
args = ["--from", "git+https://github.com/vayllon301/chitransit", "chitransit", "mcp"]
env = { CTA_TRAIN_API_KEY = "your-train-key", CTA_BUS_API_KEY = "your-bus-key" }

Reading the data correctly

  • Live vs scheduled. Train Tracker mixes tracked trains with timetable entries. live: false means no train is being tracked yet for that slot; schedule_fault: true means its scheduled departure did not happen, so it may never run. Treat both as tentative.

  • Minutes follow CTA's advice: arrival time minus the time the prediction was made.

  • Positions come from track circuits, not GPS, so they snap to the track. Buses report GPS.

  • The Loop. Brown, Green, Orange, Pink and Purple trains use the elevated ring; Red and Blue cross downtown in subways. The Inner Loop track runs clockwise and the Outer Loop counterclockwise (from the platform directions in CTA's stop list). Per that list, Brown trains use the Outer Loop; Orange, Pink and Purple the Inner Loop; Green runs both ways along Lake Street and Wabash Avenue only. loop_status counts a train as on the Loop when its next stop is a Loop station.

  • Times are ISO 8601 in America/Chicago.

  • Ridership counts station entries (tap-ins) and is published with a lag of about two months.

  • Not available from CTA: train crowding, a trip planner, a history of past arrivals. Bus Tracker v3 has a passenger-load field; chitransit passes it on when CTA fills it in.

History recorder

chitransit record                       # polls all lines every 60 s into the data directory
chitransit history summary --since 24h  # trains in service, distinct runs, delay share, outages
chitransit history headways "Clark/Lake" --line brown --since 7d

One request covers all eight lines, so 60-second polling uses about 1,440 of a key's 100,000 daily requests. Headways come from the moment a train's next stop changes, so they are accurate to about half the poll interval; gaps that span a recording outage are skipped.

To keep it running on Linux, a systemd user service works:

# ~/.config/systemd/user/chitransit-record.service
[Unit]
Description=chitransit train position recorder

[Service]
EnvironmentFile=%h/.config/chitransit/env
ExecStart=%h/.local/bin/chitransit record --quiet
Restart=on-failure
RestartSec=30

[Install]
WantedBy=default.target

Data lives in $CHITRANSIT_HOME, else $XDG_DATA_HOME/chitransit or ~/.local/share/chitransit (%LOCALAPPDATA%\chitransit on Windows).

Data sources

See docs/DATA_SOURCES.md for every endpoint, its key, limits and quirks. This project is not affiliated with the CTA, Divvy, Lyft or the City of Chicago. Use of CTA data is subject to the CTA developer terms.

Development

uv sync
uv run pytest

Tests run offline against recorded-format fixtures. MIT licensed.

Available Tools

16 tools
bus_arrivalsB
Read-onlyIdempotent

Predicted bus arrivals at stops, with minutes, direction, destination and delay flags.

Inputs: stop_ids (required), top, routes. Returns: object

bus_route_infoC
Read-onlyIdempotent

A bus route's directions, or its stops (with ids) in one direction.

Inputs: route (required), direction. Returns: object

bus_vehiclesA
Read-onlyIdempotent

Live GPS position, heading and destination of buses on routes, or of specific buses.

Inputs: routes, vehicle_ids. Returns: object

divvy_nearB
Read-onlyIdempotent

Live Divvy availability near a place: classic bikes, e-bikes, scooters and open docks.

Inputs: location (required), limit, radius_m. Returns: object

find_bus_stopsB
Read-onlyIdempotent

Search CTA bus stops by name and/or location (needs a one-time chitransit sync --gtfs).

Inputs: near, limit, query, radius_m. Returns: object

find_stationA
Read-onlyIdempotent

Find 'L' stations by name, line or location. Returns map ids, lines, accessibility and platforms.

Inputs: line, near, limit, query. Returns: object

follow_trainB
Read-onlyIdempotent

One train's position and predicted arrival at each upcoming station.

Inputs: run (required). Returns: object

history_summaryB
Read-onlyIdempotent

From locally recorded positions: trains in service, distinct runs and delay share per line, plus recording outages. Needs chitransit record running on this machine.

Inputs: line, since, until. Returns: object

line_statusB
Read-onlyIdempotent

CTA's one-line status per route, e.g. 'Normal Service', 'Planned Work', 'Significant Delays'.

Inputs: include_bus. Returns: object

loop_statusA
Read-onlyIdempotent

The Loop right now: trains on the elevated ring by line and track, downtown subway trains, line status, and alerts that touch downtown stations or lines. Works without a key (alerts only).

Inputs: no named parameters. Returns: object

nearbyB
Read-onlyIdempotent

'L' stations, Divvy bike stations (with live bikes and docks) and bus stops near a place.

Inputs: location (required), radius_m, include_bus, include_divvy. Returns: object

ridership_historyB
Read-onlyIdempotent

Historical ridership from the City of Chicago Data Portal: 'L' station entries or bus route boardings.

Inputs: kind (required), target (required), end, start, +2 more. Returns: object

service_alertsB
Read-onlyIdempotent

Active CTA alerts: delays, planned work, reroutes, station closures and elevator outages.

Inputs: line, station, bus_route, elevators, +2 more. Returns: object

station_headwaysA
Read-onlyIdempotent

From locally recorded positions: time between trains passing a station per direction (median, p90, max, bunching, longest gaps). Needs chitransit record running on this machine.

Inputs: line (required), station (required), since, until. Returns: object

train_arrivalsB
Read-onlyIdempotent

Next 'L' trains at a station, with minutes, destination, platform and live/scheduled/delayed flags.

Inputs: station (required), line, max_results. Returns: object

train_positionsA
Read-onlyIdempotent

Live location of every in-service 'L' train (one CTA request covers all lines).

Inputs: near, lines, radius_m, loop_only. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 16 tools

    Disambiguation4/5

    Most tools map to a distinct resource+action (bus_arrivals vs bus_vehicles vs bus_route_info are cleanly separated, as are train_arrivals, train_positions and follow_train). Overlap remains around loop_status, which restates line status and alerts scoped to the Loop, and around nearby, which aggregates divvy_near, find_station and find_bus_stops results, so an agent may hesitate between the aggregate and the specific tool.

    Naming Consistency3/5

    There is a loose domain-prefix convention (bus_*, train_*, plus find_* and divvy_near), but the pattern mixes domain-first nouns (bus_arrivals, station_headways), verb_noun (find_station, follow_train, find_bus_stops) and one bare noun (nearby). It stays readable, but a tool like find_bus_stops breaks the bus_* grouping and divvy_near/divvy_* ordering is inconsistent.

    Tool Count4/5

    16 tools is at the upper edge of the comfortable band, but the surface spans four sub-domains (L trains, buses, Divvy, historical/recorded data), so each tool carries weight. A few, such as loop_status and history_summary, feel like conveniences layered on top of existing tools rather than new capabilities.

    Completeness4/5

    Coverage is strong: real-time arrivals and vehicle positions for both bus and rail, alerts, station/stop discovery, Divvy availability, and even historical ridership and headway analytics. The notable gap is any multi-modal trip/journey planning or route-itinerary tool, and there is no explicit station-detail/accessibility lookup beyond what find_station returns.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers