fix(mcp-app): h5p_play takes the source as text from a chat that drops its fields

Merged
AL
8h ago
+108-5

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 of source. It is shown as a string and not enforced, as files is, so a chat that fills it with nothing, null or anything that is not text is answered as before.
    • A refusal for a source that came as source with neither type nor title adds one line: call again with the source in sourceJson, and {} as source. Nothing else names sourceJson, so a chat that sends source whole 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 _meta carries the source that was checked, so a card plays the text's.
  • design/mcp.md: the rule A chat that drops fields of source sends the source as text.
  • The card is unchanged. It plays a call's source only where that has a type, and otherwise the result's.

Verification

  • pnpm test in packages/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 main and on this branch (instructions, both tools, the card's address), compared as JSON: one difference, the sourceJson property.

  • Gemini's call, as it showed it, against this branch: without type and title, the two problems and the new line; retried with sourceJson, 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 sourceJson input whose text is read in place of source, but only where source came with no type, matching what the card plays.
  • A refusal for a source missing both type and title tells the chat to resend it in sourceJson with {} as source.
  • Chats that send source whole are unaffected, and text that isn't a source is refused in the server's own words.