Inspiration

I wanted to merge and upgrade my five classic Alexa skills for London transport: London Bus, Underground, Tram, DLR and Train Times. They were built on the old, restrictive speech model, where every station had to come from a fixed list and every reply was scripted in advance in SSML. This breaks away from that as one voice-first MCP server, with tools shaped around what people ask rather than a thin wrapper over TfL's API.


What it does

London Transport Desk gives live departures for the Underground, Overground, Elizabeth line, DLR, trams and buses; line status for those, plus the river bus, the Woolwich Ferry and the cable car; and where to get off for 223 landmarks. The data comes from Transport for London (TfL), the city's transport authority.

TfL's API answers to stop ids. People say names, and mishear them, and many names belong to more than one place. This works out which of 456 stations, 13,864 bus stops and 223 landmarks was meant, and when it can't tell, it asks which. The choices travel in the answer, so nothing is held between turns. Each answer also joins what TfL keeps apart: departures come with the disruptions on those lines, and a landmark comes with its nearest stations and whether their lines are running.

  • It takes the name the user says. Speech recognition mishears: "ho burn" for Holborn, "mud shoot" for Mudchute. Numbers arrive as words, so a stop is "Heathrow Terminal five". Matching runs exact, then whole-word, then letter-pair similarity, and asks where a match is close but uncertain.
  • It thinks in places, not modes. The five classic skills split London by transport type. Here one name means everything stopping there, so Bank answers for the Tube and the DLR together.
  • It never guesses when a bus stop's name is shared. Sometimes that is a pair: two bus stops facing each other across a road are one place with one name in TfL's data, but different places to stand. Sometimes it is coincidence: unrelated bus stops elsewhere in London share the same name outright. Either way it answers about exactly one bus stop, and where the name alone doesn't say which, it asks using the stop signage ("stop SM") or where the buses go.

It stores nothing about anyone: no saved stops, no location, no account linking, no user id. That keeps it outside GDPR. It has no notion of a usual stop or of where the user is: it answers for whatever name it is given. "Near me" is not supported.


How I built it

  • Runtime: one AWS Lambda, Node 24, arm64, behind a Function URL, deployed with SAM.
  • MCP: @modelcontextprotocol/sdk v1 in its stateless pattern. A fresh server and transport per request, enableJsonResponse: true, protocol 2025-11-25. Hono routes /mcp and runs the same app locally. The SDK is imported and called in src/mcp/createServer.js and src/app.js.
  • Data: 456 station places, 13,864 bus stops, 223 landmarks, generated at build time and shipped with the function. Resolving one landmark name live measured 378 to 1937 ms against a 500 ms budget, so none of it happens during a request.
  • Latency: arrivals cached around 20 s, status around 60 s, retries bounded by time remaining rather than a count, one warm-up call at init.
  • Built with Claude Code, across many sessions. SPEC.md and AGENTS.md live in the repo and carry the design and the house style from one session to the next.
  • Tested three ways. Over 200 unit tests under node:test against recorded TfL responses, with the network blocked. An automated rig that drives the deployed server from separate agent sessions: 26 deterministic response checks, 10 single-turn cases and 4 two-turn cases, each turn a fresh session rather than a resumed one, so the client has to answer from the tool payload instead of remembering it. Then manual conversation, which is what found most of the interaction faults.
  • CI: lint and tests gate every push. Main deploys.

Shipped in stages, each working end to end before the next: Tube; DLR and trams; Overground and Elizabeth line; buses; boats and cable car; landmarks.


Challenges I ran into

Understanding what people say

  • Disambiguation. One spoken name has to resolve across 456 stations, 13,864 bus stops and 223 landmarks, whose names overlap. "Park Road" alone names fourteen different stops, "Station Road" six. Short names sit inside longer ones too: "Bank" matched nine stops, three of which (Thames Bank, Laurel Bank Road, Waterloo Bridge / South Bank) have nothing to do with the station. The ladder is exact match, then whole-word containment, then similarity, then a question that distinguishes by something the user would know: the code on the sign, or where the buses go. An exact station name answers from that station's own stops, which fixed Bank without letting a made-up "Harlesden Bank" borrow it.
  • Clarifying across turns with no server memory. The server is stateless by design: a fresh McpServer per request, no session id, nothing held between calls. So when a name is ambiguous, the whole state of the conversation has to travel in the response and come back in the next call, rather than living on the server. A needs_clarification result carries every candidate with its own id; the tool description tells the model to ask the question and call again with the id the user picked. Proving this actually works meant a test rig where each turn of a conversation is its own fresh agent session, never resumed, so a pass can only mean the client read the id back correctly rather than remembered it.
  • Writing the tool descriptions so the agent does the right thing. It took several rounds. One version let a client offer five identically named stops as a choice with nothing to tell them apart. Descriptions now state the vocabulary, when to ask, and what not to do: get_nearest_stops says outright that it gives no departure times, because the user is going there rather than leaving from there.
  • Abbreviations and the names people actually use. TfL truncates stop names to 40 characters, so "Bethnal Grn Rd / Shoreditch High St Stn" is what both the stop data and the live predictions carry, and it writes initialisms both ways, "Tottenham Lane Ymca" and "Tottenham Lane Y M C A", which would otherwise make one stop two. "St" means Saint before a name and Street after one, so it has to be resolved by position, not by a word list. Spoken numbers have to match written ones, so "Heathrow Terminal five" finds Heathrow Airport Terminal 5. On top of that sit the names nobody official uses: T.C.R., Olympia, Camden, Battersea, the Lizzie line. I found most of these by voice testing the classic skills myself, and those seventy aliases carry over as exact entries that outrank fuzzy matching.

