h5p-mcp-app: the card's own origin in each chat's form

Merged
AL
2d ago
+68-30

Summary

Closes #329. In Claude, a server given --domain showed [mcp-ext-apps-host] ui.domain validation failed and no card: the option, ChatGPT's origin, was written to _meta.ui.domain too, which Claude accepts only in its own form. Claude's docs: a bad value shows an error in place of the app, and a site framed in the card keeps localStorage only with a valid one.

Changes

  • _meta.ui.domain is Claude's: the first 32 hex of the SHA-256 of the connector's address with .claudemcpcontent.com, computed from the address each request was sent to (<origin>/mcp, query and all).
  • domain stays ChatGPT's, written as openai/widgetDomain alone.
  • The card's address hashes the card and its policy, Claude's origin aside, so a chat that keeps the card by its address gets the changed policy; another connector address for the same site keeps the card's address.
  • The JSDoc, --help, the README and the rule in design/mcp.md say so; the domain check keeps its reason.

Verification

  • pnpm --filter @missing-elements/h5p-mcp-app test: 33 passed. Typecheck, pnpm comments, and oxlint with #326's config: clean.

  • tests/app.test.ts: Claude's origin for https://example.com/mcp is the one Claude's documentation gives, c3d80a4ed901ee05b21755a88273b4a4.claudemcpcontent.com; in the listing and on the card, with and without domain; from the command's own address.

  • By hand, once released and deployed: the card shows in Claude, and plays in it where Claude lets the play page's origin in; ChatGPT plays as before.

  • 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

Add the server as a custom connector in Claude web with --domain https://lessons.example, and ask it to play an activity: the console shows the validation error and no card. With this change the card's ui.domain is Claude's for the connector's address.


Summary by cubic

Makes the card's domain option ChatGPT-only, and gives Claude the origin it expects, so a card configured with a domain no longer shows an error in Claude.

  • domain is written only as openai/widgetDomain, which ChatGPT reads; _meta.ui.domain is now always Claude's hash of the connector's address it was asked at, which also lets a site framed in the card keep localStorage.
  • The card's address now hashes its policy, so a policy change gives the card a new address.
  • Updates the JSDoc, --help output, README, design/mcp.md, and tests.