MCP widgets
Give a capability an interactive widget that Claude, ChatGPT, VS Code and Goose render when an agent calls it over your MCP server, and that your own chat renders under the tool's row, built from your own UI kit.
A widget is a small React view for a tool's result. Your MCP server hands it to a host through the official MCP Apps extension, which renders it in a sandboxed iframe. Your own web and desktop chat renders the same view natively, under the tool's row.
config.mcpServer.apps switches both: absent, it follows config.mcpServer.enabled; true keeps the in-app widgets even with the MCP server off; false removes every widget, and the tool list and resources are exactly what they are without them.
Shipped widgets
| Widget | Tool | Shows |
|---|---|---|
| Account | account_status_get | Who is signed in, then plan, balance, spending per feature over 30 days and the latest 5 billing history lines, as money, and a link to your billing page. Nothing to buy |
| Organization | organizations_get | Per view: members and roles with open invitations (owners and admins change a role, remove a member or cancel an invitation, through organizations_members_update, organizations_members_remove and invitations_dismiss); received invitations with Accept and Decline (invitations_accept, invitations_dismiss); the user's organizations or an organization's sent invitations as a plain list |
| List (kit) | notifications_list | The user's notifications, newest first, with Mark read on each unread one and a link to the notifications page. Only while config.notifications.enabled is on |
| Table, List, Detail, Stats | Any read you define with defineKitCapability | The widget kit: your tool returns data, the kit draws it. Reach for it before writing a view |
A single-tenant build serves Account only: the organization tools are not offered, so their widget never renders.
How it fits together
| Piece | Where |
|---|---|
| Views | packages/ui/src/components/mcp-widgets/<id>/ |
| In the document | WIDGET_VIEWS in packages/mcp-widgets/src/widgets/index.ts, imported eagerly |
| In your chat | WIDGET_VIEW_LOADERS in @repo/ui/lib/mcp-widgets/views, one dynamic import each |
| Registry | packages/mcp-widgets/src/registry.ts: id, name and a factual description |
| Bridges | useMcpApp (hosts) and useInAppWidgetView (your chat) in @repo/app-core/mcp-app/, both answering the same view |
| Write status | packages/ui/src/components/mcp-widgets/widget-write-status.tsx (KitWriteStatus in kit/kit-parts.tsx for the kit) |
| Built document | packages/api/src/ai/mcp-apps/widget-documents.generated.ts, committed |
The views live in @repo/ui so both renderers reach them without a package cycle: the widget document depends on @repo/ui, and the chat loads a view only when a call that links it renders. Every host widget ships in one self-contained document, served under each widget's uri with the widget's id and your app's origin written into <html>.
Add a widget to a capability
packages/ui/src/components/mcp-widgets/<id>/: a component taking { view, t }. Wrap its content in WidgetState, which draws loading, error and cancelled, and build it from @repo/ui primitives.{ id, name, description } to MCP_WIDGETS, the view to WIDGET_VIEWS and its loader to WIDGET_VIEW_LOADERS. The compiler refuses a registered widget without a view, and the suite one without a loader.packages/i18n/translations/en/mcp-widgets.json. Your chat reads it as mcp_widgets.* through the app's own translator.pnpm --filter @repo/mcp-widgets widgets:build and commit the generated module. The drift test fails when they disagree, and the pre-commit hook rebuilds it after the translations change.ui: { resourceUri: mcpWidget("ui://widgets/<id>.html") }, with mcpWidget from packages/api/src/ai/mcp-apps/widget-uris. The uri is type-checked.The widget reads the tool's answer as view.result.data: what your execute returned, the same in both places. Your chat renders it only for a call that finished with structured data; a running or failed call, or one that answered a sentence, shows its row alone.
Theme
A widget blends with the host's chat only when that is provably safe; otherwise it wears your app's whole theme. hostPaletteVerdict (@repo/app-core/mcp-app/host-tokens) decides from the actual colour values, all or nothing:
| The host's palette is taken when | Measured as |
|---|---|
| Complete | it sets a page, text and border colour |
| Readable | every colour parses (hex, rgb(), hsl(), oklch(), oklab(), light-dark()) and every surface is opaque |
| Coherent | its page is dark under a dark theme and light under a light one |
| Legible | text, secondary text and your brand (--primary) on its page reach 4.5:1, or at least what your own theme reaches |
<html data-widget-palette="host|app">, with data-widget-palette-reason on a refusal.Your own palette reaches the document through packages/mcp-widgets/src/project-theme.ts, a file your project owns: stylesheets are imported after the shared theme, and htmlAttributes land on <html>, for a palette keyed on one such as data-brand. Rebuild with widgets:build after changing it.
Writes from a widget
Drive every write a widget offers with useWidgetWrite(view, { onDone }) (@repo/app-core/mcp-app/use-widget-write): run(tool, args) calls the tool once on the person's click, and state moves through running to done or error. Show it with <WriteStatus state t onClose /> (packages/ui/src/components/mcp-widgets/widget-write-status.tsx). The click is the person's own action, so nothing sits between it and the change, on either host.
| MCP host | Your own chat | |
|---|---|---|
| The call | Travels the host's connection to /api/mcp, like every other call the widget makes | POST /ai/tools/call on the person's app-tools session, never from the read cache |
| After it ran | onDone redraws what the change touched | The same, and every cached widget read is marked stale |
visibility: ["app"] marks a tool only a widget on an MCP host should call. Only hosts that support MCP Apps hide it from the model; with widgets off, the server does not offer it at all, and your own chat never offers it either.
Safety rules
- Same rules as every call. On a host, a widget's calls travel the host's connection to
/api/mcpwith the agent's credential. In your chat, they go throughPOST /ai/tools/callon the person's own app-tools session, with the same toolset gating, billing and per-call membership check, never the MCP route. - Nothing fetched. The host document inlines its scripts, styles and copy, and its CSP allows no outside origin.
- Text, never markup. Render tool output through React as text.
view.openLinkopenshttpslinks on your app's origin on a host, and only a route on your app's own origin, through its router, in your chat. - No purchases. A widget never buys, upgrades or tops up.
Questions stay plain: the assistant's ask_user card is in-app only, and outside hosts ask in the conversation, since MCP elicitation is not reliably supported there.
Test a widget
packages/mcp-widgets/tests/support/render-widget.tsx renders a widget as the document mounts it, against a fake host that speaks the real protocol. Drive it with host.sendToolResult(jsonToolResult(...)) and host.changeHostContext({ theme: "dark" }), and serve its calls with fakeTools from tests/support/fake-tools.ts. packages/ui/src/components/ai/tool-widget.test.tsx renders it in the real chat view against a fake backend.
ChatGPT. Tools also list openai/outputTemplate, openai/widgetAccessible and openai/visibility; resources carry openai/widgetDescription and openai/widgetCSP with your origin as the only redirect domain. App review asks for a dedicated widget origin: set it as domain in the resource _meta in packages/api/src/ai/mcp-apps/index.ts once OpenAI assigns it.
Reviewer account
Create the test account Claude's and ChatGPT's directory reviewers sign in with - email and password only, no second factor, magic link or email code, and data for every review case.
Widget kit
Give a read tool a widget without writing UI - return a table, list, detail or stats shape and the kit draws it in Claude, ChatGPT and your own chat.