How to Test MCP Apps and ChatGPT Apps Before Users See a Blank Widget
Nikhil Tiwari
MCP Playground
π TL;DR
- ChatGPT now implements the open MCP Apps standard, so one test plan covers Claude, ChatGPT and other hosts.
- Test in three layers: contract tests on every PR, render tests in a stub host, and model evals on a schedule.
- Most blank widgets come from four things: a wrong MIME type, a missing
_meta.ui.resourceUri, a CSP block, or a view that never finishes the handshake. - Tool selection is the part a unit test can't catch. Only a real model tells you whether it calls your render tool.
Table of Contents
- Why testing MCP Apps is harder than testing tools
- What an MCP App or ChatGPT app actually is
- The three layers of MCP Apps testing
- Layer 1: Contract tests for ui:// resources
- Layer 2: Testing that the widget renders
- Layer 3: Testing tool selection across models
- Testing ChatGPT apps in developer mode
- Why is my MCP App widget blank? A checklist
- Running MCP Apps tests in CI
- How MCP Playground can help
- FAQ
A common MCP App bug goes like this. The tool call succeeds, the server logs are clean, and the user sees an empty box where the widget should be.
Ordinary MCP tests check tools. They don't check the HTML a host renders in its iframe, or whether the model called the render tool in the first place.
This matters more now that ChatGPT supports the same MCP Apps standard as Claude. One widget runs in both, so one bug shows up in both.
This guide covers how I test MCP Apps and ChatGPT apps: contract tests on every PR, a render test with a small stub host, model evals for tool selection, a CI workflow, and the checklist I use when a widget comes up blank.
Why Is Testing MCP Apps Harder Than Testing MCP Tools?
A normal Model Context Protocol tool has one contract: input schema in, result out. You can test it like any API.
An MCP App has three contracts stacked on top of each other:
- The server contract. The tool points to a
ui://resource, and that resource returns valid HTML with the right MIME type. - The host contract. The host loads that HTML in a sandboxed iframe, applies a CSP, and talks to it over
postMessage. - The model contract. The model has to decide to call your render tool in the first place.
If any of these breaks, the user sees the same thing: an empty widget, or plain text where the UI should be. From the outside you can't tell which part failed.
So I test each contract separately.
What Is an MCP App (and a ChatGPT App) Under the Hood?
MCP Apps is the official MCP extension for interactive UIs, defined in SEP-1865. Here are the moving parts:
- A tool declares
_meta.ui.resourceUri, for exampleui://weather/forecast. - The server exposes that URI as a resource with MIME type
text/html;profile=mcp-app. - The host reads the resource and renders it in a sandboxed iframe.
- The view and host talk over
postMessageusing JSON-RPC. The view starts withui/initialize, then receives the tool input and result.
A ChatGPT app is now the same thing. OpenAI's docs say ChatGPT implements the open MCP Apps standard and recommend its keys by default.
The older Apps SDK pieces still exist as ChatGPT extras:
_meta["openai/outputTemplate"]is a compatibility alias for_meta.ui.resourceUri.window.openaigives you ChatGPT-only features on top of the standard bridge.text/html+skybridgeis the older ChatGPT-only MIME type.
If you stick to the standard keys, the same tests cover both hosts. You only need ChatGPT-specific tests for the extras you actually use.
New to building these? Start with my guide to building MCP Apps, then come back here.
The Three Layers of MCP Apps Testing
I split the tests by how long they take and what they cost:
| Layer | What it catches | Speed | When to run |
|---|---|---|---|
| 1. Contract | Missing resourceUri, wrong MIME type, broken HTML, bad tool schema | Seconds | Every PR |
| 2. Render | Handshake bugs, CSP blocks, JS errors, empty state on real data | Under a minute | Every PR that touches the UI |
| 3. Model evals | Model skips the render tool, picks the wrong tool, sends bad arguments | Minutes | Nightly or before release |
The first two layers need no API keys and run in CI for free. Model evals need keys and cost money per run, so I keep them out of the PR checks.
Layer 1: How Do You Contract-Test a ui:// Resource?
Contract tests are cheap and catch most of the bugs I see. You connect a normal MCP client and check what a host would get back.
For each tool that should render UI, check four things:
tools/listreturns_meta.ui.resourceUrion that tool, and it starts withui://.resources/readon that URI succeeds.- The content's
mimeTypeistext/html;profile=mcp-app. - The HTML is non-empty and contains your root element.
A minimal version with the official TypeScript SDK and Vitest:
import { describe, it, expect } from "vitest";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const URL_UNDER_TEST = process.env.MCP_URL ?? "http://localhost:3000/mcp";
const UI_TOOLS = ["show_forecast"]; // tools that should render a widget
describe("MCP App contract", () => {
it("every UI tool points to a valid ui:// resource", async () => {
const client = new Client({ name: "contract-test", version: "1.0.0" });
await client.connect(new StreamableHTTPClientTransport(new URL(URL_UNDER_TEST)));
const { tools } = await client.listTools();
for (const name of UI_TOOLS) {
const tool = tools.find((t) => t.name === name);
expect(tool, name + " is missing").toBeDefined();
const uri = tool!._meta?.ui?.resourceUri;
expect(uri).toMatch(/^ui:\/\//);
const { contents } = await client.readResource({ uri });
const html = contents[0];
expect(html.mimeType).toBe("text/html;profile=mcp-app");
expect(html.text?.length ?? 0).toBeGreaterThan(100);
expect(html.text).toContain('id="root"');
}
await client.close();
});
});
People tend to skip the MIME check. A resource served as plain text/html looks fine in a debugger, but the host may not render it.
OpenAI suggests the RESOURCE_MIME_TYPE constant from @modelcontextprotocol/ext-apps/server instead of a hard-coded string. Use it in your server, and assert on it in your test.
Add these contract checks too
- CSP domains. If the widget fetches from an API or a CDN, check that
_meta.ui.csplists those domains. - ChatGPT alias. If you set
openai/outputTemplate, check it matchesui.resourceUri. Mismatched URIs render different widgets per host. - Structured output. If the view reads
structuredContent, check the tool returns it in the shape the view expects. - Both protocol revisions. If you serve 2025-11-25 and 2026-07-28 clients, run the suite against each.
No code yet? Point a client at a known-good server first. Test any MCP server free β lets you call tools/list and resources/read in the browser and inspect the raw _meta.
Layer 2: How Do You Test That the MCP App Widget Renders?
A contract test tells you the HTML arrives, not that it runs. For that you need a real browser and a page that plays the host's part.
The steps:
- Read the
ui://resource with your MCP client. - Load the HTML into a sandboxed iframe in a test page.
- Answer the view's
ui/initializerequest. - Send a tool result, then assert on what the widget shows.
A cut-down Playwright version, with the stub host in the outer page:
import { test, expect } from "@playwright/test";
import { readWidgetHtml, sampleResult } from "./fixtures"; // your MCP client helpers
test("forecast widget renders a real result", async ({ page }) => {
const html = await readWidgetHtml("ui://weather/forecast");
const errors: string[] = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.setContent('<iframe id="app" sandbox="allow-scripts"></iframe>');
await page.evaluate(({ html, result }) => {
const frame = document.getElementById("app") as HTMLIFrameElement;
window.addEventListener("message", (event) => {
const msg = event.data;
if (msg?.method === "ui/initialize" && msg.id !== undefined) {
frame.contentWindow!.postMessage(
{ jsonrpc: "2.0", id: msg.id, result: { /* host context for your SDK version */ } }, "*"
);
frame.contentWindow!.postMessage(
{ jsonrpc: "2.0", method: "ui/notifications/tool-result", params: result }, "*"
);
}
});
frame.srcdoc = html;
}, { html, result: sampleResult });
const app = page.frameLocator("#app");
await expect(app.getByText("Tomorrow")).toBeVisible({ timeout: 5000 });
expect(errors).toEqual([]);
});
This is a smoke test, not a full host implementation. Make the ui/initialize result match the version of @modelcontextprotocol/ext-apps you ship.
What it catches:
- The view never sends
ui/initialize. Usually a bundling bug: the script didn't inline, or it threw on load. - Uncaught JS errors from code that assumes a browser API the sandbox blocks.
- Empty states. The widget renders, but shows "No data" because it reads the wrong field from the result.
- Layout issues. Take a screenshot at a narrow width. Chat panels are smaller than you think.
Use real results, not hand-written mocks. Save a few actual tool responses as fixtures. Hand-written fixtures always match what the view expects. Real ones don't.
What a stub host won't catch
A stub doesn't apply Claude's or ChatGPT's real CSP, sizing rules or theme. It also can't tell you whether a model calls your tool.
I cover the first with a quick check in both hosts before a release, and the second with evals.
Layer 3: Does the Model Actually Call Your Render Tool?
A widget can work perfectly and the model can still answer in plain text, because it never called the render tool. Unit tests won't catch that.
A common version: the server has a data tool and a render tool, and the model calls the data tool and writes its own summary.
An MCP eval catches it. You write prompts a real user would send, and check which tool the model calls and with what arguments.
What to assert in an MCP Apps eval
- Tool choice. "Show me the forecast for Pune" should call
show_forecast, not justget_forecast. - Arguments. The model passes valid values that match the schema, such as a city name, not a sentence.
- Negative cases. "What's the capital of France?" should call no tool at all.
- Disambiguation. If two tools sound alike, add prompts that should clearly pick one.
Run it across more than one model
Models differ a lot here. The same prompt can get a different tool from Claude, GPT and Gemini.
Since your app now runs in Claude and ChatGPT, test at least one model from each family. My post on the best AI models for MCP tool calling covers how far apart they can be.
If a model keeps skipping the render tool, I look at the tool description first. It should say when to use the tool, not just what it is:
// Before
description: "Forecast widget"
// After
description: "Show an interactive weather forecast card for a city. Use this whenever the user asks to see or compare a forecast. Prefer it over get_forecast when the user wants to view results."
I wrote more on this in how tool descriptions decide what a model calls.
You can run these evals against your server in MCP Playground's evals. Pick the models, write the prompts, and see which tool each model called.
How Do You Test a ChatGPT App in Developer Mode?
Before a release I still do one pass by hand in ChatGPT.
- Turn on developer mode: Settings β Connectors β Advanced β Developer mode.
- Expose your local server with a tunnel such as ngrok or cloudflared.
- Add the server as a connector with its public HTTPS URL.
- Run your eval prompts by hand and watch the widget render.
Two things that catch people out:
- Cached templates. ChatGPT can keep an old version of your widget. Version your
ui://URI, for exampleui://weather/forecast-v3, when the HTML changes. - Localhost hostnames. Tunnels send their public hostname, and the SDKs' DNS-rebinding protection can reject it. See my fix for localhost connection errors.
Do the same quick pass in Claude. My Claude MCP Apps guide covers how Claude shows them.
Why Is My MCP App Widget Blank? A Checklist
Check these in order. The first four explain most blank widgets.
- MIME type. Is it
text/html;profile=mcp-app, not plaintext/html? - Missing resourceUri. Does the tool in
tools/listactually carry_meta.ui.resourceUri? Some frameworks drop unknown_metakeys. - CSP. Does the widget load a script, font or API from a domain not listed in
_meta.ui.csp? The iframe blocks it silently. - No handshake. Does the view complete
ui/initialize? If the bundle throws first, the host waits forever. - Wrong data field. Does the view read
structuredContentwhile the tool only returnscontenttext? - External assets. Did you link a separate JS or CSS file? Inline everything into one HTML file.
- Old cached version. Did the host keep an earlier template? Bump the URI.
Contract tests catch 1, 2, 3 and 5, and render tests catch 4 and 6, which is why both run on every PR.
How Do You Run MCP Apps Tests in CI?
CI follows the same split: free checks block the merge, and paid evals run on a schedule.
# .github/workflows/mcp-app.yml
name: MCP App tests
on:
pull_request:
schedule:
- cron: "0 3 * * *" # nightly evals
jobs:
contract-and-render:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 22 }
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npm run start:mcp &
- run: npx wait-on http://localhost:3000/mcp
- run: npx vitest run tests/contract
- run: npx playwright test tests/render
model-evals:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run evals
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
A few things that help:
- Upload Playwright screenshots as artifacts. A picture of the widget beats any log line.
- Track pass rates, not single runs. Models are non-deterministic. Run each eval prompt three to five times and alert on a drop.
- Run evals before a release too, not just nightly. Changing a tool description can change tool choice.
The GitHub Actions docs cover secrets and schedules if you're new to them.
How MCP Playground Can Help
In MCP Playground you can check tools/list, _meta.ui.resourceUri and resources/read in the browser MCP tester, and see which tool each model picks in evals. It doesn't preview widgets yet, so use the stub host above for rendering.
Conclusion
To recap: run contract tests and a render test on every PR, and run model evals nightly and before releases.
Because ChatGPT and Claude now share the MCP Apps standard, one set of tests covers both. If you only add one thing this week, make it the contract test.
FAQ
How do I test an MCP App without Claude or ChatGPT?+
Use an MCP client to check tools/list and resources/read, then load the ui:// HTML into a sandboxed iframe with a small stub host in Playwright. The stub answers ui/initialize and sends a tool result so you can check what the widget shows.
Are ChatGPT apps and MCP Apps the same thing?+
Mostly. ChatGPT implements the open MCP Apps standard, and OpenAI recommends its keys by default. ChatGPT also keeps extras like window.openai and the openai/outputTemplate alias. If you only use the standard keys, the same tests cover both.
Why does my MCP App show a blank widget?+
The most common causes are a MIME type other than text/html;profile=mcp-app, a tool missing _meta.ui.resourceUri, a CSP that blocks a script or API, and a view that throws before finishing ui/initialize. Check those four first.
What MIME type should an MCP App resource use?+
text/html;profile=mcp-app. The older text/html+skybridge type is only used by ChatGPT's original Apps SDK. Use the RESOURCE_MIME_TYPE constant from @modelcontextprotocol/ext-apps/server rather than typing the string.
How do I check that a model calls my MCP App's render tool?+
Run evals: send realistic user prompts to real models connected to your server and check which tool each one calls and with what arguments. Test models from more than one family, since tool choice varies between them.
Should MCP Apps evals run on every pull request?+
Usually not. Evals need API keys, cost money and vary between runs. Run fast contract and render tests on every PR, and run model evals nightly and before releases.
Written by Nikhil Tiwari
15+ years in product development. AI enthusiast building developer tools that make complex technologies accessible to everyone.
Free MCP Tools (no install)
Build, compare & ship MCP agents
Connect any MCP server, run evals on it, compare 90+ models side-by-side, deploy hosted servers, and save reusable agents you can export as an API β all in your browser.