Skip to Content
GenerateSaaS

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.

WidgeturiDraws
Tableui://widgets/table.htmlLabelled columns, one row per record, an optional action per row
Listui://widgets/list.htmlItems with a title, a detail line and a date or status, an optional action each
Detailui://widgets/detail.htmlOne record as sections of labelled fields
Statsui://widgets/stat.htmlA 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

packages/api/src/ai/capabilities/invoices.ts
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.

A kit tool must be a read (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

KindWhat goes thereExample
LabelA 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 } }
ValueData: a string, number, null, or a date as an ISO string42.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.

RuleEnforced
List every tool a row may call in actions: ["invoices_void"] on defineKitCapabilityAn answer naming any other tool is refused
Each listed tool is a capability in the same registryBuilding 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_BYTES in packages/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.

On this page