From d110e29fd8121bf3bd79ddb7c6363a029eebedeb Mon Sep 17 00:00:00 2001 From: Aleksandr Shevchuk Date: Wed, 25 Nov 2026 11:40:28 +0200 Subject: [PATCH 1/3] 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; the structured part only with an attachment, since a chat may show the model it alone (#276) --- design/mcp.md | 40 ++++++++++++++-- packages/mcp/README.md | 10 ++-- packages/mcp/lib/app.mjs | 56 +++++++++++++++++++--- packages/mcp/lib/card.html | 84 +++++++++++++++++++++++++++------ packages/mcp/tests/app.test.ts | 49 +++++++++++++++++-- packages/mcp/tests/card.test.ts | 72 ++++++++++++++++++++++++++-- 6 files changed, 278 insertions(+), 33 deletions(-) diff --git a/design/mcp.md b/design/mcp.md index c93ae07..250d19b 100644 --- a/design/mcp.md +++ b/design/mcp.md @@ -108,6 +108,21 @@ command is that handler on a port. Its endpoint is `/mcp`. as it is and not to open it: a reply that began with the chat's own analysis of the file drew no card, twice, and without it the card came (ChatGPT, 2026-11-23 and 11-24; one cause is not proven). +- **The model's words are in the answer's text, and its structured part comes only with an + attachment, carrying them too** (#276). A chat may give the model the structured part in place + of the text: Claude Code 2.1.331 gave Haiku `{"files":0}` and no word of the check, its + outline or what to hand over (2026-11-25). The structured part is there for a card that is + handed only it, with the attachment's id, which the card also gets in `_meta`. +- **A chat that draws no card is told to hand the source to the build page, by what it says it + draws** (#276). MCP Apps names a chat's cards in its capabilities (`io.modelcontextprotocol/ui`, + with `text/html;profile=mcp-app`). Protocol 2026-07-28 carries them in each request, so there + the answer is one or the other: the card, or h5p-author's route 4, the whole source in one + JSON block and one line with the build page's plain address. A chat on the 2025 protocols says + them once, as it starts, to a server that keeps no session, so its answer says the card and, + for a chat that draws none, route 4 too. Never a link that carries the source: a model breaks + one by a character (the owner, 2026-11-16). The instructions let a model give only an address + the answer gives. Haiku as such a chat, Claude Code with the two tools and nothing else: see + the PR of #276. - **The file input is ChatGPT's, to the letter, and not held to.** `file` is named in `openai/fileParams` and its schema is the reference's: `download_url` and `file_id` required, `mime_type` and `file_name`, nothing else. It is shown and not enforced, as `source` is: a @@ -120,7 +135,9 @@ command is that handler on a port. Its endpoint is `/mcp`. what only the chat has, by the page's messages: the attached file's address, asked of the chat by the file's id, and what it weighs, its bytes where the page needs them or that they did not come, the chat's theme, a save (`ui/download-file`), and an open tab for a link of the site's - and no other (`openExternal`). It sends nothing to the server it came from and calls no tool. Its policy + and no other (`openExternal`). The answer carries the source for it in `_meta`, which a chat + shows the card and not the model, so a card drawn from the result alone, with no input, plays + all the same (#276). It sends nothing to the server it came from and calls no tool. Its policy names the one site it frames and the chat's file store. A chat keeps a card by its address, so the address carries the card's hash. - **Where the page cannot play in the card's frame, the card offers the activity in a tab, and @@ -137,11 +154,23 @@ command is that handler on a port. Its endpoint is `/mcp`. would keep the card's sandbox and have no origin either (probed in Chromium, Firefox and WebKit, 2026-11-25). Whether a tab opened is not the card's to see, so the address is there to copy from the first press on, and at once in a chat - that opens no link. The page's own word from the frame takes the card back: a wrong conclusion - never hides a player that works. The chat's theme is ChatGPT's `window.openai.theme` or MCP + that opens no link. A page that has said nothing 10 s after its frame loaded did not start + there, refused without the browser saying so or blocked by a network, and the card offers the + tab too, saying the activity did not start in the reply (#276): the page speaks within a moment + of its load. The page's own word from the frame takes the card back: a wrong conclusion + never hides a player that works. Where the page starts in the frame and the player then cannot, + the page offers the tab itself (the site's #116). The chat's theme is ChatGPT's `window.openai.theme` or MCP Apps' `hostContext.theme`. In Claude the tab was seen to work (the owner, 2026-11-25). Not known: Open WebUI itself, which the card met only as a stand-in. A player without the Service Worker is not built for such a chat ([scope.md](scope.md)). +- **Until the activity comes, the card says what the chat is doing** (#276). A chat may draw the + card while its model still writes the source, which takes longer than a moment for a long one: + where it says so as it goes (`tool-input-partial`), the card says the chat is writing it, and + never plays from a part. A call the chat stopped (`tool-cancelled`) is said. With no word at + all, it says at 6 s that it waits, and at a minute that nothing came: before, it said at 6 s + that nothing came and took it back when the source did. A word that ends the wait is as tall + as what it says. Its colours are plain in a browser from before 2024, which has no + `light-dark()`, and nothing asks for `URL.canParse`. - **What ChatGPT's frame was found to do is written in the card, with its date.** A card's frame saves no file and opens no tab on a press; the chat saves a file handed to it of 8 MB and refuses one of 16 MB, downloads from no address, and takes no package into its own files; its @@ -155,7 +184,10 @@ command is that handler on a port. Its endpoint is `/mcp`. `tests/card.test.ts` runs the card in a browser, the verifier's, in three chats that stand in for the ones it was written against: one that sandboxes it without an origin, under the policy Open WebUI writes from the card's domains; one that refuses the frame; one that lets the page - be framed. Each speaks MCP Apps to it, and the play page there says its height and no more. + be framed. Each speaks MCP Apps to it, and the play page there says its height and no more: + the source streamed, a stopped call, a result with no input, nothing for a while, and a page + that never speaks. `app.test.ts` asks as a chat on protocol 2026-07-28 too, with and without + cards. With the site's own play page the card is checked by hand in a page that stands in for a chat, its frame sandboxed as ChatGPT's was found to be; in ChatGPT itself ran the probe's card, which this one is without its test parts. diff --git a/packages/mcp/README.md b/packages/mcp/README.md index 989c6b4..0dd4913 100644 --- a/packages/mcp/README.md +++ b/packages/mcp/README.md @@ -79,12 +79,16 @@ which checks an activity's source and shows the card. The card frames the play p [missing-elements.github.io](https://missing-elements.github.io/h5p/), which builds the activity in the person's browser and plays it there. In a chat app that does not let a card frame a page, or gives the card no origin of its own, the card asks the chat to open the same page in a new tab -instead, and shows the page's link to copy in case none opens. +instead, and shows the page's link to copy in case none opens; so it does where the page does not +start in the frame. A chat that draws no card is answered with the way to the +[build page](https://missing-elements.github.io/h5p/build/) instead: the model gives the source, +and the person pastes it there. Where the chat says what it draws, as on protocol 2026-07-28, the +answer is one or the other; where it does not, the answer says both. What the server receives, and what it keeps: -- A call of `h5p_play` brings it the activity's source, which it checks. A call of `h5p_types` - brings it the name of a content type, or nothing. +- A call of `h5p_play` brings it the activity's source, which it checks, and gives back in its + answer for the card. A call of `h5p_types` brings it the name of a content type, or nothing. - It never receives a file. For a file attached in the chat, the chat sends a reference, an address and an id. The server does not ask that address and does not pass it on: it hands the id to the card, which asks the chat for the file's address, and the person's browser fetches diff --git a/packages/mcp/lib/app.mjs b/packages/mcp/lib/app.mjs index 884ff45..63738ee 100644 --- a/packages/mcp/lib/app.mjs +++ b/packages/mcp/lib/app.mjs @@ -40,7 +40,7 @@ const INSTRUCTIONS = `Makes an H5P activity and plays it in the chat, built in t 3. Call h5p_play with the source. Where it lists problems, fix each at its path and call it again. A file the person attached (a video, a recording, a picture): name it in the source by its file name, and pass the attachment in file. Do not open, read or analyse it yourself, with code or otherwise: pass it as it is, since nothing here needs what is in it. The author and the licence are what the person gave; otherwise the name you know them by, or "Unknown", and the licence "U". -The card has the download of the .h5p file: do not offer a link of your own.` +The card has the download of the .h5p file: give no link of your own, only an address h5p_play's answer gives.` const PLAY = `Checks an H5P activity's source and plays the activity in the chat, built in the person's browser, with a download of the .h5p file. The source is as h5p_types describes it for its type, its params holding only what differs from the type's defaults. A source with problems is refused, each problem named by its path. Nothing is stored.` @@ -58,6 +58,33 @@ const FILE = { additionalProperties: false } +/** MCP Apps' name for a chat's cards, and the kind of card this server's is. */ +const UI = 'io.modelcontextprotocol/ui' +const CARD_TYPE = 'text/html;profile=mcp-app' + +/** + * Whether the chat draws this server's card, as it says (#276): true or false where it says, as on + * protocol 2026-07-28, which carries the client's capabilities in each request; null where it says + * nothing here, as a chat on the 2025 protocols, which says them once as it starts, to a server + * that keeps no session. + * @param {unknown} capabilities + * @returns {boolean | null} + */ +function drawsCards(capabilities) { + if (!capabilities || typeof capabilities !== 'object') return null + const ui = /** @type {{ extensions?: Record }} */ (capabilities).extensions?.[UI] + return Array.isArray(ui?.mimeTypes) && ui.mimeTypes.includes(CARD_TYPE) +} + +/** + * What a chat that draws no card hands over in its place (#276): h5p-author's route 4, the whole + * source and the build page's plain address. Never a link that carries the source, which breaks + * where a model writes one character of it wrong (the owner, 2026-11-16). + * @param {string} site + * @param {number} files how many files the source names, which the page asks the person for + */ +const handOver = (site, files) => `hand the activity over to be built in the person's browser: the whole source, once, in one json code block, and one line telling them to copy it, open ${site}/h5p/build/, choose "Paste your chat's JSON", paste it into the box in place of the sample's, and press Build.${files ? ' Add that the page asks for the files the source names before it builds.' : ''} Give the page's address as it is, with nothing after it.` + /** Where a chat keeps attached files, which the card asks from the person's browser: ChatGPT's, as seen in November 2026. */ const FILE_HOSTS = ['https://*.blob.core.windows.net', 'https://files.oaiusercontent.com', 'https://*.oaiusercontent.com'] @@ -142,7 +169,18 @@ export async function createApp(options = {}) { const came = attached(file) // An attachment goes to the card only for a source that names a file: one it does not name is not used. const given = files.length ? came : null - const lines = [`The activity is checked and plays in the card: ${result.manifest.mainLibrary}, ${result.libraries.length} libraries. It is built in the person's browser; nothing was stored.`] + const cards = drawsCards(mcp.server.getClientCapabilities()) + const what = `${result.manifest.mainLibrary}, ${result.libraries.length} libraries` + if (cards === false) { + // No card comes: the source, to the build page. + const lines = [`The activity is checked: ${what}. Nothing was stored. This chat draws no card, so ${handOver(site, files.length)}`] + if (files.length) lines.push(`Its file${files.length === 1 ? '' : 's'}, ${files.join(', ')}, ${files.length === 1 ? 'is' : 'are'} not checked here.`) + lines.push(...heldLines(result)) + return answer(lines.join('\n')) + } + const lines = [`The activity is checked and plays in the card: ${what}. It is built in the person's browser; nothing was stored.`] + // A chat that did not say whether it draws cards: the way where it draws none, too. + if (cards === null) lines.push(`Where this chat draws no card, as a terminal or an editor's chat draws none, ${handOver(site, files.length)}`) if (files.length) { lines.push(given ? `Its file${files.length === 1 ? '' : 's'}, ${files.join(', ')}, ${files.length === 1 ? 'is' : 'are'} not checked here: the card gets the attachment in the person's browser${files.length === 1 ? '' : ', and asks the person for any other'}.` @@ -151,11 +189,17 @@ export async function createApp(options = {}) { lines.push('An attachment came with the call, and the source names no file, so it is not used: name it in the source, as the type\'s notes say, to use it.') } lines.push(...heldLines(result)) + const text = lines.join('\n') return { - ...answer(lines.join('\n')), - structuredContent: { files: files.length, ...(given ? { fileId: given.file_id } : {}), ...(given?.file_name ? { fileName: given.file_name } : {}) }, - // For the card, as a chat hands a card either part of an answer. - ...(given ? { _meta: { 'h5p/file': given } } : {}) + ...answer(text), + // The attachment's id for the card, where one came, in both parts of an answer a chat may + // hand a card. Not otherwise: a chat may give the model this part in place of the text + // (Claude Code 2.1.331 gave Haiku `{"files":0}` and no word of the check, 2026-11-25, + // #276), so it carries the text too. + ...(given ? { structuredContent: { answer: text, files: files.length, fileId: given.file_id, ...(given.file_name ? { fileName: given.file_name } : {}) } } : {}), + // And the source, which a card drawn from the result alone, with no input, plays from + // (#276). Shown to the card, not the model. It came in the call; nothing of it is kept. + _meta: { 'h5p/source': source, ...(given ? { 'h5p/file': given } : {}) } } }) diff --git a/packages/mcp/lib/card.html b/packages/mcp/lib/card.html index 88d35e5..76973ce 100644 --- a/packages/mcp/lib/card.html +++ b/packages/mcp/lib/card.html @@ -5,7 +5,13 @@ H5P activity