get_departures
Retrieve real-time departure information for a specific stop in Berlin's public transport system, including the number of results desired. Powered by the Berlin Transport MCP Server and VBB API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| results | No | Number of results to return | |
| stop_id | Yes | Stop ID to get departures for |
Implementation Reference
- src/index.ts:42-53 (handler)Handler function that constructs the VBB API URL for departures at the specified stop, optionally limits results, fetches the data, and returns it as JSON string in MCP content format.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 input schema defining required 'stop_id' string parameter and optional 'results' number parameter.{ 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(), including name, input schema, and handler function."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) }], }; } );