npx skills add ...
npx skills add modelcontextprotocol/ext-apps --skill add-app-to-server
This skill should be used when the user asks to "add an app to my MCP server", "add UI to my MCP server", "add a view to my MCP tool", "enrich MCP tools with UI", "add interactive UI to existing server", "add MCP Apps to my server", or needs to add interactive UI capabilities to an existing MCP server that already has tools. Provides guidance for analyzing existing tools and adding MCP Apps UI resources.
npx skills add modelcontextprotocol/ext-apps --skill add-app-to-server
Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK (@modelcontextprotocol/ext-apps).
Existing tools get paired with HTML resources that render inline in the host's conversation. The tool continues to work for text-only clients — UI is an enhancement, not a replacement. Each tool that benefits from UI gets linked to a resource via _meta.ui.resourceUri, and the host renders that resource in a sandboxed iframe when the tool is called.
Clone the SDK repository for working examples and API documentation:
Read JSDoc documentation directly from /tmp/mcp-ext-apps/src/:
| File | Contents |
|---|---|
src/app.ts | App class, handlers (ontoolinput, ontoolresult, onhostcontextchanged, onteardown), lifecycle |
src/server/index.ts | registerAppTool, registerAppResource, getUiCapability, tool visibility options |
src/spec.types.ts | All type definitions: McpUiHostContext, CSS variable keys, display modes |
src/styles.ts | applyDocumentTheme, applyHostStyleVariables, applyHostFonts |
src/react/useApp.tsx | useApp hook for React apps |
src/react/useHostStyles.ts | useHostStyles, useHostStyleVariables, useHostFonts hooks |
These examples demonstrate servers with both App-enhanced and plain tools — the exact pattern you're adding:
| Example | Pattern |
|---|---|
examples/map-server/ | show-map (App tool) + geocode (plain tool) |
examples/pdf-server/ | display_pdf (App tool) + list_pdfs (plain tool) + read_pdf_bytes (app-only tool) |
examples/system-monitor-server/ | get-system-info (App tool) + poll-system-stats (app-only polling tool) |
Learn and adapt from /tmp/mcp-ext-apps/examples/basic-server-{framework}/:
| Template | Key Files |
|---|---|
basic-server-vanillajs/ | server.ts, src/mcp-app.ts, mcp-app.html |
basic-server-react/ | server.ts, src/mcp-app.tsx (uses useApp hook) |
basic-server-vue/ | server.ts, src/App.vue |
basic-server-svelte/ | server.ts, src/App.svelte |
basic-server-preact/ | server.ts, src/mcp-app.tsx |
basic-server-solid/ | server.ts, src/mcp-app.tsx |
Before writing any code, analyze the server's existing tools and determine which ones benefit from UI.
| Tool output type | UI benefit | Example |
|---|---|---|
| Structured data / lists / tables | High — interactive table, search, filtering | List of items, search results |
| Metrics / numbers over time | High — charts, gauges, dashboards | System stats, analytics |
| Media / rich content | High — viewer, player, renderer | Maps, PDFs, images, video |
| Simple text / confirmations | Low — text is fine | "File created", "Setting updated" |
| Data for other tools | Consider app-only | Polling endpoints, chunk loaders |
Plus framework-specific dependencies if needed (e.g., react, react-dom, @vitejs/plugin-react for React), and @modelcontextprotocol/node / @modelcontextprotocol/express if the server uses HTTP transports.
ext-apps 2.x requires the split base MCP SDK packages at ^2.0.0
(@modelcontextprotocol/core comes in transitively). Existing servers that
still import @modelcontextprotocol/sdk v1 must migrate those imports and
handler schemas before adding the App integration:
SDK v1 (@modelcontextprotocol/sdk) | SDK v2 |
|---|---|
sdk/server/mcp.js (McpServer) | @modelcontextprotocol/server |
sdk/server/streamableHttp.js (StreamableHTTPServerTransport) | NodeStreamableHTTPServerTransport from @modelcontextprotocol/node |
| Express wiring by hand | createMcpExpressApp from @modelcontextprotocol/express |
sdk/server/stdio.js | @modelcontextprotocol/server/stdio |
sdk/types.js types (CallToolResult, …) | @modelcontextprotocol/client or @modelcontextprotocol/server |
sdk/types.js zod schemas (CallToolResultSchema, …) | @modelcontextprotocol/core |
Raw zod shapes: inputSchema: { q: z.string() } | inputSchema: z.object({ q: z.string() }) |
extra.signal in tool callbacks | extra.mcpReq.signal |
setRequestHandler(SomeRequestSchema, handler) | setRequestHandler("some/method", { params: ParamsSchema }, handler) (the 2-arg form is only for spec methods such as "tools/call") |
Create vite.config.ts with vite-plugin-singlefile to bundle the UI into a single HTML file:
Create mcp-app.html (or one per distinct UI if tools need different views):
Add build scripts to package.json. The UI must be built before the server code bundles it:
Transform plain MCP tools into App tools with UI.
Before (plain MCP tool):
After (App tool with UI):
Key guidance:
content array with a text fallback for text-only clientsstructuredContent for data the UI needs to render_meta.ui.resourceUriRegister the HTML resource so the host can fetch it:
If multiple tools share the same UI, they can reference the same resourceUri and the same resource registration.
Register ALL handlers BEFORE calling app.connect():
Use host CSS variables for theme integration:
Key variable groups: --color-background-*, --color-text-*, --color-border-*, --font-sans, --font-mono, --font-text-*-size, --font-heading-*-size, --border-radius-*. See src/spec.types.ts for the full list.
For React apps, use the useApp and useHostStyles hooks instead — see basic-server-react/ for the pattern.
Tools the UI calls but the model doesn't need to invoke directly (polling, pagination, chunk loading):
The UI calls these via
app.callServerTool({ name: "poll-data", arguments: {} }).
If the UI needs to load external resources (fonts, APIs, CDNs), declare the domains:
For large tool inputs, show progress during LLM generation:
getUiCapability()Conditionally register App tools only when the client supports UI, falling back to text-only tools:
Allow the UI to expand to fullscreen:
content fallback — Always include content array with text for non-UI hostsconnect() — Register ALL handlers BEFORE calling app.connect()vite-plugin-singlefile — Without it, assets won't load in the sandboxed iframeresourceUri that must have a matching resourcevar(--color-*)) for theme integrationctx.safeAreaInsets in onhostcontextchangedTest the enhanced server with the basic-host example:
Configure SERVERS with a JSON array of your server URLs (default: http://localhost:3001/mcp).
ontoolinput handler fires with tool argumentsontoolresult handler fires with tool result