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.
The kit is four ordinary widgets your capabilities fill with data. A tool returns a shape from @repo/ai/widget-kit, and the kit draws it with your theme, in every MCP host and in your own chat. No view, no registry entry, no build.
| Widget | uri | Draws |
|---|---|---|
| Table | ui://widgets/table.html | Labelled columns, one row per record, an optional action per row |
| List | ui://widgets/list.html | Items with a title, a detail line and a date or status, an optional action each |
| Detail | ui://widgets/detail.html | One record as sections of labelled fields |
| Stats | ui://widgets/stat.html | A few figures, each with its change and a sparkline |
Each also takes an optional title and a link to the same data in your app. A table or list takes an empty label.
Return a table
import { jsonSchema } from "@repo/ai";
import { defineKitCapability } from "@repo/ai/capabilities";
import { mcpWidget } from "../mcp-apps/widget-uris";
export const invoicesList = defineKitCapability("table", {
name: "invoices_list",
title: "List invoices",
description: "List the user's recent invoices. Read-only.",
inputSchema: jsonSchema<Record<string, never>>({ type: "object", properties: {} }),
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
ui: { resourceUri: mcpWidget("ui://widgets/table.html") },
async execute(_input, ctx) {
const invoices = await listInvoices(ctx.userId);
return {
title: "invoices.title",
columns: [
{ key: "date", label: "invoices.date", format: "date" },
{ key: "amount", label: "invoices.amount", format: "currency", currency: "USD" },
{ key: "status", label: "invoices.status", format: "badge" }
],
rows: invoices.map((invoice) => ({
id: invoice.id,
cells: { date: invoice.createdAt.toISOString(), amount: invoice.total, status: invoice.status }
})),
empty: "invoices.empty"
};
}
});defineKitCapability types execute by the kit's schema, so a wrong shape fails the type-check. It also parses every answer once: a bad one throws when a test calls execute, and over MCP or chat the call answers the generic failure while the server logs the schema's problems. A toolFailure(...) answer passes through.
readOnlyHint: true, not mutating): after a row's action runs, the widget calls the tool again with the same input to redraw. Declaring it otherwise throws.Labels and values
| Kind | What goes there | Example |
|---|---|---|
| Label | A key in packages/i18n/translations/en/mcp-widgets.json: titles, headers, field names, empty state, button and link text | "invoices.amount", or { key: "invoices.count", values: { count: 3 } } |
| Value | Data: a string, number, null, or a date as an ISO string | 42.5, "2026-11-06T09:00:00.000Z" |
A label that is not a dotted lower-case key is refused, so English text never ships in a label. Values take a format: text (default), number, currency (with an ISO 4217 currency), percent (a fraction), date, datetime or badge.
Row actions
A table row or list item can carry one action: { label, tool, arguments }. A click runs that tool once, like every widget write, then the widget redraws by re-running its own tool with the same input; the kit adds no write path of its own.
| Rule | Enforced |
|---|---|
List every tool a row may call in actions: ["invoices_void"] on defineKitCapability | An answer naming any other tool is refused |
| Each listed tool is a capability in the same registry | Building the toolset throws otherwise |
The shipped example is notifications_list in packages/api/src/ai/capabilities/notifications.ts: a list whose unread items carry Mark read, with the widget link, the actions entry and each row's action inside gsaas:mcp-apps regions.
Limits
- Up to 100 rows or items, 8 columns or tiles, and 120 sparkline points.
- The shared widget document has a size budget (
WIDGET_DOCUMENT_BUDGET_BYTESinpackages/mcp-widgets/scripts/widget-build.ts). The build fails over it, which keeps chart libraries out. - The answer never depends on the widget: with widgets off (
config.mcpServer.apps: false) the tool returns the same data, which agents read as JSON.
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.
Client Architecture
How client code is layered - apps hold thin views, @repo/ui draws shared components, and @repo/app-core owns headless behavior behind host seams.