onebusaway-mcp-server 0.1.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/CLAUDE.md +367 -0
- package/Dockerfile +99 -0
- package/LICENSE +201 -0
- package/README.md +322 -0
- package/changelog/0.1.x/0.1.0.md +15 -0
- package/changelog/0.1.x/0.1.1.md +17 -0
- package/changelog/template.md +119 -0
- package/dist/config/server-config.d.ts +13 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +26 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/route.resource.d.ts +9 -0
- package/dist/mcp-server/resources/definitions/route.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/route.resource.js +33 -0
- package/dist/mcp-server/resources/definitions/route.resource.js.map +1 -0
- package/dist/mcp-server/resources/definitions/stop.resource.d.ts +9 -0
- package/dist/mcp-server/resources/definitions/stop.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/stop.resource.js +33 -0
- package/dist/mcp-server/resources/definitions/stop.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/find-routes.tool.d.ts +24 -0
- package/dist/mcp-server/tools/definitions/find-routes.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/find-routes.tool.js +72 -0
- package/dist/mcp-server/tools/definitions/find-routes.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/find-stops.tool.d.ts +28 -0
- package/dist/mcp-server/tools/definitions/find-stops.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/find-stops.tool.js +76 -0
- package/dist/mcp-server/tools/definitions/find-stops.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-arrivals.tool.d.ts +49 -0
- package/dist/mcp-server/tools/definitions/get-arrivals.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-arrivals.tool.js +176 -0
- package/dist/mcp-server/tools/definitions/get-arrivals.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-route.tool.d.ts +25 -0
- package/dist/mcp-server/tools/definitions/get-route.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-route.tool.js +60 -0
- package/dist/mcp-server/tools/definitions/get-route.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-route.tool.d.ts +31 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-route.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-route.tool.js +107 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-route.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-stop.tool.d.ts +31 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-stop.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-stop.tool.js +105 -0
- package/dist/mcp-server/tools/definitions/get-schedule-for-stop.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-stop.tool.d.ts +28 -0
- package/dist/mcp-server/tools/definitions/get-stop.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-stop.tool.js +57 -0
- package/dist/mcp-server/tools/definitions/get-stop.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-trip.tool.d.ts +42 -0
- package/dist/mcp-server/tools/definitions/get-trip.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-trip.tool.js +143 -0
- package/dist/mcp-server/tools/definitions/get-trip.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-vehicles.tool.d.ts +34 -0
- package/dist/mcp-server/tools/definitions/get-vehicles.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-vehicles.tool.js +117 -0
- package/dist/mcp-server/tools/definitions/get-vehicles.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-agencies.tool.d.ts +23 -0
- package/dist/mcp-server/tools/definitions/list-agencies.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-agencies.tool.js +58 -0
- package/dist/mcp-server/tools/definitions/list-agencies.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-routes-for-agency.tool.d.ts +25 -0
- package/dist/mcp-server/tools/definitions/list-routes-for-agency.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-routes-for-agency.tool.js +71 -0
- package/dist/mcp-server/tools/definitions/list-routes-for-agency.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-routes.tool.d.ts +26 -0
- package/dist/mcp-server/tools/definitions/search-routes.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-routes.tool.js +68 -0
- package/dist/mcp-server/tools/definitions/search-routes.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-stops.tool.d.ts +25 -0
- package/dist/mcp-server/tools/definitions/search-stops.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-stops.tool.js +61 -0
- package/dist/mcp-server/tools/definitions/search-stops.tool.js.map +1 -0
- package/dist/services/onebusaway/onebusaway-service.d.ts +64 -0
- package/dist/services/onebusaway/onebusaway-service.d.ts.map +1 -0
- package/dist/services/onebusaway/onebusaway-service.js +441 -0
- package/dist/services/onebusaway/onebusaway-service.js.map +1 -0
- package/dist/services/onebusaway/types.d.ts +147 -0
- package/dist/services/onebusaway/types.d.ts.map +1 -0
- package/dist/services/onebusaway/types.js +6 -0
- package/dist/services/onebusaway/types.js.map +1 -0
- package/package.json +90 -0
- package/server.json +127 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Full-day schedule for a route — all trips and stop sequences.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-schedule-for-route.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getOneBusAwayService } from '../../../services/onebusaway/onebusaway-service.js';
|
|
8
|
+
/** Format seconds-from-midnight (GTFS schedule) as HH:MM. */
|
|
9
|
+
function fmtTimeSec(secs) {
|
|
10
|
+
if (!secs && secs !== 0)
|
|
11
|
+
return 'N/A';
|
|
12
|
+
const h = Math.floor(secs / 3600)
|
|
13
|
+
.toString()
|
|
14
|
+
.padStart(2, '0');
|
|
15
|
+
const m = Math.floor((secs % 3600) / 60)
|
|
16
|
+
.toString()
|
|
17
|
+
.padStart(2, '0');
|
|
18
|
+
return `${h}:${m}`;
|
|
19
|
+
}
|
|
20
|
+
export const getScheduleForRoute = tool('onebusaway_get_schedule_for_route', {
|
|
21
|
+
title: 'Get Route Schedule',
|
|
22
|
+
description: 'Full-day schedule for a route — all trips, stop sequences, and departure times for the specified date (defaults to today). Returns up to all trips for the route. For live predictions, use onebusaway_get_arrivals at specific stops instead.',
|
|
23
|
+
annotations: { readOnlyHint: true },
|
|
24
|
+
input: z.object({
|
|
25
|
+
routeId: z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1)
|
|
28
|
+
.describe('Agency-prefixed route ID (e.g. "1_100259"). Use onebusaway_find_routes or onebusaway_search_routes to discover IDs.'),
|
|
29
|
+
date: z.string().optional().describe('ISO 8601 date (e.g. "2026-05-23"). Defaults to today.'),
|
|
30
|
+
}),
|
|
31
|
+
output: z.object({
|
|
32
|
+
routeId: z.string().describe('The queried route ID.'),
|
|
33
|
+
routeShortName: z.string().describe('Route short name.'),
|
|
34
|
+
serviceDateMs: z.number().describe('Service date as Unix milliseconds.'),
|
|
35
|
+
trips: z
|
|
36
|
+
.array(z
|
|
37
|
+
.object({
|
|
38
|
+
tripId: z.string().describe('Trip ID for follow-up onebusaway_get_trip calls.'),
|
|
39
|
+
tripHeadsign: z.string().describe('Destination sign text.'),
|
|
40
|
+
serviceId: z.string().describe('Service calendar ID.'),
|
|
41
|
+
stops: z
|
|
42
|
+
.array(z
|
|
43
|
+
.object({
|
|
44
|
+
stopId: z.string().describe('Stop ID.'),
|
|
45
|
+
stopName: z.string().describe('Stop name.'),
|
|
46
|
+
arrivalTime: z
|
|
47
|
+
.number()
|
|
48
|
+
.describe('Scheduled arrival time as seconds from midnight (GTFS format).'),
|
|
49
|
+
departureTime: z
|
|
50
|
+
.number()
|
|
51
|
+
.describe('Scheduled departure time as seconds from midnight (GTFS format).'),
|
|
52
|
+
})
|
|
53
|
+
.describe('A stop time along this trip.'))
|
|
54
|
+
.describe('Stop sequence for this trip.'),
|
|
55
|
+
})
|
|
56
|
+
.describe('A single trip with its scheduled stop sequence.'))
|
|
57
|
+
.describe('All trips for this route on this date, with their stop sequences.'),
|
|
58
|
+
}),
|
|
59
|
+
errors: [
|
|
60
|
+
{
|
|
61
|
+
reason: 'route_not_found',
|
|
62
|
+
code: JsonRpcErrorCode.NotFound,
|
|
63
|
+
when: 'Route ID does not exist on this instance.',
|
|
64
|
+
recovery: 'Search for the route with onebusaway_find_routes or onebusaway_search_routes to get a valid ID.',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
async handler(input, ctx) {
|
|
68
|
+
const result = await getOneBusAwayService().getScheduleForRoute({
|
|
69
|
+
routeId: input.routeId,
|
|
70
|
+
...(input.date && { date: input.date }),
|
|
71
|
+
}, ctx);
|
|
72
|
+
ctx.log.info('getScheduleForRoute completed', {
|
|
73
|
+
routeId: input.routeId,
|
|
74
|
+
tripCount: result.trips.length,
|
|
75
|
+
});
|
|
76
|
+
return result;
|
|
77
|
+
},
|
|
78
|
+
format: (result) => {
|
|
79
|
+
const serviceDate = new Date(result.serviceDateMs);
|
|
80
|
+
const serviceDateStr = serviceDate.toLocaleDateString('en-US', {
|
|
81
|
+
weekday: 'short',
|
|
82
|
+
year: 'numeric',
|
|
83
|
+
month: 'short',
|
|
84
|
+
day: 'numeric',
|
|
85
|
+
});
|
|
86
|
+
const lines = [
|
|
87
|
+
`## Schedule for Route ${result.routeShortName} (${result.routeId})`,
|
|
88
|
+
`**Service date:** ${serviceDateStr} (${result.serviceDateMs})`,
|
|
89
|
+
`**Trips:** ${result.trips.length}`,
|
|
90
|
+
];
|
|
91
|
+
for (const t of result.trips) {
|
|
92
|
+
lines.push(`\n### Trip ${t.tripId} → ${t.tripHeadsign} (serviceId: ${t.serviceId})`);
|
|
93
|
+
if (t.stops.length > 0) {
|
|
94
|
+
const first = t.stops.at(0);
|
|
95
|
+
const last = t.stops.at(-1);
|
|
96
|
+
if (first && last) {
|
|
97
|
+
lines.push(`Departs ${first.stopName} at ${fmtTimeSec(first.departureTime)}, arrives ${last.stopName} at ${fmtTimeSec(last.arrivalTime)} — ${t.stops.length} stops`);
|
|
98
|
+
}
|
|
99
|
+
for (const s of t.stops) {
|
|
100
|
+
lines.push(`- ${fmtTimeSec(s.arrivalTime)} [${s.arrivalTime}s] ${s.stopName} (${s.stopId}) dep ${fmtTimeSec(s.departureTime)} [${s.departureTime}s]`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=get-schedule-for-route.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schedule-for-route.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-schedule-for-route.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,6DAA6D;AAC7D,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,I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C;oBACxB,KAAK,CAAC,IAAI,CACR,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,WAAW,MAAM,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,MAAM,SAAS,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,aAAa,IAAI,CAC1I,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Full-day departure schedule for a stop.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-schedule-for-stop.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const getScheduleForStop: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
stopId: z.ZodString;
|
|
9
|
+
date: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
stopId: z.ZodString;
|
|
12
|
+
stopName: z.ZodString;
|
|
13
|
+
serviceDateMs: z.ZodNumber;
|
|
14
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
15
|
+
routeId: z.ZodString;
|
|
16
|
+
routeShortName: z.ZodString;
|
|
17
|
+
directions: z.ZodArray<z.ZodObject<{
|
|
18
|
+
tripHeadsign: z.ZodString;
|
|
19
|
+
departures: z.ZodArray<z.ZodObject<{
|
|
20
|
+
scheduledDepartureTime: z.ZodNumber;
|
|
21
|
+
tripId: z.ZodString;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
}, z.core.$strip>, readonly [{
|
|
26
|
+
readonly reason: "stop_not_found";
|
|
27
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
28
|
+
readonly when: "Stop ID does not exist on this instance.";
|
|
29
|
+
readonly recovery: "Search for the stop with onebusaway_find_stops or onebusaway_search_stops to get a valid ID.";
|
|
30
|
+
}]>;
|
|
31
|
+
//# sourceMappingURL=get-schedule-for-stop.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schedule-for-stop.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-schedule-for-stop.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAUjE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;GA6G7B,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Full-day departure schedule for a stop.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-schedule-for-stop.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getOneBusAwayService } from '../../../services/onebusaway/onebusaway-service.js';
|
|
8
|
+
function fmtTime(ms) {
|
|
9
|
+
const d = new Date(ms);
|
|
10
|
+
const h = d.getHours().toString().padStart(2, '0');
|
|
11
|
+
const m = d.getMinutes().toString().padStart(2, '0');
|
|
12
|
+
return `${h}:${m}`;
|
|
13
|
+
}
|
|
14
|
+
export const getScheduleForStop = tool('onebusaway_get_schedule_for_stop', {
|
|
15
|
+
title: 'Get Stop Schedule',
|
|
16
|
+
description: "Full-day departure schedule for a stop. Lists every departure by route and direction for the specified date (defaults to today). Useful for planning or when real-time data isn't needed. For live predictions, use onebusaway_get_arrivals instead.",
|
|
17
|
+
annotations: { readOnlyHint: true },
|
|
18
|
+
input: z.object({
|
|
19
|
+
stopId: z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.describe('Agency-prefixed stop ID (e.g. "1_75403"). Use onebusaway_find_stops or onebusaway_search_stops to discover IDs.'),
|
|
23
|
+
date: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('ISO 8601 date (e.g. "2026-05-23"). Defaults to today in the agency\'s timezone.'),
|
|
27
|
+
}),
|
|
28
|
+
output: z.object({
|
|
29
|
+
stopId: z.string().describe('The queried stop ID.'),
|
|
30
|
+
stopName: z.string().describe('Stop name.'),
|
|
31
|
+
serviceDateMs: z.number().describe('Service date as Unix milliseconds (start of service day).'),
|
|
32
|
+
routes: z
|
|
33
|
+
.array(z
|
|
34
|
+
.object({
|
|
35
|
+
routeId: z
|
|
36
|
+
.string()
|
|
37
|
+
.describe('Route ID for follow-up onebusaway_get_route or onebusaway_get_schedule_for_route calls.'),
|
|
38
|
+
routeShortName: z.string().describe('Route short name.'),
|
|
39
|
+
directions: z
|
|
40
|
+
.array(z
|
|
41
|
+
.object({
|
|
42
|
+
tripHeadsign: z.string().describe('Destination sign text.'),
|
|
43
|
+
departures: z
|
|
44
|
+
.array(z
|
|
45
|
+
.object({
|
|
46
|
+
scheduledDepartureTime: z
|
|
47
|
+
.number()
|
|
48
|
+
.describe('Scheduled departure time as Unix milliseconds.'),
|
|
49
|
+
tripId: z
|
|
50
|
+
.string()
|
|
51
|
+
.describe('Trip ID for follow-up onebusaway_get_trip calls.'),
|
|
52
|
+
})
|
|
53
|
+
.describe('A single scheduled departure.'))
|
|
54
|
+
.describe('All departures for this direction.'),
|
|
55
|
+
})
|
|
56
|
+
.describe('A service direction at this stop.'))
|
|
57
|
+
.describe('Service directions for this route at this stop.'),
|
|
58
|
+
})
|
|
59
|
+
.describe('A route with its scheduled departures from this stop.'))
|
|
60
|
+
.describe('All routes with departures from this stop on this date.'),
|
|
61
|
+
}),
|
|
62
|
+
errors: [
|
|
63
|
+
{
|
|
64
|
+
reason: 'stop_not_found',
|
|
65
|
+
code: JsonRpcErrorCode.NotFound,
|
|
66
|
+
when: 'Stop ID does not exist on this instance.',
|
|
67
|
+
recovery: 'Search for the stop with onebusaway_find_stops or onebusaway_search_stops to get a valid ID.',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
async handler(input, ctx) {
|
|
71
|
+
const result = await getOneBusAwayService().getScheduleForStop({
|
|
72
|
+
stopId: input.stopId,
|
|
73
|
+
...(input.date && { date: input.date }),
|
|
74
|
+
}, ctx);
|
|
75
|
+
ctx.log.info('getScheduleForStop completed', {
|
|
76
|
+
stopId: input.stopId,
|
|
77
|
+
routeCount: result.routes.length,
|
|
78
|
+
});
|
|
79
|
+
return result;
|
|
80
|
+
},
|
|
81
|
+
format: (result) => {
|
|
82
|
+
const serviceDate = new Date(result.serviceDateMs);
|
|
83
|
+
const serviceDateStr = serviceDate.toLocaleDateString('en-US', {
|
|
84
|
+
weekday: 'short',
|
|
85
|
+
year: 'numeric',
|
|
86
|
+
month: 'short',
|
|
87
|
+
day: 'numeric',
|
|
88
|
+
});
|
|
89
|
+
const lines = [
|
|
90
|
+
`## Schedule for ${result.stopName} (${result.stopId})`,
|
|
91
|
+
`**Service date:** ${serviceDateStr} (${result.serviceDateMs})`,
|
|
92
|
+
`**Routes:** ${result.routes.length}`,
|
|
93
|
+
];
|
|
94
|
+
for (const r of result.routes) {
|
|
95
|
+
lines.push(`\n### Route ${r.routeShortName} (${r.routeId})`);
|
|
96
|
+
for (const dir of r.directions) {
|
|
97
|
+
lines.push(`**→ ${dir.tripHeadsign}** (${dir.departures.length} departures)`);
|
|
98
|
+
const times = dir.departures.map((d) => `${fmtTime(d.scheduledDepartureTime)} (${d.scheduledDepartureTime}) [${d.tripId}]`);
|
|
99
|
+
lines.push(times.join(', '));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=get-schedule-for-stop.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schedule-for-stop.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-schedule-for-stop.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,SAAS,OAAO,CAAC,EAAU;IACzB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,kCAAkC,EAAE;IACzE,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EACT,sPAAsP;IACxP,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;IACnC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACP,iHAAiH,CAClH;QACH,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,EAAE;aAC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U,EAAE,CAAC;gBAC/B,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,YAAY,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,cAAc,CAAC,CAAC;gBAC9E,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAC9B,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,sBAAsB,MAAM,CAAC,CAAC,MAAM,GAAG,CAC1F,CAAC;gBACF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fetch details for a specific stop by ID.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-stop.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const getStop: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
stopId: z.ZodString;
|
|
9
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
code: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
lat: z.ZodNumber;
|
|
14
|
+
lon: z.ZodNumber;
|
|
15
|
+
direction: z.ZodString;
|
|
16
|
+
routeIds: z.ZodArray<z.ZodString>;
|
|
17
|
+
wheelchairBoarding: z.ZodEnum<{
|
|
18
|
+
ACCESSIBLE: "ACCESSIBLE";
|
|
19
|
+
NOT_ACCESSIBLE: "NOT_ACCESSIBLE";
|
|
20
|
+
UNKNOWN: "UNKNOWN";
|
|
21
|
+
}>;
|
|
22
|
+
}, z.core.$strip>, readonly [{
|
|
23
|
+
readonly reason: "stop_not_found";
|
|
24
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
25
|
+
readonly when: "Stop ID does not exist on this instance.";
|
|
26
|
+
readonly recovery: "Search for the stop with onebusaway_find_stops or onebusaway_search_stops to get a valid ID.";
|
|
27
|
+
}]>;
|
|
28
|
+
//# sourceMappingURL=get-stop.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-stop.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-stop.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;GAwDlB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fetch details for a specific stop by ID.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-stop.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getOneBusAwayService } from '../../../services/onebusaway/onebusaway-service.js';
|
|
8
|
+
export const getStop = tool('onebusaway_get_stop', {
|
|
9
|
+
title: 'Get Stop Details',
|
|
10
|
+
description: 'Fetch details for a specific stop by ID. Returns the stop\'s name, coordinates, direction, served routes, and wheelchair accessibility. Stop IDs use agency-prefixed format: {agencyId}_{localId} (e.g. "1_75403" for Metro Transit stop 75403).',
|
|
11
|
+
annotations: { readOnlyHint: true },
|
|
12
|
+
input: z.object({
|
|
13
|
+
stopId: z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1)
|
|
16
|
+
.describe('Agency-prefixed stop ID (e.g. "1_75403" for Metro Transit stop 75403, "40_100239" for Sound Transit). Use onebusaway_find_stops or onebusaway_search_stops to discover IDs.'),
|
|
17
|
+
}),
|
|
18
|
+
output: z.object({
|
|
19
|
+
id: z.string().describe('Agency-prefixed stop ID.'),
|
|
20
|
+
code: z.string().describe('The stop code printed on the sign.'),
|
|
21
|
+
name: z.string().describe('Stop name.'),
|
|
22
|
+
lat: z.number().describe('Latitude of the stop.'),
|
|
23
|
+
lon: z.number().describe('Longitude of the stop.'),
|
|
24
|
+
direction: z.string().describe('Compass direction of travel at this stop (e.g. "NW").'),
|
|
25
|
+
routeIds: z
|
|
26
|
+
.array(z.string())
|
|
27
|
+
.describe('IDs of routes that serve this stop. Use with onebusaway_get_arrivals or onebusaway_get_schedule_for_stop.'),
|
|
28
|
+
wheelchairBoarding: z
|
|
29
|
+
.enum(['ACCESSIBLE', 'NOT_ACCESSIBLE', 'UNKNOWN'])
|
|
30
|
+
.describe('Wheelchair boarding status.'),
|
|
31
|
+
}),
|
|
32
|
+
errors: [
|
|
33
|
+
{
|
|
34
|
+
reason: 'stop_not_found',
|
|
35
|
+
code: JsonRpcErrorCode.NotFound,
|
|
36
|
+
when: 'Stop ID does not exist on this instance.',
|
|
37
|
+
recovery: 'Search for the stop with onebusaway_find_stops or onebusaway_search_stops to get a valid ID.',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
async handler(input, ctx) {
|
|
41
|
+
const stop = await getOneBusAwayService().getStop(input.stopId, ctx);
|
|
42
|
+
ctx.log.info('getStop completed', { stopId: input.stopId });
|
|
43
|
+
return stop;
|
|
44
|
+
},
|
|
45
|
+
format: (result) => {
|
|
46
|
+
const lines = [
|
|
47
|
+
`## ${result.name}`,
|
|
48
|
+
`**ID:** ${result.id} | **Code:** ${result.code}`,
|
|
49
|
+
`**Direction:** ${result.direction}`,
|
|
50
|
+
`**Coordinates:** ${result.lat.toFixed(6)}, ${result.lon.toFixed(6)}`,
|
|
51
|
+
`**Routes:** ${result.routeIds.join(', ') || 'none'}`,
|
|
52
|
+
`**Wheelchair:** ${result.wheelchairBoarding}`,
|
|
53
|
+
];
|
|
54
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=get-stop.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-stop.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-stop.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,EAAE;IACjD,KAAK,EAAE,kBAAkB;IACzB,WAAW,EACT,kPAAkP;IACpP,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;IACnC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACP,6KAA6K,CAC9K;KACJ,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QACnD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;QAC/D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QACvC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QACjD,GA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MAAM,EAAE;YACrD,mBAAmB,MAAM,CAAC,kBAAkB,EAAE;SAC/C,CAAC;QACF,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Real-time status and stop sequence for an active trip.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-trip.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const getTrip: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
tripId: z.ZodString;
|
|
9
|
+
serviceDateMs: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
includeSchedule: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
tripId: z.ZodString;
|
|
13
|
+
routeShortName: z.ZodString;
|
|
14
|
+
tripHeadsign: z.ZodString;
|
|
15
|
+
status: z.ZodObject<{
|
|
16
|
+
phase: z.ZodString;
|
|
17
|
+
predicted: z.ZodBoolean;
|
|
18
|
+
position: z.ZodNullable<z.ZodObject<{
|
|
19
|
+
lat: z.ZodNumber;
|
|
20
|
+
lon: z.ZodNumber;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
scheduleDeviation: z.ZodNumber;
|
|
23
|
+
nextStop: z.ZodNullable<z.ZodString>;
|
|
24
|
+
closestStop: z.ZodNullable<z.ZodString>;
|
|
25
|
+
vehicleId: z.ZodNullable<z.ZodString>;
|
|
26
|
+
lastUpdateTime: z.ZodNumber;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
schedule: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
29
|
+
stopId: z.ZodString;
|
|
30
|
+
stopName: z.ZodString;
|
|
31
|
+
arrivalTime: z.ZodNumber;
|
|
32
|
+
departureTime: z.ZodNumber;
|
|
33
|
+
distanceAlongTripMeters: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
situations: z.ZodArray<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>, readonly [{
|
|
37
|
+
readonly reason: "trip_not_found";
|
|
38
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
39
|
+
readonly when: "Trip ID not found or not active for the service date.";
|
|
40
|
+
readonly recovery: "Verify the tripId from an arrivals response; if the trip has completed, fetch the schedule instead with onebusaway_get_schedule_for_route.";
|
|
41
|
+
}]>;
|
|
42
|
+
//# sourceMappingURL=get-trip.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trip.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-trip.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAwBjE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmIlB,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Real-time status and stop sequence for an active trip.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-trip.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getOneBusAwayService } from '../../../services/onebusaway/onebusaway-service.js';
|
|
8
|
+
/** Format Unix milliseconds as HH:MM. */
|
|
9
|
+
function fmtTimeMs(ms) {
|
|
10
|
+
if (!ms && ms !== 0)
|
|
11
|
+
return 'N/A';
|
|
12
|
+
const d = new Date(ms);
|
|
13
|
+
const h = d.getHours().toString().padStart(2, '0');
|
|
14
|
+
const m = d.getMinutes().toString().padStart(2, '0');
|
|
15
|
+
return `${h}:${m}`;
|
|
16
|
+
}
|
|
17
|
+
/** Format seconds-from-midnight (GTFS schedule) as HH:MM. */
|
|
18
|
+
function fmtTimeSec(secs) {
|
|
19
|
+
if (!secs && secs !== 0)
|
|
20
|
+
return 'N/A';
|
|
21
|
+
const h = Math.floor(secs / 3600)
|
|
22
|
+
.toString()
|
|
23
|
+
.padStart(2, '0');
|
|
24
|
+
const m = Math.floor((secs % 3600) / 60)
|
|
25
|
+
.toString()
|
|
26
|
+
.padStart(2, '0');
|
|
27
|
+
return `${h}:${m}`;
|
|
28
|
+
}
|
|
29
|
+
export const getTrip = tool('onebusaway_get_trip', {
|
|
30
|
+
title: 'Get Trip Status',
|
|
31
|
+
description: "Real-time status and stop sequence for a trip. Returns vehicle position, schedule deviation, current phase, and remaining stops. Use tripId from onebusaway_get_arrivals to look up a specific vehicle's progress.",
|
|
32
|
+
annotations: { readOnlyHint: true },
|
|
33
|
+
input: z.object({
|
|
34
|
+
tripId: z.string().min(1).describe('Trip ID from an arrivals response or schedule lookup.'),
|
|
35
|
+
serviceDateMs: z
|
|
36
|
+
.number()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Service date as Unix milliseconds (midnight local time). Only needed for trips from a previous service day. Omit to use today.'),
|
|
39
|
+
includeSchedule: z
|
|
40
|
+
.boolean()
|
|
41
|
+
.default(true)
|
|
42
|
+
.describe('Whether to include the full stop sequence with times. Defaults to true.'),
|
|
43
|
+
}),
|
|
44
|
+
output: z.object({
|
|
45
|
+
tripId: z.string().describe('The queried trip ID.'),
|
|
46
|
+
routeShortName: z.string().describe('Route short name (e.g. "44").'),
|
|
47
|
+
tripHeadsign: z.string().describe('Destination sign text.'),
|
|
48
|
+
status: z
|
|
49
|
+
.object({
|
|
50
|
+
phase: z
|
|
51
|
+
.string()
|
|
52
|
+
.describe('Current journey phase (e.g. "in_progress", "layover_before", "layover_during").'),
|
|
53
|
+
predicted: z.boolean().describe('True if GPS-tracked real-time data is available.'),
|
|
54
|
+
position: z
|
|
55
|
+
.object({
|
|
56
|
+
lat: z.number().describe('Vehicle latitude.'),
|
|
57
|
+
lon: z.number().describe('Vehicle longitude.'),
|
|
58
|
+
})
|
|
59
|
+
.nullable()
|
|
60
|
+
.describe('Current vehicle position if available, or null.'),
|
|
61
|
+
scheduleDeviation: z.number().describe('Seconds late (positive) or early (negative).'),
|
|
62
|
+
nextStop: z.string().nullable().describe('Stop ID of the next stop, or null.'),
|
|
63
|
+
closestStop: z.string().nullable().describe('Stop ID of the closest stop, or null.'),
|
|
64
|
+
vehicleId: z.string().nullable().describe('Vehicle ID if known, or null.'),
|
|
65
|
+
lastUpdateTime: z
|
|
66
|
+
.number()
|
|
67
|
+
.describe('Timestamp of the last real-time update as Unix milliseconds.'),
|
|
68
|
+
})
|
|
69
|
+
.describe('Real-time status of the trip.'),
|
|
70
|
+
schedule: z
|
|
71
|
+
.array(z
|
|
72
|
+
.object({
|
|
73
|
+
stopId: z.string().describe('Stop ID.'),
|
|
74
|
+
stopName: z.string().describe('Stop name.'),
|
|
75
|
+
arrivalTime: z
|
|
76
|
+
.number()
|
|
77
|
+
.describe('Scheduled arrival time as seconds from midnight (GTFS format).'),
|
|
78
|
+
departureTime: z
|
|
79
|
+
.number()
|
|
80
|
+
.describe('Scheduled departure time as seconds from midnight (GTFS format).'),
|
|
81
|
+
distanceAlongTripMeters: z
|
|
82
|
+
.number()
|
|
83
|
+
.describe('Distance along the trip to this stop, in meters.'),
|
|
84
|
+
})
|
|
85
|
+
.describe('A scheduled stop time along this trip.'))
|
|
86
|
+
.nullable()
|
|
87
|
+
.describe('Full stop sequence with times, or null if includeSchedule=false.'),
|
|
88
|
+
situations: z.array(z.string()).describe('Active situation IDs affecting this trip.'),
|
|
89
|
+
}),
|
|
90
|
+
errors: [
|
|
91
|
+
{
|
|
92
|
+
reason: 'trip_not_found',
|
|
93
|
+
code: JsonRpcErrorCode.NotFound,
|
|
94
|
+
when: 'Trip ID not found or not active for the service date.',
|
|
95
|
+
recovery: 'Verify the tripId from an arrivals response; if the trip has completed, fetch the schedule instead with onebusaway_get_schedule_for_route.',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
async handler(input, ctx) {
|
|
99
|
+
const result = await getOneBusAwayService().getTrip({
|
|
100
|
+
tripId: input.tripId,
|
|
101
|
+
...(input.serviceDateMs != null && { serviceDate: input.serviceDateMs }),
|
|
102
|
+
includeSchedule: input.includeSchedule,
|
|
103
|
+
}, ctx);
|
|
104
|
+
ctx.log.info('getTrip completed', { tripId: input.tripId });
|
|
105
|
+
return result;
|
|
106
|
+
},
|
|
107
|
+
format: (result) => {
|
|
108
|
+
const s = result.status;
|
|
109
|
+
const devSecs = s.scheduleDeviation;
|
|
110
|
+
const devLabel = devSecs === 0
|
|
111
|
+
? 'on time'
|
|
112
|
+
: devSecs > 0
|
|
113
|
+
? `${Math.round(devSecs / 60)} min late`
|
|
114
|
+
: `${Math.round(Math.abs(devSecs) / 60)} min early`;
|
|
115
|
+
const lines = [
|
|
116
|
+
`## Route ${result.routeShortName} → ${result.tripHeadsign}`,
|
|
117
|
+
`**Trip ID:** ${result.tripId}`,
|
|
118
|
+
`**Phase:** ${s.phase} | **Predicted:** ${s.predicted}`,
|
|
119
|
+
`**Schedule deviation:** ${devLabel} (${s.scheduleDeviation}s)`,
|
|
120
|
+
];
|
|
121
|
+
if (s.vehicleId)
|
|
122
|
+
lines.push(`**Vehicle:** ${s.vehicleId}`);
|
|
123
|
+
if (s.position) {
|
|
124
|
+
lines.push(`**Position:** ${s.position.lat.toFixed(5)}, ${s.position.lon.toFixed(5)}`);
|
|
125
|
+
}
|
|
126
|
+
if (s.nextStop)
|
|
127
|
+
lines.push(`**Next stop:** ${s.nextStop}`);
|
|
128
|
+
if (s.closestStop)
|
|
129
|
+
lines.push(`**Closest stop:** ${s.closestStop}`);
|
|
130
|
+
lines.push(`**Last update:** ${fmtTimeMs(s.lastUpdateTime)} (${s.lastUpdateTime})`);
|
|
131
|
+
if (result.situations.length > 0) {
|
|
132
|
+
lines.push(`**Active alerts:** ${result.situations.join(', ')}`);
|
|
133
|
+
}
|
|
134
|
+
if (result.schedule && result.schedule.length > 0) {
|
|
135
|
+
lines.push('\n## Stop Sequence');
|
|
136
|
+
for (const st of result.schedule) {
|
|
137
|
+
lines.push(`- **${st.stopName}** (${st.stopId}) — arr ${fmtTimeSec(st.arrivalTime)} [${st.arrivalTime}s], dep ${fmtTimeSec(st.departureTime)} [${st.departureTime}s] | dist ${Math.round(st.distanceAlongTripMeters)}m`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
//# sourceMappingURL=get-trip.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trip.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-trip.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,yCAAyC;AACzC,SAAS,SAAS,CAAC,EAAU;IAC3B,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,C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CAAC,KAAK,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC;QAEpF,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACjC,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACjC,KAAK,CAAC,IAAI,CACR,OAAO,EAAE,CAAC,QAAQ,OAAO,EAAE,CAAC,MAAM,WAAW,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,WAAW,WAAW,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,aAAa,aAAa,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC,GAAG,CAC7M,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Real-time vehicle positions for all active vehicles for an agency.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-vehicles.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const getVehicles: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
agencyId: z.ZodString;
|
|
9
|
+
routeId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
vehicles: z.ZodArray<z.ZodObject<{
|
|
12
|
+
vehicleId: z.ZodString;
|
|
13
|
+
tripId: z.ZodNullable<z.ZodString>;
|
|
14
|
+
routeId: z.ZodNullable<z.ZodString>;
|
|
15
|
+
routeShortName: z.ZodNullable<z.ZodString>;
|
|
16
|
+
tripHeadsign: z.ZodNullable<z.ZodString>;
|
|
17
|
+
position: z.ZodObject<{
|
|
18
|
+
lat: z.ZodNumber;
|
|
19
|
+
lon: z.ZodNumber;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
lastUpdateTime: z.ZodNumber;
|
|
22
|
+
phase: z.ZodString;
|
|
23
|
+
scheduleDeviation: z.ZodNullable<z.ZodNumber>;
|
|
24
|
+
orientation: z.ZodNullable<z.ZodNumber>;
|
|
25
|
+
nextStop: z.ZodNullable<z.ZodString>;
|
|
26
|
+
predicted: z.ZodBoolean;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
}, z.core.$strip>, readonly [{
|
|
29
|
+
readonly reason: "agency_not_found";
|
|
30
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
31
|
+
readonly when: "Agency ID does not exist on this instance.";
|
|
32
|
+
readonly recovery: "Use onebusaway_list_agencies to get valid agency IDs for this instance.";
|
|
33
|
+
}]>;
|
|
34
|
+
//# sourceMappingURL=get-vehicles.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-vehicles.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-vehicles.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAYjE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GtB,CAAC"}
|