mcp-app-cards
Skill1 starsChanged 10 days agoMITView on GitHub
Build MCP Apps cards (ui:// HTML resources rendered inside the chat) that work in both ChatGPT and Claude - the MCP Apps start-up handshake done in the right order, window.openai treated as an extra and never a reason to skip the handshake, data picked up however the host delivers it so a card never stays blank, the card-domain conflict (Claude's hashed ui.domain vs ChatGPT's openai/widgetDomain), CSP and link targets, and a stand-in host test that runs in headless Chrome. Use when adding a card or widget to an MCP server, porting an OpenAI Apps SDK widget, or when a card shows "timed out", "Couldn't open", renders blank, or works in one host and not the other.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- mcp-server-for-pluginsSkill
- plugin-oauthSkill
- plugin-packageSkill
- plugin-prerequisitesSkill
- publish-mcp-serverSkill
- submit-to-chatgptSkill
- submit-to-claudeSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Only then it sends {"jsonrpc":"2.0","method":"ui/notifications/initialized"}.
- Distinctive: line 74
Run it on the old card and the new one when fixing a bug.
- Distinctive: line 82
If a host fails, reproduce in the stand-in before changing anything: watch the page for the card's frame appearing and disappearing, and …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MCP Apps cards that render in both hosts
A card is an HTML document served as an MCP resource (ui://…, mime type
text/html;profile=mcp-app) and linked from a tool with _meta.ui.resourceUri. The host runs it
in a sandboxed iframe and talks to it with JSON-RPC over postMessage. Both ChatGPT and Claude
implement this standard; they differ in strictness and in a few keys. Start from
assets/card-template.html, which already does everything below.
1. The start-up, in this order
- The card sends a request:
{"jsonrpc":"2.0","id":1,"method":"ui/initialize","params":{"protocolVersion":"2026-01-26","appInfo":{"name":"…","version":"…"},"appCapabilities":{…}}}. It'sappInfo, notclientInfo. - It waits for the host's answer to id 1.
- Only then it sends
{"jsonrpc":"2.0","method":"ui/notifications/initialized"}. - The host sends the data in
ui/notifications/tool-result(params.structuredContent), and may also include it in the initialize answer (result.toolResult).
Claude tolerates a card that sends initialized early or names itself wrongly. ChatGPT doesn't:
it waits for a correct start-up and, after about 5 seconds, removes the card ("<card> timed out",
then "Couldn't open <card>").
2. window.openai is an extra, never a shortcut
ChatGPT also injects window.openai (with toolOutput, theme, openExternal). A card that
sees window.openai.toolOutput and skips the handshake draws its data, and ChatGPT still times
it out because the start-up never happened. Always run the handshake. Use window.openai only
to draw sooner or to open links.
3. Never stay blank
The host may hand data over at different moments, and not always by message. A card that looks
once and then waits can sit on its loading skeleton forever ("Opened <card>" with an empty box).
So: render on tool-result, on the initialize answer, on window.openai.toolOutput at start,
on the openai:set_globals event, and keep checking for about 10 seconds. If nothing arrives,
replace the skeleton with a sentence ("This card could not load here. Ask again.").
4. Keys that differ between hosts
| Need | Standard key (Claude reads) | ChatGPT key |
| A dedicated origin | _meta.ui.domain | openai/widgetDomain (alias) |
| Network / assets allowed | _meta.ui.csp.connectDomains, resourceDomains | openai/widgetCSP.connect_domains, resource_domains |
| Sites the card may open | (open-link request) | openai/widgetCSP.redirect_domains |
| Tool → card link | _meta.ui.resourceUri | openai/outputTemplate (alias) |
The conflict: Claude shows a card only if ui.domain is absent or exactly
<first 32 hex of sha256(full MCP URL)>.claudemcpcontent.com; anything else gives "Invalid
ui.domain format". ChatGPT requires a domain for a submitted plugin. Leave ui.domain out and
put your origin in openai/widgetDomain; ChatGPT then serves the card from
<your-domain-with-dashes>.web-sandbox.oaiusercontent.com. Use origins with the scheme
(https://example.com) in every domain list. ChatGPT appends ?redirectUrl=… to links it
opens, so make sure no page of your site follows a redirect parameter blindly.
5. Test it before either host sees it
scripts/card_host_test.py runs a card inside a stand-in host in headless Chrome, three ways:
a plain MCP Apps host; ChatGPT-like, with window.openai.toolOutput present at start; and
ChatGPT-late, with window.openai filled 1.5 s later and no tool-result message. It checks the
start-up order (appInfo, initialized only after the answer) and that the card drew your data.
python3 scripts/card_host_test.py path/to/card.html --data sample.json --expect "text that must appear"Run it on the old card and the new one when fixing a bug; the old should fail the way the host did, and the new should pass all three.
6. Then in the real hosts
- Claude: add the server as a custom connector, ask for the tool, and check that the card draws.
- ChatGPT: chatgpt.com/plugins → your plugin → Refresh after every deploy (it caches card HTML), then a new chat with the plugin @-mentioned.
- If a host fails, reproduce in the stand-in before changing anything: watch the page for the card's frame appearing and disappearing, and the host's own "Opening… / Couldn't open" text.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

