LabscoMCP early access ↗
harshil1712MCP SERVER

Berlin Transport

Berlin and Brandenburg public transport for an agent — stops, live departures and journey options — behind two tools instead of one per endpoint.

by harshil1712 ↗Travel Booking, Transit & NavigationCommunity

LABSCO SUMMARY

A working example of two tools beating twenty.

The Code Mode pattern is the reason to look at this even if you never take a Berlin tram: the model gets the API spec on demand instead of every schema up front, and a two-step lookup happens inside one sandbox run. The repository is explicit that swapping the spec and the origin points it at a different API, so it doubles as a template.

What it is

A Cloudflare Worker that wraps the VBB transport API. It uses Code Mode: rather than registering a tool per API operation, it describes the API as an OpenAPI spec and exposes two tools — the model reads the spec, then writes a short JavaScript snippet that runs in a sandboxed Dynamic Worker and chains several calls in one go.

What you get

  • search — read the OpenAPI spec to find the operation, its parameters and the shape of what comes back
  • execute — run an async JavaScript snippet calling codemode.request({ method, path, query }); the host proxies the HTTP call, and the sandbox has no direct network access of its own
  • Three underlying operations the spec exposes: getLocations for stops, stations, addresses and points of interest; getDepartures for what is leaving a stop next; getJourneys for routes between two places
  • Chaining in a single sandbox run — find the stop, then fetch its departures, without a round trip back to the model in between

Requirements

No account and no key for the transport data itself. npm install then npm run dev gives a local server at http://localhost:8787/mcp; npm run deploy publishes the Worker to your own workers.dev subdomain, which needs a Cloudflare account. Clients that speak remote MCP connect to the URL directly; Claude Desktop reaches it through npx mcp-remote with the URL as the argument. To wrap a different API instead, change API_ORIGIN and the OpenAPI spec in src/index.ts.

Setup effort

Paste a URL — add the endpoint to your client