feat(mcp): a way on in a chat with no cards, a streamed or stopped call, a reply drawn from its result, a page that never speaks (#276)
Closes #276.
The server
- Answers by what the chat says it draws. MCP Apps names a chat's cards in its capabilities (
io.modelcontextprotocol/ui, withtext/html;profile=mcp-app), and protocol 2026-07-28 carries them in each request, so the stateless server knows there: to a chat with cards, the card as before; to one without, h5p-author's route 4, the whole source in one JSON block and one line with the build page's plain address ("Paste your chat's JSON"). Never a link that carries the source. On the 2025 protocols, where a chat says its capabilities once, to a server with no session, the answer says the card and, for a chat that draws none, route 4 too. - Found while testing it: Claude Code gives the model a result's
structuredContentin place of its text. In Claude Code 2.1.331, Haiku read{"files":0}fromh5p_playand nothing of the check, its outline or what to hand over, and said it could not confirm the card rendered. So the structured part now comes only with an attachment, which a card may be handed in that part alone, and it carries the text too (answer). Without an attachment there is none, and every chat shows the model the text. - The source for the card in
_meta['h5p/source'], which a chat shows the card and not the model: a card drawn from the result alone, with no input, plays all the same. The server receives the source in the call already, and still keeps nothing. - The instructions' last line: "give no link of your own, only an address h5p_play's answer gives", so a chat without cards may give the build page's.
The card
- The source being written (
tool-input-partial): "The chat is writing the activity…" / "It is built in your browser once it is written.", spinner. A part of the source is never played from. Each part starts the minute again. - A stopped call (
tool-cancelled): "The activity was not made" / "The chat stopped before it was written. Ask it again.", no spinner. - No word at all: at 6 s "Waiting for the activity…" / "The chat is still sending it.", spinner; at 60 s "No activity arrived" / "Ask the chat to show it again." Before: "No activity arrived" at 6 s, taken back when the source came.
- A word that ends the wait (stopped, nothing arrived) is as tall as what it says, as the tab state is, not the player's 16:9 place: 150 px in place of 394 px at 760 px wide.
- A page that says nothing 10 s after its frame loaded (a chat that refuses the frame without the browser saying so, a network that blocks the site): the tab state, its note "The activity did not start inside this reply. In a tab of its own it is built and played in your browser, and nothing is sent to a server." The page's first word still takes the card back.
- A result with no input plays from the result's source.
- Older browsers (Safari before 17.5, Chrome before 123, Firefox before 120): the colours follow the chat's theme by a
data-themeattribute the card writes, with the system's scheme only where the chat gives none, in place oflight-dark(); andURL.canParsereplaced bynew URLin atry.
Every state drawn in a stand-in chat at 760 px and 390 px, light and dark: no scrollbar in the card, no page error, the notes wrapped balanced and held to 46 characters a line.
Tested
app.test.ts: the answer to a 2025 client (the card and route 4), and as a chat on 2026-07-28 with cards, with none, and with cards of another kind; the structured part absent without an attachment and carrying the text with one; the source in_meta.card.test.ts: five new, the source streamed, a stopped call, a result with no input, nothing for 6 s, a page that never speaks.worker.test.ts: the Worker still answers word for word as the server on Node.- Haiku in Claude Code as a chat with MCP tools and no cards (
--tools "", the two tools only), against this branch's server, three prompts (True/False, a three-question quiz, flash cards): 3 of 3 gave a JSON block that parses, of the right type, with the build page's plain address and "Paste your chat's JSON", no link with the source, and no word of a card. Before the structured-part change, the two runs that called the tool said they could not confirm the card rendered.
cubic's review: three points, fixed in 29706e7 (the README's sentence on the tab, the design file's Haiku runs stated in it, the colours by the chat's theme in any browser); a fourth, the browsers named by version, in 234a51b.
Only you can check, after the Worker is deployed
- ChatGPT: the reply does not add the JSON block and the build page's line. Its answer says both where ChatGPT does not say what it draws, so this is the one place it could.
- Claude: the reply now reads what the activity holds back to you (it read
{"files":0}before, if Claude does as Claude Code does).
Paired with missing-elements/missing-elements.github.io#117, the play page's own way on (no worker, storage refused, no secure context). Neither needs the other.
Not here: links inside an activity. The card opens only the site's own addresses (design/mcp.md), and opening any other is your decision.
Summary by cubic
Answers a chat that draws no card with the build page's way on, and covers the card's states before an activity comes or where it cannot start.
Server
- A chat that says what it draws (protocol 2026-07-28) gets the card, or, where it draws none, route 4: the whole source in one JSON block and the build page's plain address, with the 2025 protocols told both.
- The structured part comes only with an attachment — a chat may show the model that part alone (Claude Code 2.1.331 gave Haiku
{"files":0}) — and then carries the text too. - The source goes to the card in
_meta['h5p/source'], so a reply drawn from the result alone, with no input, plays all the same; nothing of it is kept.
Card
- Says "The chat is writing the activity…" while the source streams, never plays from a part, says a stopped call was not made, at 6 s that it waits, at a minute that nothing came.
- Offers the tab where a page says nothing 10 s after its frame loaded: "The activity did not start inside this reply."
- Falls back for browsers before 2024 with theme colours by a
data-themeattribute in place oflight-dark(), andnew URLin atryin place ofURL.canParse.
Tests cover the new server answers and five new card states; Haiku as a chat with no cards handed over valid JSON in 3 of 3 prompts. After the Worker is deployed, check ChatGPT (reply should not add the JSON block and build line) and Claude (should read what the activity holds back, not {"files":0}), since only those chats can confirm it.