From a machine-to-machine API to a spoken answer

TfL's API is built for machine interoperability: stops keyed by national NaPTAN codes, line ids, and raw arrival predictions, for software that already knows exactly which id it wants. It was never meant for a conversation without a screen, where someone says a name, perhaps misheard, and expects one answer read aloud. Bridging the two is the work of this project. The API gives no warning of the problems below, and if left alone, each would reach the listener as a wrong answer or as silence.

  • TfL predicts arrivals, never departures. At a terminus there is nothing onward to show, and read aloud that silence sounds like the line is down, so the tool says outright that the station is a terminus. Getting the detection right took live testing: Battersea proved that "every prediction terminates" is the wrong check, and "at least one terminates" is the rule that holds.
  • TfL has no endpoint for "where is this place". The closest thing is its journey planner, meant for planning a trip from A to B, asked instead to place a single landmark by name. It answers confidently and sometimes wrongly: Soho in Barnet, the Royal Festival Hall at the Royal Albert Hall, Fortnum & Mason at Bank. A tool that resolves at request time hands a wrong answer straight to the user with nothing to catch it. Here resolution happens at build time instead, and twenty of 223 landmarks needed correcting by hand before any could go in a spoken answer.
  • An id an LLM remembers is not the same as an id the API still accepts. The Overground split into six named lines in November 2024; an old line id still returns HTTP 200 with nothing in it. A tool built from a model's memory of the API produces an empty answer that a voice client speaks as "nothing due" rather than an error, and the two sound identical to the person listening.
  • A station name arrives as free text, with nothing to check it against. The classic skills constrained speech to a closed list of values (Alexa's "slots"); an MCP tool takes a plain string and has to work out for itself how near a miss is close enough to act on. "holburn" scores 0.73 against Holborn with Kilburn at 0.67, close enough to ask and not to assume. Those thresholds, and seventy alias entries, are what five classic skills learned from years of real voice traffic, carried into tools that had none of that history.
  • An incomplete tool result gets filled in. Testing from a separate agent session produced "route 2, towards West Norwood, passes through Brixton"; West Norwood was in no tool response. A voice client under pressure to answer will complete a gap from its own knowledge rather than say nothing, so a tool result has to leave no gap to complete.
  • The tool description is the only interface a voice client has to the tool's own rules, and it gets spoken. One version was recited to the user as the answer: "I have nothing for the other side of the road."

Accomplishments I'm proud of

The interaction model. It resolves what someone says across 456 stations, 13,864 bus stops and 223 landmarks. Names repeat and contain each other: fourteen stops are called Park Road, and "Bank" is part of Thames Bank and South Bank as well as being a station. Where a name still fits more than one place, it asks about something the user would know, such as where their bus is going or the letter on the stop's sign.

Five classic Alexa skills became one service. They had a rigid model: a closed list of station values, an intent and slot per question, and speech responses written in advance. Here the name arrives as free text, and the answer is shaped from what TfL returns.

Knowing which of TfL's answers to reject. TfL does not flag its own mistakes: ask where Soho is and it replies with a place in Barnet, miles north, as a normal success. So a landmark is accepted only if TfL's reply shares a real word with the name asked.


What I learned

MCP itself, and the SDK's stateless pattern in particular.

A tool description is interface copy as much as documentation: it steers the agent directly, and a client may read it out to the user as the answer.

Unit tests cannot tell whether a client will reach for a tool, or what it will do with the answer. Mine stayed green while a clarification offered three landmark names that told a listener nothing. That turned up only by asking out loud and reading what came back. An automated rig driving the MCP server would not have caught it, because the fix was prose: the wording of the clarification. Judging that needs a person.


What's next for London Transport Desk

Becoming a concierge desk for London, not only its transport: what's on right now, with recommendations; booking shows, events and gigs; and ordering a taxi when the train won't do.

For production, OAuth 2.1 with PKCE: proving a call came through Alexa without identifying the user, so the no-personal-data position survives launch.

Built With

Share this project:

Updates

Submission history