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.
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.
- `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
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`.
One command — npx mcp-remote https://berlin-transport.mcp-tools.app/sse
