Skip to main content
Glama
harshil1712

Berlin Transport MCP Server

by harshil1712

get_departures

Retrieve real-time departure information for Berlin public transport stops to plan journeys and check upcoming services.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stop_idYesStop ID to get departures for
resultsNoNumber of results to return

Implementation Reference

  • 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) }],
      };
    }
  • 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) }],
        };
      }
    );
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/harshil1712/berlin-transport-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server