Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/services/RoutesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const COMPUTE_ROUTES_FIELD_MASK = [
"routes.legs.steps.staticDuration",
"routes.legs.steps.startLocation",
"routes.legs.steps.endLocation",
"routes.legs.steps.transitDetails",
"routes.legs.polyline",
"routes.optimizedIntermediateWaypointIndex",
].join(",");
Expand Down
5 changes: 4 additions & 1 deletion src/tools/maps/directions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const SCHEMA = {
.describe("Travel mode for directions"),
departure_time: z.string().optional().describe("Departure time (ISO string format)"),
arrival_time: z.string().optional().describe("Arrival time (ISO string format)"),
avoid_tolls: z.boolean().optional().describe('Avoid toll roads where reasonable. Only supported with mode "driving".'),
avoid_tolls: z
.boolean()
.optional()
.describe('Avoid toll roads where reasonable. Only supported with mode "driving".'),
avoid_highways: z
.boolean()
.optional()
Expand Down
5 changes: 4 additions & 1 deletion src/tools/maps/distanceMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const SCHEMA = {
.describe(
"Departure time in ISO 8601 format (e.g. 2026-03-21T09:00:00Z). Enables traffic-aware duration estimates."
),
avoid_tolls: z.boolean().optional().describe('Avoid toll roads where reasonable. Only supported with mode "driving".'),
avoid_tolls: z
.boolean()
.optional()
.describe('Avoid toll roads where reasonable. Only supported with mode "driving".'),
avoid_highways: z
.boolean()
.optional()
Expand Down
5 changes: 4 additions & 1 deletion src/tools/maps/planRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const SCHEMA = {
.string()
.optional()
.describe("Departure time in ISO 8601 format (e.g. 2026-03-21T09:00:00Z). Enables traffic-aware routing."),
avoid_tolls: z.boolean().optional().describe('Avoid toll roads where reasonable. Only supported with mode "driving".'),
avoid_tolls: z
.boolean()
.optional()
.describe('Avoid toll roads where reasonable. Only supported with mode "driving".'),
avoid_highways: z
.boolean()
.optional()
Expand Down
46 changes: 46 additions & 0 deletions tests/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,51 @@ async function testTransitErrorMessages(session: McpSession): Promise<void> {
}
}

async function testTransitDetailsField(session: McpSession): Promise<void> {
if (!API_KEY) {
console.log(" ⏭️ Skipped transitDetails test (no GOOGLE_MAPS_API_KEY)");
return;
}

console.log("\n🔍 Testing transit step includes transitDetails (field mask)...");

// Dublin Airport → city centre: virtually always returns a bus step (issue #78 scope).
const result = await sendRequest(session, "tools/call", {
name: "maps_directions",
arguments: {
origin: "Dublin Airport, Ireland",
destination: "Trinity College Dublin, Ireland",
mode: "transit",
},
});
const content = result?.result?.content ?? [];
assert(content.length > 0, "Transit directions in Dublin returns content");
if (content.length === 0) return;

const text = content[0]?.text ?? "";
const isError = result?.result?.isError === true;
assert(!isError, `Transit directions in Dublin should succeed, got error: ${text.slice(0, 200)}`);
if (isError) return;

const parsed = JSON.parse(text);
const steps: any[] = parsed?.routes?.[0]?.legs?.flatMap((l: any) => l.steps ?? []) ?? [];
assert(steps.length > 0, "Transit response has at least one step");

const transitStep = steps.find((s: any) => s.transitDetails);
if (!transitStep) {
// Routes API may rarely return a walking-only itinerary; warn but don't flaky-fail.
console.log(" ⚠️ No transit step in this itinerary — field mask correctness cannot be asserted this run");
return;
}

const td = transitStep.transitDetails;
assert(
td?.transitLine || td?.stopDetails,
"transitDetails contains structured transit metadata (transitLine or stopDetails)",
`got: ${JSON.stringify(td).slice(0, 200)}`
);
}

// --------------- Main ---------------

async function main() {
Expand All @@ -1127,6 +1172,7 @@ async function main() {
await testToolCalls(session);
await testPlaceDetailsPhotos(session);
await testTransitErrorMessages(session);
await testTransitDetailsField(session);
await testMultiSession();
} catch (err) {
console.error("\n💥 Fatal error:", err);
Expand Down
Loading