fix(mcp-app): h5p_play takes the source as text from a chat that drops its fields
Summary
Closes #346. Gemini's web app called h5p_play with a source whose type and title did not reach the server, though its call showed both, and the model could not get past the refusal (2026-12-03). h5p_play now takes the whole source as JSON text too, in sourceJson, and the refusal for a source that came with neither field says to use it.
A chat that plays today is not touched: source and its schema, files, what is required, both descriptions, the instructions and the card's address are the same, byte for byte. The one difference in what the server lists is the new optional input.
Changes
packages/mcp-app/lib/app.mjs:sourceJson, optional: the whole source as JSON text, read in place ofsource. It is shown as a string and not enforced, asfilesis, so a chat that fills it with nothing,nullor anything that is not text is answered as before.- A refusal for a source that came as
sourcewith neithertypenortitleadds one line: call again with the source insourceJson, and{}assource. Nothing else namessourceJson, so a chat that sendssourcewhole never writes a source twice. - Text that is no source is refused in the server's own words, since a parser's message quotes what it read. A call's arguments written whole,
{"source": {…}}, are read as the source in them. - The answer's
_metacarries the source that was checked, so a card plays the text's.
design/mcp.md: the rule A chat that drops fields ofsourcesends the source as text.- The card is unchanged. It plays a call's
sourceonly where that has atype, and otherwise the result's.
Verification
-
pnpm testinpackages/mcp-app: 3 files, 37 passed. New: the server case (the source as Gemini sent it, the retry with{}and with the dropped source, text that is no source, an input filled with nothing) and a card case (input with{}and the text, then the result). -
What the server lists on
mainand on this branch (instructions, both tools, the card's address), compared as JSON: one difference, thesourceJsonproperty. -
Gemini's call, as it showed it, against this branch: without
typeandtitle, the two problems and the new line; retried withsourceJson, the check goes on to the params and names five problems there by their paths, as it does for the same source sent whole. -
pnpm --filter @missing-elements/h5p-mcp-app typecheck,pnpm lint,node scripts/comments.mjs: pass. -
Not checked: Gemini itself, which needs a release and a deployed server.
-
Tests added or updated where behavior changed
-
Documentation updated where public behavior or deployment changed
-
Relevant type checks, tests, and builds pass
-
No security-sensitive details or credentials are included
Screenshots or reproduction
Call h5p_play with { "source": { "language": "en", "license": "U", "authors": [{ "name": "Unknown", "role": "Author" }], "params": {} } }: the refusal names type and title, and says to send the source in sourceJson. Call again with { "source": {}, "sourceJson": "<the whole source as JSON text>" }: it is checked and played as the same source sent in source is.
Summary by cubic
Fixes h5p_play refusing sources whose fields Gemini's web app drops on the way, by accepting the whole source as JSON text.
- Adds an optional
sourceJsoninput whose text is read in place ofsource, but only wheresourcecame with notype, matching what the card plays. - A refusal for a source missing both
typeandtitletells the chat to resend it insourceJsonwith{}assource. - Chats that send
sourcewhole are unaffected, and text that isn't a source is refused in the server's own words.