get_departures
Retrieve real-time departure information for Berlin public transport stops to plan journeys and check upcoming services.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stop_id | Yes | Stop ID to get departures for | |
| results | No | Number of results to return |
Implementation Reference
- src/index.ts:42-53 (handler)Handler function that fetches departures from the VBB Transport API for a given stop ID, optionally limiting the number of results, and returns the JSON data as text content.async ({ stop_id, results }) => { const url = new URL(`/stops/${stop_id}/departures`, VBB_API_BASE); if (results) { url.searchParams.set("results", String(results)); } const response = await fetch(url); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; }
- src/index.ts:38-41 (schema)Zod schema defining the input parameters for the get_departures tool: required stop_id (string) and optional results (number).{ stop_id: z.string().describe("Stop ID to get departures for"), results: z.number().optional().describe("Number of results to return"), },
- src/index.ts:37-54 (registration)Registration of the get_departures tool on the MCP server using this.server.tool(name, schema, handler)."get_departures", { stop_id: z.string().describe("Stop ID to get departures for"), results: z.number().optional().describe("Number of results to return"), }, async ({ stop_id, results }) => { const url = new URL(`/stops/${stop_id}/departures`, VBB_API_BASE); if (results) { url.searchParams.set("results", String(results)); } const response = await fetch(url); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }], }; } );