timetable-api-node 1.4.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INTEGRATION.md +24 -13
- package/README.md +146 -235
- package/index.js +0 -4
- package/package.json +4 -4
package/INTEGRATION.md
CHANGED
|
@@ -11,9 +11,19 @@ No API key or authentication required.
|
|
|
11
11
|
|
|
12
12
|
## MCP (Model Context Protocol)
|
|
13
13
|
|
|
14
|
-
### Claude
|
|
14
|
+
### Claude Code
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
```bash
|
|
17
|
+
claude mcp add --transport http lviv-timetable https://api.lad.lviv.ua/mcp
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Claude Desktop / claude.ai
|
|
21
|
+
|
|
22
|
+
Open **Settings → Connectors → Add custom connector** and paste `https://api.lad.lviv.ua/mcp`. No authentication is needed.
|
|
23
|
+
|
|
24
|
+
`claude_desktop_config.json` only takes stdio servers (`command`/`args`), not a `url` — to go through the config file instead, use the stdio entry below.
|
|
25
|
+
|
|
26
|
+
### Cursor / Windsurf / other clients with remote MCP support
|
|
17
27
|
|
|
18
28
|
```json
|
|
19
29
|
{
|
|
@@ -25,7 +35,7 @@ Add to `~/.claude/claude_desktop_config.json` (or `claude.ai/code` MCP settings)
|
|
|
25
35
|
}
|
|
26
36
|
```
|
|
27
37
|
|
|
28
|
-
###
|
|
38
|
+
### stdio-only clients (including Claude Desktop's config file)
|
|
29
39
|
|
|
30
40
|
```bash
|
|
31
41
|
npx timetable-api-node
|
|
@@ -44,7 +54,7 @@ Or pin the config:
|
|
|
44
54
|
}
|
|
45
55
|
```
|
|
46
56
|
|
|
47
|
-
The `npx` entry is a
|
|
57
|
+
The `npx` entry is a thin stdio proxy — it forwards every request to the live API, so there is no database or config to set up. npx still installs the package's npm dependencies on first run, so expect a short download.
|
|
48
58
|
|
|
49
59
|
### MCP Inspector (testing)
|
|
50
60
|
|
|
@@ -60,15 +70,16 @@ All tools are read-only. Argument names are **exact** — pass them as shown.
|
|
|
60
70
|
|
|
61
71
|
| Tool | Arguments | Purpose |
|
|
62
72
|
|------|-----------|---------|
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
| `search_stops` | `query` (string), `limit` (int 1–25, optional) | Stop IDs by name — Ukrainian or English, partial, inflection-tolerant. |
|
|
74
|
+
| `get_stops_around_location` | `latitude`, `longitude` (numbers), `radius_meters` (int 50–3000, optional) | Stop IDs near a coordinate, with serving routes. |
|
|
75
|
+
| `get_stop_realtime` | `stop_id` (number or digit string) | Live arrivals at a stop: route, destination, minutes to arrival. |
|
|
76
|
+
| `find_routes_between` | `from_stop_id`, `to_stop_id` | Direct routes from A to B: where to board and get off, walk at each end. |
|
|
77
|
+
| `get_route_static` | `route_name` (string, e.g. `"T30"`), `include_shapes` (bool, optional) | Stop lists (both directions), first-stop timetable; polylines on request. |
|
|
78
|
+
| `get_route_realtime` | `route_name` (string) | Live vehicles on a route with destination and next stop. |
|
|
79
|
+
| `get_nearby_vehicles` | `latitude`, `longitude` (numbers), `radius_meters`, `route`, `limit` (optional) | Live vehicles near a coordinate, nearest first. |
|
|
80
|
+
| `get_vehicle_info` | `vehicle_id` (string) | One vehicle: route, destination, plate, upcoming stops with names. |
|
|
81
|
+
|
|
82
|
+
Every tool result is JSON with three keys — `view`, `data` (the payload), and `ui_blocks` (ordered map/arrival-list rendering hints that point into `data`). Resolve a stop name with `search_stops`, or an address/coordinates with `get_stops_around_location`, before calling stop-based tools.
|
|
72
83
|
|
|
73
84
|
---
|
|
74
85
|
|
package/README.md
CHANGED
|
@@ -31,12 +31,8 @@ nvm use && make test
|
|
|
31
31
|
|
|
32
32
|
## Monitoring
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
| Variable | Effect |
|
|
37
|
-
| --- | --- |
|
|
38
|
-
| `SENTRY_DSN` | Error reporting via `instrument.js` |
|
|
39
|
-
| `NEW_RELIC_LICENSE_KEY` | New Relic APM via `newrelic.cjs` |
|
|
34
|
+
New Relic APM, off unless `NEW_RELIC_LICENSE_KEY` is set. It also carries
|
|
35
|
+
errors and the custom metrics recorded through `utils/metrics.js`.
|
|
40
36
|
|
|
41
37
|
New Relic runs as a preloaded agent, so `npm start` carries the flags:
|
|
42
38
|
|
|
@@ -102,7 +98,16 @@ graph LR;
|
|
|
102
98
|
<details>
|
|
103
99
|
<summary><strong>Postman / curl: call a tool on production</strong></summary>
|
|
104
100
|
|
|
105
|
-
`POST https://api.lad.lviv.ua/mcp` with `Content-Type: application/json
|
|
101
|
+
`POST https://api.lad.lviv.ua/mcp` with `Content-Type: application/json` **and** `Accept: application/json, text/event-stream` — the Streamable HTTP transport rejects a request that does not accept both. The server is stateless: there is no session, so `tools/call` works on its own without an `initialize` first. The response arrives as a single SSE `event: message` frame carrying the JSON-RPC result.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
curl -s https://api.lad.lviv.ua/mcp \
|
|
105
|
+
-H 'Content-Type: application/json' \
|
|
106
|
+
-H 'Accept: application/json, text/event-stream' \
|
|
107
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_stop_realtime","arguments":{"stop_id":101}}}'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Example **`tools/call`** body shape:
|
|
106
111
|
|
|
107
112
|
```json
|
|
108
113
|
{
|
|
@@ -116,72 +121,66 @@ graph LR;
|
|
|
116
121
|
}
|
|
117
122
|
```
|
|
118
123
|
|
|
119
|
-
Successful tool responses return a **natural-language text summary** inside MCP `content` items (`type: "text"`) — e.g. *"Stop
|
|
124
|
+
Successful tool responses return a **natural-language text summary** inside MCP `content` items (`type: "text"`) — e.g. *"Stop «Площа Ринок»: 6 arrivals. Next: Т02 → «Пасічна» in 3 min."* The full structured payload is in the `structuredContent` field (for schema-aware clients). Each `structuredContent` payload follows one contract:
|
|
120
125
|
|
|
121
126
|
```json
|
|
122
127
|
{
|
|
123
128
|
"view": "transit_realtime",
|
|
124
|
-
"data": { "...": "tool-specific
|
|
129
|
+
"data": { "...": "tool-specific payload" },
|
|
125
130
|
"ui_blocks": [
|
|
126
|
-
{ "type": "map", "data": { "
|
|
127
|
-
{ "type": "arrival_list", "data": { "
|
|
131
|
+
{ "type": "map", "data": { "center": [49.84, 24.03], "zoom": 14, "layers": { "stops": "data.stop", "vehicles": "data.arrivals" } } },
|
|
132
|
+
{ "type": "arrival_list", "data": { "source": "data.arrivals" } }
|
|
128
133
|
]
|
|
129
134
|
}
|
|
130
135
|
```
|
|
131
136
|
|
|
132
|
-
|
|
137
|
+
`ui_blocks` point into `data` instead of repeating it. A `map` block gives the centre and zoom, and `layers` maps `stops`, `vehicles` and `polylines` to a dot path in the result; every stop and vehicle there has `lat`/`lng`, vehicles also `bearing`. An `arrival_list` block names the arrivals array to render, already sorted by `arrival_minutes` (`null` = no ETA).
|
|
133
138
|
|
|
134
139
|
</details>
|
|
135
140
|
|
|
136
141
|
### Exposed tools
|
|
137
142
|
|
|
138
|
-
- `
|
|
139
|
-
- `get_route_static`
|
|
140
|
-
- `get_route_realtime`
|
|
141
|
-
- `get_stop_geometry`
|
|
142
|
-
- `get_stops_around_location`
|
|
143
|
-
- `get_nearby_vehicles`
|
|
144
|
-
- `get_vehicle_info`
|
|
143
|
+
All tools are read-only. Stop IDs are the numeric codes on stop signs, returned as strings (`"707"`). Route names are the short names on vehicles (`"Т30"`, `"А1"`); Latin `"T30"`/`"A01"` work too, and a bare number is read as an internal route ID. An unknown route or vehicle returns `isError: true` with a hint on what to pass instead.
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
| Tool | Arguments | Returns |
|
|
146
|
+
|------|-----------|---------|
|
|
147
|
+
| `search_stops` | `query` (string, ≥ 2 chars), `limit` (1–25, default 10) | Stops whose Ukrainian or English name contains every query word (inflection-tolerant: `"опера"` finds «Театр опери та балету»), with `routes`. |
|
|
148
|
+
| `get_stops_around_location` | `latitude`, `longitude`, `radius_meters` (50–3000, default 1000) | Stops near a point, nearest first, with `distance_meters` and `routes`. |
|
|
149
|
+
| `get_stop_realtime` | `stop_id` | Live arrivals: `route`, `direction` (destination), `vehicle_type`, `arrival_minutes`, vehicle position. |
|
|
150
|
+
| `find_routes_between` | `from_stop_id`, `to_stop_id` | Direct routes within a 300 m walk of each end, best first: `board_stop`, `alight_stop`, `destination`, `stops_count`, walk at each end. |
|
|
151
|
+
| `get_route_static` | `route_name`, `include_shapes` (default false) | Name, type, colour, stop lists for both directions, first-stop timetable; polylines only on request. |
|
|
152
|
+
| `get_route_realtime` | `route_name` | Vehicles on the route with `destination` and `next_stop` (`id`, `name`, ISO `arrival`). |
|
|
153
|
+
| `get_nearby_vehicles` | `latitude`, `longitude`, `radius_meters` (100–1000, default 500), `route`, `limit` (1–50, default 15) | Live vehicles nearest first, with `destination` and `distance_meters`; `total` counts all in range. |
|
|
154
|
+
| `get_vehicle_info` | `vehicle_id` | One vehicle: position, route, `destination`, plate, upcoming stops (`id`, `name`, ISO times) not yet passed. |
|
|
148
155
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
| Field | Type | Required |
|
|
152
|
-
|-------|------|----------|
|
|
153
|
-
| `stop_id` | positive integer or digits-only string | yes |
|
|
154
|
-
|
|
155
|
-
**Example result** (shape only; values from upstream):
|
|
156
|
+
<details>
|
|
157
|
+
<summary><code>get_stop_realtime</code> — example</summary>
|
|
156
158
|
|
|
157
159
|
```json
|
|
158
160
|
{
|
|
159
161
|
"view": "transit_realtime",
|
|
160
162
|
"data": {
|
|
161
|
-
"stop": { "id": "
|
|
163
|
+
"stop": { "id": "61", "name": "Площа Ринок", "lat": 49.84146, "lng": 24.03227 },
|
|
162
164
|
"arrivals": [
|
|
163
165
|
{
|
|
164
|
-
"route": "
|
|
165
|
-
"direction": "
|
|
166
|
+
"route": "Т02",
|
|
167
|
+
"direction": "Пасічна",
|
|
166
168
|
"vehicle_type": "tram",
|
|
167
|
-
"arrival_minutes":
|
|
168
|
-
"vehicle_id": "
|
|
169
|
-
"lat": 49.
|
|
170
|
-
"lng": 24.
|
|
171
|
-
"bearing":
|
|
169
|
+
"arrival_minutes": 3,
|
|
170
|
+
"vehicle_id": "2393",
|
|
171
|
+
"lat": 49.83461,
|
|
172
|
+
"lng": 24.01672,
|
|
173
|
+
"bearing": 60
|
|
172
174
|
}
|
|
173
175
|
],
|
|
174
|
-
"updated_at": "2026-
|
|
176
|
+
"updated_at": "2026-09-23T09:01:21Z"
|
|
175
177
|
},
|
|
176
178
|
"ui_blocks": [
|
|
177
179
|
{
|
|
178
180
|
"type": "map",
|
|
179
|
-
"data": { "center": [49.
|
|
181
|
+
"data": { "center": [49.84146, 24.03227], "zoom": 14, "layers": { "stops": "data.stop", "vehicles": "data.arrivals" } }
|
|
180
182
|
},
|
|
181
|
-
{
|
|
182
|
-
"type": "arrival_list",
|
|
183
|
-
"data": { "arrivals": [] }
|
|
184
|
-
}
|
|
183
|
+
{ "type": "arrival_list", "data": { "source": "data.arrivals" } }
|
|
185
184
|
]
|
|
186
185
|
}
|
|
187
186
|
```
|
|
@@ -189,252 +188,164 @@ Consistency rule: each vehicle rendered on map must either have a matching ETA i
|
|
|
189
188
|
</details>
|
|
190
189
|
|
|
191
190
|
<details>
|
|
192
|
-
<summary><code>
|
|
193
|
-
|
|
194
|
-
**Arguments (JSON):**
|
|
195
|
-
|
|
196
|
-
| Field | Type | Required |
|
|
197
|
-
|-------|------|----------|
|
|
198
|
-
| `route_name` | route short name (e.g. `"T30"`, `"32A"`) or numeric external ID | yes |
|
|
199
|
-
|
|
200
|
-
**Example result** (shape only; stops truncated for brevity):
|
|
191
|
+
<summary><code>search_stops</code> — example</summary>
|
|
201
192
|
|
|
202
193
|
```json
|
|
203
194
|
{
|
|
204
195
|
"view": "transit_realtime",
|
|
205
196
|
"data": {
|
|
206
|
-
"
|
|
207
|
-
"name": "T30",
|
|
208
|
-
"long_name": "Рясне-2 — Сихів",
|
|
209
|
-
"color": "#e81717",
|
|
210
|
-
"type": "tram"
|
|
211
|
-
},
|
|
197
|
+
"query": "rynok",
|
|
212
198
|
"stops": [
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
[
|
|
222
|
-
{ "id": "707", "name": "Стадіон Сільмаш", "lat": 49.838, "lng": 24.021, "departures": [], "schedule": { "workday": [], "weekend": [] } },
|
|
223
|
-
{ "id": "101", "name": "Головний вокзал", "lat": 49.841, "lng": 24.003, "departures": [], "schedule": { "workday": [], "weekend": [] } }
|
|
224
|
-
]
|
|
225
|
-
],
|
|
226
|
-
"shapes": [
|
|
227
|
-
[[49.841, 24.003], [49.839, 24.012], [49.838, 24.021]],
|
|
228
|
-
[[49.838, 24.021], [49.839, 24.012], [49.841, 24.003]]
|
|
199
|
+
{
|
|
200
|
+
"id": "61",
|
|
201
|
+
"name": "Площа Ринок",
|
|
202
|
+
"lat": 49.84146,
|
|
203
|
+
"lng": 24.03227,
|
|
204
|
+
"eng_name": "Rynok square",
|
|
205
|
+
"routes": ["Т01", "Т02"]
|
|
206
|
+
}
|
|
229
207
|
],
|
|
230
|
-
"updated_at": "2026-
|
|
208
|
+
"updated_at": "2026-09-23T09:36:53Z"
|
|
231
209
|
},
|
|
232
210
|
"ui_blocks": [
|
|
233
|
-
{
|
|
234
|
-
"type": "map",
|
|
235
|
-
"data": {
|
|
236
|
-
"center": [49.841, 24.003],
|
|
237
|
-
"zoom": 13,
|
|
238
|
-
"polylines": [[[49.841, 24.003], [49.839, 24.012], [49.838, 24.021]]],
|
|
239
|
-
"stops": [
|
|
240
|
-
{ "id": "101", "name": "Головний вокзал", "lat": 49.841, "lng": 24.003 },
|
|
241
|
-
{ "id": "707", "name": "Стадіон Сільмаш", "lat": 49.838, "lng": 24.021 }
|
|
242
|
-
],
|
|
243
|
-
"vehicles": []
|
|
244
|
-
}
|
|
245
|
-
}
|
|
211
|
+
{ "type": "map", "data": { "center": [49.84146, 24.03227], "zoom": 14, "layers": { "stops": "data.stops" } } }
|
|
246
212
|
]
|
|
247
213
|
}
|
|
248
214
|
```
|
|
249
215
|
|
|
250
|
-
|
|
216
|
+
One stop name usually covers both sides of the street under different IDs; each is returned, and `routes` tells them apart. `get_stops_around_location` returns the same stop objects plus `distance_meters`.
|
|
251
217
|
|
|
252
218
|
</details>
|
|
253
219
|
|
|
254
220
|
<details>
|
|
255
|
-
<summary><code>
|
|
256
|
-
|
|
257
|
-
**Arguments (JSON):**
|
|
258
|
-
|
|
259
|
-
| Field | Type | Required |
|
|
260
|
-
|-------|------|----------|
|
|
261
|
-
| `route_name` | route short name (e.g. `"T30"`, `"32A"`) or numeric external ID | yes |
|
|
221
|
+
<summary><code>find_routes_between</code> — example</summary>
|
|
262
222
|
|
|
263
|
-
|
|
223
|
+
Text summary: *"3 direct routes «Площа Ринок» → «Залізничний вокзал». Best: Т01 towards «Залізничний вокзал», 8 stops, board at «Руська» (137m walk)."*
|
|
264
224
|
|
|
265
225
|
```json
|
|
266
226
|
{
|
|
267
227
|
"view": "transit_realtime",
|
|
268
228
|
"data": {
|
|
269
|
-
"
|
|
270
|
-
"
|
|
229
|
+
"from": { "id": "61", "name": "Площа Ринок", "stop_ids": ["10", "57", "58", "59", "61", "63", "855"] },
|
|
230
|
+
"to": { "id": "118", "name": "Залізничний вокзал", "stop_ids": ["117", "118", "188", "189", "190", "191"] },
|
|
231
|
+
"options": [
|
|
271
232
|
{
|
|
272
|
-
"
|
|
233
|
+
"route": "Т01",
|
|
234
|
+
"vehicle_type": "tram",
|
|
273
235
|
"direction": 0,
|
|
274
|
-
"
|
|
275
|
-
"lng": 24.
|
|
276
|
-
"
|
|
277
|
-
"
|
|
236
|
+
"destination": "Залізничний вокзал",
|
|
237
|
+
"board_stop": { "id": "58", "name": "Руська", "lat": 49.84186, "lng": 24.03408 },
|
|
238
|
+
"alight_stop": { "id": "118", "name": "Залізничний вокзал", "lat": 49.839, "lng": 23.99677 },
|
|
239
|
+
"stops_count": 8,
|
|
240
|
+
"walk_to_board_meters": 137,
|
|
241
|
+
"walk_from_alight_meters": 0
|
|
278
242
|
}
|
|
279
243
|
],
|
|
280
|
-
"updated_at": "2026-
|
|
244
|
+
"updated_at": "2026-09-23T09:36:53Z"
|
|
281
245
|
},
|
|
282
|
-
"ui_blocks": [
|
|
283
|
-
{
|
|
284
|
-
"type": "map",
|
|
285
|
-
"data": {
|
|
286
|
-
"center": [49.838, 24.021],
|
|
287
|
-
"zoom": 13,
|
|
288
|
-
"vehicles": [
|
|
289
|
-
{
|
|
290
|
-
"id": "tram_123",
|
|
291
|
-
"direction": 0,
|
|
292
|
-
"lat": 49.838,
|
|
293
|
-
"lng": 24.021,
|
|
294
|
-
"bearing": 120,
|
|
295
|
-
"lowfloor": true
|
|
296
|
-
}
|
|
297
|
-
]
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
]
|
|
246
|
+
"ui_blocks": []
|
|
301
247
|
}
|
|
302
248
|
```
|
|
303
249
|
|
|
304
|
-
|
|
250
|
+
Each end covers every stop within a 300 m walk (`stop_ids`): a line's two directions often stop on opposite sides of a street under different names, as here, where Т01 towards the station leaves from «Руська», not «Площа Ринок». Options are ranked by stops plus walking (150 m of walking weighs as one stop), one per route and direction. A direction's last stop counts as a place to get off, not to board. Only direct routes are listed; an empty `options` means a transfer is needed.
|
|
305
251
|
|
|
306
252
|
</details>
|
|
307
253
|
|
|
308
254
|
<details>
|
|
309
|
-
<summary><code>
|
|
310
|
-
|
|
311
|
-
**Arguments:**
|
|
312
|
-
|
|
313
|
-
| Field | Type | Required |
|
|
314
|
-
|-------|------|----------|
|
|
315
|
-
| `stop_id` | positive integer or digits-only string | yes |
|
|
316
|
-
|
|
317
|
-
**Example result:**
|
|
255
|
+
<summary><code>get_route_static</code> — example</summary>
|
|
318
256
|
|
|
319
257
|
```json
|
|
320
258
|
{
|
|
321
259
|
"view": "transit_realtime",
|
|
322
260
|
"data": {
|
|
323
|
-
"
|
|
324
|
-
"
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
261
|
+
"route": { "name": "Т30", "long_name": "Університет - Городоцька - вул. Ряшівська", "color": "#EF88AA", "type": "trolleybus" },
|
|
262
|
+
"stops": [
|
|
263
|
+
[
|
|
264
|
+
{
|
|
265
|
+
"id": "101", "name": "Університет", "lat": 49.841, "lng": 24.003,
|
|
266
|
+
"departures": ["05:30", "05:52"],
|
|
267
|
+
"schedule": { "workday": ["05:30", "05:52", "06:10"], "weekend": ["07:00", "07:30"] }
|
|
268
|
+
},
|
|
269
|
+
{ "id": "707", "name": "Стадіон Сільмаш", "lat": 49.838, "lng": 24.021, "departures": [], "schedule": { "workday": [], "weekend": [] } }
|
|
270
|
+
],
|
|
271
|
+
[
|
|
272
|
+
{ "id": "707", "name": "Стадіон Сільмаш", "lat": 49.838, "lng": 24.021, "departures": ["06:00"], "schedule": { "workday": ["06:00"], "weekend": [] } }
|
|
273
|
+
]
|
|
274
|
+
],
|
|
275
|
+
"updated_at": "2026-09-23T09:01:12Z"
|
|
330
276
|
},
|
|
331
|
-
"ui_blocks": [
|
|
277
|
+
"ui_blocks": [
|
|
278
|
+
{ "type": "map", "data": { "center": [49.841, 24.003], "zoom": 13, "layers": { "stops": "data.stops" } } }
|
|
279
|
+
]
|
|
332
280
|
}
|
|
333
281
|
```
|
|
334
282
|
|
|
283
|
+
`stops[0]` is direction 0 (outbound), `stops[1]` direction 1 (return). `departures` and `schedule` are populated for the **first stop of each direction**; other stops have empty arrays. `schedule.workday` is Monday–Friday, `schedule.weekend` Saturday–Sunday; `departures` keeps today's schedule for backward compatibility. With `include_shapes: true`, `data.shapes` holds one `[lat, lng]` polyline per direction and the map block adds `"polylines": "data.shapes"`.
|
|
284
|
+
|
|
335
285
|
</details>
|
|
336
286
|
|
|
337
287
|
<details>
|
|
338
|
-
<summary><code>
|
|
339
|
-
|
|
340
|
-
Returns 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).
|
|
341
|
-
|
|
342
|
-
**Arguments (JSON):**
|
|
343
|
-
|
|
344
|
-
| Field | Type | Required |
|
|
345
|
-
|-------|------|----------|
|
|
346
|
-
| `latitude` | number, −90…90 | yes |
|
|
347
|
-
| `longitude` | number, −180…180 | yes |
|
|
348
|
-
| `radius_meters` | integer, 50…3000 | no (default **1000**) |
|
|
349
|
-
|
|
350
|
-
**Example result** (shape only):
|
|
288
|
+
<summary><code>get_route_realtime</code> — example</summary>
|
|
351
289
|
|
|
352
290
|
```json
|
|
353
291
|
{
|
|
354
292
|
"view": "transit_realtime",
|
|
355
293
|
"data": {
|
|
356
|
-
"
|
|
357
|
-
"
|
|
358
|
-
"
|
|
359
|
-
"stops": [
|
|
294
|
+
"route_name": "Т01",
|
|
295
|
+
"destinations": ["Залізничний вокзал", "Погулянка"],
|
|
296
|
+
"vehicles": [
|
|
360
297
|
{
|
|
361
|
-
"id": "
|
|
362
|
-
"
|
|
363
|
-
"
|
|
364
|
-
"
|
|
365
|
-
"
|
|
298
|
+
"id": "5907",
|
|
299
|
+
"direction": 0,
|
|
300
|
+
"destination": "Залізничний вокзал",
|
|
301
|
+
"next_stop": { "id": "118", "name": "Залізничний вокзал", "arrival": "2026-09-23T09:35:00.000Z" },
|
|
302
|
+
"lat": 49.83947,
|
|
303
|
+
"lng": 23.99566,
|
|
304
|
+
"bearing": 126,
|
|
305
|
+
"lowfloor": true
|
|
366
306
|
}
|
|
367
307
|
],
|
|
368
|
-
"updated_at": "2026-
|
|
308
|
+
"updated_at": "2026-09-23T09:32:10Z"
|
|
369
309
|
},
|
|
370
310
|
"ui_blocks": [
|
|
371
|
-
{
|
|
372
|
-
"type": "map",
|
|
373
|
-
"data": {
|
|
374
|
-
"center": [49.84, 24.03],
|
|
375
|
-
"zoom": 15,
|
|
376
|
-
"stops": [
|
|
377
|
-
{
|
|
378
|
-
"id": "707",
|
|
379
|
-
"name": "Стадіон Сільмаш",
|
|
380
|
-
"lat": 49.841,
|
|
381
|
-
"lng": 24.031,
|
|
382
|
-
"distance_meters": 120
|
|
383
|
-
}
|
|
384
|
-
],
|
|
385
|
-
"vehicles": []
|
|
386
|
-
}
|
|
387
|
-
}
|
|
311
|
+
{ "type": "map", "data": { "center": [49.83947, 23.99566], "zoom": 13, "layers": { "vehicles": "data.vehicles" } } }
|
|
388
312
|
]
|
|
389
313
|
}
|
|
390
314
|
```
|
|
391
315
|
|
|
392
|
-
|
|
316
|
+
`route_name` is the canonical short name whatever form was passed. `direction` indexes `get_route_static`'s `stops` (0 = outbound, 1 = return) and `destinations`. `next_stop` is `null` when the feed has no trip update for the vehicle.
|
|
393
317
|
|
|
394
318
|
</details>
|
|
395
319
|
|
|
396
320
|
<details>
|
|
397
|
-
<summary><code>get_nearby_vehicles</code> —
|
|
398
|
-
|
|
399
|
-
Returns live positions for all transit vehicles within 1 km of given coordinates. Wraps the same backend as `GET /transport`.
|
|
400
|
-
|
|
401
|
-
**Arguments (JSON):**
|
|
402
|
-
|
|
403
|
-
| Field | Type | Required |
|
|
404
|
-
|-------|------|----------|
|
|
405
|
-
| `latitude` | number, −90…90 | yes |
|
|
406
|
-
| `longitude` | number, −180…180 | yes |
|
|
407
|
-
|
|
408
|
-
**Example result** (shape only):
|
|
321
|
+
<summary><code>get_nearby_vehicles</code> — example</summary>
|
|
409
322
|
|
|
410
323
|
```json
|
|
411
324
|
{
|
|
412
325
|
"view": "transit_realtime",
|
|
413
326
|
"data": {
|
|
414
|
-
"center_lat": 49.
|
|
415
|
-
"center_lng": 24.
|
|
327
|
+
"center_lat": 49.8419,
|
|
328
|
+
"center_lng": 24.0316,
|
|
329
|
+
"radius_meters": 500,
|
|
330
|
+
"total": 18,
|
|
416
331
|
"vehicles": [
|
|
417
332
|
{
|
|
418
|
-
"id": "
|
|
419
|
-
"route": "
|
|
333
|
+
"id": "3422",
|
|
334
|
+
"route": "Т01",
|
|
420
335
|
"vehicle_type": "tram",
|
|
421
|
-
"
|
|
422
|
-
"
|
|
423
|
-
"
|
|
424
|
-
"
|
|
336
|
+
"direction": 0,
|
|
337
|
+
"destination": "Залізничний вокзал",
|
|
338
|
+
"lat": 49.84154,
|
|
339
|
+
"lng": 24.03364,
|
|
340
|
+
"bearing": 258,
|
|
341
|
+
"lowfloor": false,
|
|
342
|
+
"distance_meters": 152
|
|
425
343
|
}
|
|
426
344
|
],
|
|
427
|
-
"updated_at": "2026-
|
|
345
|
+
"updated_at": "2026-09-23T09:32:10Z"
|
|
428
346
|
},
|
|
429
347
|
"ui_blocks": [
|
|
430
|
-
{
|
|
431
|
-
"type": "map",
|
|
432
|
-
"data": {
|
|
433
|
-
"center": [49.84, 24.03],
|
|
434
|
-
"zoom": 14,
|
|
435
|
-
"vehicles": [{ "id": "tram_123", "route": "T01", "lat": 49.841, "lng": 24.031, "bearing": 90, "eta_status": "unassigned" }]
|
|
436
|
-
}
|
|
437
|
-
}
|
|
348
|
+
{ "type": "map", "data": { "center": [49.8419, 24.0316], "zoom": 15, "layers": { "vehicles": "data.vehicles" } } }
|
|
438
349
|
]
|
|
439
350
|
}
|
|
440
351
|
```
|
|
@@ -442,47 +353,47 @@ Returns live positions for all transit vehicles within 1 km of given coordinates
|
|
|
442
353
|
</details>
|
|
443
354
|
|
|
444
355
|
<details>
|
|
445
|
-
<summary><code>get_vehicle_info</code> —
|
|
446
|
-
|
|
447
|
-
Full 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`.
|
|
448
|
-
|
|
449
|
-
**Arguments (JSON):**
|
|
450
|
-
|
|
451
|
-
| Field | Type | Required |
|
|
452
|
-
|-------|------|----------|
|
|
453
|
-
| `vehicle_id` | string | yes |
|
|
454
|
-
|
|
455
|
-
**Example result** (shape only):
|
|
356
|
+
<summary><code>get_vehicle_info</code> — example</summary>
|
|
456
357
|
|
|
457
358
|
```json
|
|
458
359
|
{
|
|
459
360
|
"view": "transit_realtime",
|
|
460
361
|
"data": {
|
|
461
|
-
"vehicle_id": "
|
|
462
|
-
"route": "
|
|
463
|
-
"license_plate": "
|
|
464
|
-
"lat": 49.
|
|
465
|
-
"lng":
|
|
466
|
-
"bearing":
|
|
362
|
+
"vehicle_id": "5907",
|
|
363
|
+
"route": "Т01",
|
|
364
|
+
"license_plate": "1238",
|
|
365
|
+
"lat": 49.83947,
|
|
366
|
+
"lng": 23.99566,
|
|
367
|
+
"bearing": 126,
|
|
467
368
|
"direction": 0,
|
|
369
|
+
"destination": "Залізничний вокзал",
|
|
468
370
|
"upcoming_stops": [
|
|
469
|
-
{ "
|
|
470
|
-
{ "
|
|
371
|
+
{ "id": "118", "name": "Залізничний вокзал", "arrival": null, "departure": "2026-09-23T09:35:00.000Z" },
|
|
372
|
+
{ "id": "188", "name": "Приміський вокзал", "arrival": "2026-09-23T09:35:49.000Z", "departure": null }
|
|
471
373
|
],
|
|
472
|
-
"updated_at": "2026-
|
|
374
|
+
"updated_at": "2026-09-23T09:32:10Z"
|
|
473
375
|
},
|
|
474
376
|
"ui_blocks": [
|
|
475
|
-
{
|
|
476
|
-
"type": "map",
|
|
477
|
-
"data": { "center": [49.841, 24.031], "zoom": 15, "vehicles": [{ "id": "tram_123", "eta_status": "unassigned" }] }
|
|
478
|
-
}
|
|
377
|
+
{ "type": "map", "data": { "center": [49.83947, 23.99566], "zoom": 15, "layers": { "vehicles": "data" } } }
|
|
479
378
|
]
|
|
480
379
|
}
|
|
481
380
|
```
|
|
482
381
|
|
|
382
|
+
`route` is the route short name, falling back to the opaque GTFS route ID only when the route is missing from the local data. Either value is accepted as `route_name` by `get_route_static` and `get_route_realtime`. `license_plate` is `null` when the feed has none.
|
|
383
|
+
|
|
483
384
|
</details>
|
|
484
385
|
|
|
485
386
|
|
|
387
|
+
### Prompts
|
|
388
|
+
|
|
389
|
+
Reusable instruction templates for rendering workflows. Each takes one argument, `stop_id` (positive integer or digits-only string).
|
|
390
|
+
|
|
391
|
+
| Prompt | Use case |
|
|
392
|
+
|--------|----------|
|
|
393
|
+
| `transit-map-view` | Map-first rendering of live vehicles for a stop. |
|
|
394
|
+
| `transit-arrival-list` | Arrival list for a stop, sorted by ETA and grouped by route. |
|
|
395
|
+
| `transit-hybrid-view` | Map block first, arrival-list block second, with ETA values kept consistent across both. |
|
|
396
|
+
|
|
486
397
|
### Resources and resource templates
|
|
487
398
|
|
|
488
399
|
In addition to tools, the server exposes MCP **resources** for reference data that doesn't require a tool call:
|
package/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import "./instrument.js";
|
|
2
1
|
import "dotenv/config";
|
|
3
2
|
|
|
4
|
-
import * as Sentry from "@sentry/node";
|
|
5
3
|
import pkg from "./package.json" with { type: "json" };
|
|
6
4
|
import path from "path";
|
|
7
5
|
const __dirname = import.meta.dirname;
|
|
@@ -454,8 +452,6 @@ app.get("/server.json", (req, res) => {
|
|
|
454
452
|
|
|
455
453
|
app.use(notFoundAction);
|
|
456
454
|
|
|
457
|
-
Sentry.setupExpressErrorHandler(app);
|
|
458
|
-
|
|
459
455
|
app.use(errorHandler);
|
|
460
456
|
|
|
461
457
|
app.on("ready", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "timetable-api-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Lviv (Ukraine) public transport REST API and read-only Model Context Protocol (MCP) server: stops, timetables, routes, live vehicle positions, GTFS/GTFS-RT. No API key required.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -33,9 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
36
|
-
"@sentry/node": "^10.52.0",
|
|
37
36
|
"cors": "^2.8.5",
|
|
38
|
-
"dotenv": "^
|
|
37
|
+
"dotenv": "^18.0",
|
|
39
38
|
"express": "^5.2.1",
|
|
40
39
|
"express-rate-limit": "^8.6.2",
|
|
41
40
|
"gtfs": "^4.18.5",
|
|
@@ -52,7 +51,8 @@
|
|
|
52
51
|
"import-slim": "node gtfs-import-slim.js",
|
|
53
52
|
"start": "node -r dotenv/config -r newrelic --import newrelic/esm-loader.mjs index.js",
|
|
54
53
|
"test": "vitest run",
|
|
55
|
-
"test:watch": "vitest"
|
|
54
|
+
"test:watch": "vitest",
|
|
55
|
+
"version": "node scripts/sync-manifest-versions.js && git add server.json openapi.yaml"
|
|
56
56
|
},
|
|
57
57
|
"author": "vbhjckfd@gmail.com",
|
|
58
58
|
"license": "WTFPL",
|