The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Timetable API Node listing page.
Express-based API for Lviv transport timetable data with a read-only MCP endpoint.
.nvmrc)Two optional integrations, both off unless their environment variable is set:
| Variable | Effect |
|---|---|
SENTRY_DSN | Error reporting via instrument.js |
NEW_RELIC_LICENSE_KEY | New Relic APM via newrelic.cjs |
New Relic runs as a preloaded agent, so npm start carries the flags:
dotenv/config is preloaded first so .env is populated before the agent
reads its configuration. The config file is newrelic.cjs (the agent is
CommonJS and this project is ESM) and holds no secrets — the key comes from the
environment. /health is excluded from transactions via rules.ignore.
The account is in the EU region; its license key starts with eu01xx and
the agent picks the collector from that prefix. Use the 40-character ingest
license key, not an NRAK-... user API key.
Cloud Run reads the key from Secret Manager:
This service exposes a public read-only MCP endpoint over Streamable HTTP.
/mcp/.well-known/mcp/server-card.json/robots.txt (non-standard comment hint)Production deployment (see cloudbuild.yaml for Cloud Run) serves REST and MCP from api.lad.lviv.ua. The main site lad.lviv.ua is the public transport website (this repo still links there in HTML sitemap and tables for people, not for the API host). Use your own origin when running locally.
/mcp flowAn MCP client (Claude, Cursor, or the MCP SDK) talks JSON-RPC over Streamable HTTP to POST /mcp. Tool handlers reuse the same Express actions as the REST API, backed by LokiJS timetable data, GTFS SQLite (via gtfs), and live GTFS-RT feeds (for example track.ua-gis.com).
MCP Inspector (local): run npx @modelcontextprotocol/inspector, then open the UI with transport and server URL prefilled (from the inspector README):
http://localhost:6274/?transport=streamable-http&serverUrl=https%3A%2F%2Fapi.lad.lviv.ua%2Fmcp
POST https://api.lad.lviv.ua/mcp with Content-Type: application/json. The Streamable HTTP transport may require additional headers your MCP client sets automatically; for a quick manual test, follow the same sequence your MCP SDK uses (session initialize, then tools/call). Example tools/call body shape:
Successful tool responses return a natural-language text summary inside MCP content items (type: "text") — e.g. "Stop «Opera»: 3 arrivals. Next: T01 → «Rynok» in 2 min." The full structured payload is in the structuredContent field (for schema-aware clients). Each structuredContent payload follows a strict UI contract:
Consistency rule: each vehicle rendered on map must either have a matching ETA in list data or eta_status: "unassigned".
get_stop_realtimeget_route_staticget_route_realtimeget_stop_geometryget_stops_around_locationget_nearby_vehiclesget_vehicle_infoget_stop_realtime — input & exampleArguments (JSON):
| Field | Type | Required |
|---|---|---|
stop_id | positive integer or digits-only string | yes |
Example result (shape only; values from upstream):
get_route_static — input & exampleArguments (JSON):
| Field | Type | Required |
|---|---|---|
route_name | route short name (e.g. "T30", "32A") or numeric external ID | yes |
Example result (shape only; stops truncated for brevity):
stops[0] is direction 0 (outbound), stops[1] is direction 1 (return). departures and schedule are populated only for the first stop of direction 0; all other stops have empty arrays. schedule.workday contains Monday–Friday departure times; schedule.weekend contains Saturday–Sunday departure times. departures keeps today's schedule for backward compatibility. shapes follows the same two-element order. The map block uses direction-0 polyline and all unique stops as markers.
get_route_realtime — input & exampleArguments (JSON):
| Field | Type | Required |
|---|---|---|
route_name | route short name (e.g. "T30", "32A") or numeric external ID | yes |
Example result:
direction matches the index into get_route_static's stops array (0 = outbound, 1 = return). lowfloor: true indicates a low-floor vehicle. Returns an empty vehicles array when no vehicles are currently active on the route.
get_stop_geometry — input & exampleArguments:
| Field | Type | Required |
|---|---|---|
stop_id | positive integer or digits-only string | yes |
Example result:
get_stops_around_location — input & exampleReturns stops near a map point (numeric code, name, coordinates, distance). Intended for hosts that render map UI blocks (for example ChatGPT): one block with multiple stop markers and the search center. Uses the same backend as GET /closest (see below).
Arguments (JSON):
| Field | Type | Required |
|---|---|---|
latitude | number, −90…90 | yes |
longitude | number, −180…180 | yes |
radius_meters | integer, 50…3000 | no (default 1000) |
Example result (shape only):
Map zoom is 15 for radius ≤ 1500 m and 14 for larger radii (up to 3000 m).
get_nearby_vehicles — input & exampleReturns live positions for all transit vehicles within 1 km of given coordinates. Wraps the same backend as GET /transport.
Arguments (JSON):
| Field | Type | Required |
|---|---|---|
latitude | number, −90…90 | yes |
longitude | number, −180…180 | yes |
Example result (shape only):
get_vehicle_info — input & exampleFull details for one vehicle by its ID: position, route, license plate, direction, and upcoming stop arrival times. Vehicle IDs come from get_route_realtime, get_nearby_vehicles, or get_stop_realtime.
Arguments (JSON):
| Field | Type | Required |
|---|---|---|
vehicle_id | string | yes |
Example result (shape only):
In addition to tools, the server exposes MCP resources for reference data that doesn't require a tool call:
| URI | Description |
|---|---|
timetable://about | Scope, usage, and data caveats for this server (Markdown) |
timetable://reference/tools | Tools reference table (Markdown) |
timetable://reference/prompts | Prompt templates catalog (Markdown) |
timetable://stop/{code} | Static info for a stop by numeric code — name, coordinates, serving routes (JSON) |
timetable://route/{name} | Static metadata for a route by short name — color, type, stop counts (JSON) |
POST /mcp is rate-limited to 60 requests/min per IP (in-memory, resets on restart). Excess requests receive HTTP 429 with a JSON-RPC error body.robots.txt is only a best-effort discovery hint and not a protocol contract.All endpoints return JSON. :code is a numeric stop code; :name is a route short name (e.g. T1, 32A) or numeric external ID.
GET /stops.jsonAll stops as a JSON array, sorted by code.
{ code, name, eng_name, location: [lat, lng], routes, sign, sign_pdf }.(GET /stops returns an HTML table instead.)
The upstream route list for a stop is sometimes behind reality. GET /stops
applies a stored override to its Маршрути column — removed routes shown red and
struck through, added ones green — and hangs the matching ?add=/?remove= on
that row's SVG and PDF links, which offline.lad.lviv.ua and pdf.lad.lviv.ua
both understand.
The route column is always clickable: click a route to drop or restore it, type
one into the + box to add it.
Overrides live in the browser's own localStorage (see
public/stopOverrides.js), not on a server — no
account to edit through, no cache to purge, an edit applies at once. The trade
is scope: an override is visible only in the browser that made it, not to
anyone else who opens /stops.
/stops.json reports sign and sign_pdf without overrides applied.
GET /stops/:codeSingle stop with live realtime timetable. Short-cached (5–10 s).
skipTimetableData=1 — omit live arrivals (long-cached response).{ code, name, eng_name, latitude, longitude, transfers, timetable }.GET /stops/:code/timetableLive timetable only for a stop. Short-cached (5–10 s).
GET /stops/:code/staticStatic stop info without live data. Long-cached (30 days).
{ code, name, eng_name, latitude, longitude, transfers }.GET /closest?latitude={lat}&longitude={lng}Nearby stops — same search as get_stops_around_location, for non-MCP clients.
radius — meters, clamped between 50 and 3000 (default 1000).{ code, name, latitude, longitude, distance_meters } (sorted by distance).GET /routes.jsonAll routes as a JSON array, sorted by short name.
(GET /routes returns an HTML table.)
GET /routes/static/:nameRoute shape, stop list, and metadata. Long-cached (30 days).
{ id, color, type, route_short_name, route_long_name, stops: [[dir0…], [dir1…]], shapes }.{ code, name, loc, transfers, departures, schedule }.
departures — today's departure times (HH:MM), populated only for direction 0 first stop. Kept for backward compatibility.schedule — { workday: string[], weekend: string[] } departure times by day type, populated only for direction 0 first stop.GET /routes/dynamic/:nameLive vehicle positions for a route. Short-cached (10 s).
{ id, direction, location: [lat, lng], bearing, speed, lowfloor }. speed is m/s from the GPS unit, or null when not reported.GET /vehicle/:vehicleIdLive position and upcoming stop arrivals for one vehicle. Short-cached (5 s).
{ location: [lat, lng], routeId, bearing, speed, direction, licensePlate, arrivals }. speed is m/s from the GPS unit, or null when not reported.GET /vehicle-by-plate/:plateLook up a vehicle ID by its license plate. Short-cached (5 s).
BC-1234-AA, bc 1234 aa, and bc1234aa are all equivalent).{ vehicleId } — use the returned ID with GET /vehicle/:vehicleId.GET /transport?latitude={lat}&longitude={lng}Vehicles within 1 km of a point. Short-cached (10 s).
{ id, route, routeId, direction, vehicle_type, color, location: [lat, lng], bearing, speed, lowfloor }. routeId is usable as :name in /routes/static/:name; direction matches the index into stops/shapes (0 = outbound, 1 = return, null if unknown). speed is m/s or null.