Purpose
timetable-api-node is the Node.js version of the lad.lviv.ua API, providing timetable data services for public transport in Lviv (Ukraine). Built on Express, it exposes a read-only REST API and a read-only MCP (Model Context Protocol) endpoint for LLM clients and ordinary HTTP clients to query real-time and static information about public transport such as buses and trams.
Main capabilities
- Real-time stop arrivals: Query real-time arrival information for a specified stop, with short caching (5–10 seconds).
- Real-time vehicle positions: Query real-time vehicle positions by route, or query the real-time position and upcoming arrivals of a single vehicle by vehicle ID.
- Route static data: Retrieve route shapes, stop lists, departure timetables (categorized by weekday, Saturday, Sunday), etc.
- Nearby stop discovery: Find nearby stops based on latitude and longitude, with a radius parameter (50–3000 meters, default 1000 meters).
- Transfer planning: Provide direct routes and one-transfer trip options via MCP tools, sorted by number of stops and walking distance.
- Vehicle lookup by license plate: Find a vehicle ID by license plate number (ignoring case, spaces, and hyphens).
- MCP resources: In addition to tools, it also exposes MCP resources (such as timetable://route/{name}), with completion support.
Usage
- Environment requirements: Node.js 26 (see .nvmrc).
- Data import: Run
make importto download static GTFS data and write it to two stores:database/Timetable(LokiJS, containing stops, routes, shapes, first-stop timetables) anddatabase/gtfs(SQLite, containing trips and calendars). Both are gitignored, so a freshly cloned repository must import data first.make import-slimonly re-imports the lightweight tables into SQLite. - Running: The code is TypeScript and runs directly through Node's built-in type stripping, with no build step required.
npm run buildonly generatesmcp/stdio.js(the published bin), because Node does not strip types inside node_modules. - MCP endpoint:
/mcp, using Streamable HTTP transport, stateless, and tools/call can be invoked without first calling initialize. Requests must setContent-Type: application/jsonandAccept: application/json, text/event-stream. - REST endpoints: Including
/stops、/stops.json、/stops/:code、/stops/:code/timetable、/stops/:code/static、/stops/nearby、/routes、/routes/static/:name、/routes/realtime/:name、/vehicle/:vehicleId、/vehicle/by-plate/:plate、/vehicles/nearby, etc. - Deployment: The production environment runs on Cloud Run (europe-north1), proxied through Cloudflare. The Dockerfile imports GTFS data at build time.
make deploycan be manually built and deployed. - npm package:
make publishis published to npm and the MCP Registry, containing only the timetable-mcp stdio proxy.
Applicable scenarios
- Developing applications or websites for Lviv public transport that need real-time arrivals, vehicle positions, and route data.
- Letting LLM clients (such as Claude, Cursor) query public transport information via the MCP protocol.
- Scenarios requiring nearby stop discovery or simple transfer planning.
Limitations
- All tools and endpoints are read-only and do not provide any operations that modify data.
- Publicly read-only, no authentication required.
- POST /mcp is rate-limited by IP to 60 requests/minute (in memory, reset on restart), returning HTTP 429 when exceeded.
- Stop overrides (stopOverrides) are stored only in browser localStorage and are visible only to the browser that made the edits.
- The upstream route list sometimes lags behind reality, and GET /stops applies stored overrides to correct it.
- Transfer options are limited to at most one transfer; if both lists are empty, it means two or more transfers are required.
- Some fields (such as speed, license_plate, next_stop) are null when the data source does not provide them.
- The production environment uses New Relic APM, which is disabled by default and requires setting NEW_RELIC_LICENSE_KEY to enable.