mcp-apps-interactive-ui
A Pizza Builder MCP server that demonstrates interactive in-chat UI widgets for selecting pizza options with live price updates and order submission.
README
mcp-apps-interactive-ui
A runnable example of building interactive in-chat UI with MCP Apps, with docs on the parts that aren't obvious from the spec.
MCP Apps (the io.modelcontextprotocol/ui extension, SEP-1865) lets an MCP server hand the host a sandboxed HTML widget instead of plain text. The model calls one tool and the user gets a real interface: option pickers, live totals, buttons that talk back to the model. This repo is a minimal working example of that pattern.

Static screenshot, not a live embed. To run the real thing: build the repo and open dist/builder.html in a browser, or connect the server to a host (see Quickstart).
The example app is a Pizza Builder. Pick size, crust, and toppings, watch the price update live, and hit Place order to hand the choice back to the model. The domain is intentionally simple so the MCP Apps mechanics stay in focus.
Requirements
Node.js 20.11 or newer (the code uses import.meta.dirname, and @modelcontextprotocol/ext-apps requires Node 20+).
What it demonstrates
In a small, commented codebase (~700 lines of TypeScript):
| Capability | How | Where |
|---|---|---|
| Render an interactive widget from a tool call | _meta.ui.resourceUri links a tool to a ui:// resource |
src/server.ts, docs/02 |
| Keep the model's context small | launcher returns a {orderId} ref; the widget fetches the rest via an app-only tool |
docs/06 |
| Let the user pick options without spending tokens | visibility: ["app"] tools the host keeps out of the model's list |
src/server.ts |
| Hand a result back to the model | updateModelContext (stage) then sendMessage (trigger) |
docs/05 |
| Show external images | _meta.ui.csp.resourceDomains |
docs/04 |
| Download a file | app.downloadFile |
src/widget/widget.ts |
| Go fullscreen | app.requestDisplayMode (gated on availableDisplayModes) |
src/widget/widget.ts |
| Match the host's theme and fonts | applyHostStyleVariables / applyHostFonts |
docs/03 |
| See what the host actually granted you | getHostCapabilities() and a capability probe |
docs/07 |
Plus 10 gotchas: URI caching, the silent updateModelContext, the caution banner, the session-locked tool catalog, and more.
Quickstart
git clone https://github.com/iamneilroberts/mcp-apps-interactive-ui
cd mcp-apps-interactive-ui
npm install
npm run build
See the widget immediately, no host required. The build produces a single self-contained dist/builder.html that falls back to mock data when opened directly:
open dist/builder.html # macOS
xdg-open dist/builder.html # Linux
Run it as a real MCP server:
npm start # Streamable HTTP at http://127.0.0.1:3001/mcp
npm run start:stdio # stdio, for Claude Desktop / MCP Inspector
Connect it to a host:
- Claude Desktop: add to your MCP config, then ask Claude "build me a pizza":
{ "mcpServers": { "pizza": { "command": "node", "args": ["/abs/path/to/mcp-apps-interactive-ui/dist/index.js", "--stdio"] } } } - MCP Inspector:
npx @modelcontextprotocol/inspector node dist/index.js --stdio
How it fits together
flowchart TB
M["Model (Claude)"]
H["Host (claude.ai / Desktop)"]
W["Widget (sandboxed iframe)"]
S[("Your MCP server: build_pizza, pizza_state, pizza_pick")]
M <-->|"tool call / result + UI resource"| H
H <-->|"postMessage / JSON-RPC bridge"| W
H -->|"app.callServerTool() (proxied by host)"| S
The model launches the widget once. After that the widget talks to your server directly through the host (app.callServerTool), so picking options costs zero model tokens. The widget hands control back to the model only when the user is done. Full walkthrough in docs/01.
Repo layout
src/
server.ts the MCP server: 1 launcher tool + 2 app-only tools + 1 UI resource
data.ts the toy domain (menu, orders, pricing)
index.ts transport wiring (Streamable HTTP + stdio)
widget/
widget.ts the App: render, pick, place-order, download, fullscreen, theme
widget.html the shell (CSS + JS get inlined here at build time)
styles.css
esbuild.mjs bundles the widget into one self-contained HTML the server serves
test/ unit tests for the pricing/selection logic (node --test via tsx)
docs/ 01-08, the deep dives
media/ screenshots
Run the tests with npm test. CI (typecheck, build, test) runs on every push via GitHub Actions.
Docs
- Architecture & lifecycle: the handshake, the bridge, the two-part registration.
- Declaring UI resources:
ui://, the MIME type,_meta.ui.resourceUri, tool visibility. - The host API: every
app.*method, and the capabilities-vs-context distinction. - CSP & imagery: why your image is blocked and how to allow the domains you need.
- Two-way comms:
updateModelContextvssendMessage, the caution banner, no progress tokens. - The token economy: the ref-and-fetch pattern that keeps a large payload out of the model's context.
- Probing host capabilities: how to find out what a host grants, with real Claude Desktop results.
- Gotchas: 10 things to know before shipping.
The capability tables in docs/07 come from running a probe inside a live host. Claude Desktop results are confirmed as of 2026-06-13; some claude.ai web cells are marked pending where they hadn't been captured in-host. Host behavior changes over time, so treat every host-specific claim as "as of that date" and re-probe before relying on a specific cell.
License
MIT.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。