fix(mcp): an earlier card's address gets the current card (#278)

Merged
AL
10h ago
+25-4

Closes #278.

After #277 was deployed, Grok could not load the app: "read-resource failed: 400". The card's address carries its hash, #277 changed the card, and the server answered only the new address: the earlier one, card-df8ccbdd2aa8.html, got "Resource not found" on mcp.embed-my.org. Grok had kept the tool list, or the reply, from before. ChatGPT keeps the card it fetched, so its old replies played on.

The fix: an earlier card's address, ui://h5p-play/card- and twelve hex digits, gets the current card, with the same policy, as a resource template that is not listed. The card plays what an earlier one was handed (the same tool input, and the result's _meta). The address still changes with the card, so a chat that keeps cards by address fetches a changed one as before. Any other name under card- is still not found.

Tested: app.test.ts reads the pre-#277 address and gets the current card, its text and policy, under the address asked; refuses card-latest.html; lists one card. worker.test.ts reads the earlier address from the Worker in the Workers runtime. Both packages' typecheck passes.

After merge: deploy the Worker again. Grok's old tool list then loads the app; reconnecting the app in Grok does the same now, before the deploy.


Summary by cubic

Fixes the failure after #277 where chats that kept an earlier card address (like Grok) got a 400 on read. Now an earlier card's address (ui://h5p-play/card- plus 12 hex digits) serves the current card, so old tool lists and replies still work; other names under card- are still not found. The resource is not listed, and the address still changes with the card content. Redeploy the Worker after merging so Grok's saved tool list loads the app.