add-app-to-server — for Claude Code add-app-to-server, mcp-apps-demo, community, for Claude Code, ide skills, _meta.ui.resourceUri, ontoolinput, ontoolresult, onhostcontextchanged, onteardown

v1.0.0

이 스킬 정보

적합한 상황: Ideal for AI agents that need add ui to mcp server. 현지화된 요약: # Add UI to MCP Server Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK (@modelcontextprotocol/ext-apps). This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

기능

Add UI to MCP Server
Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK
Getting Reference Code
Clone the SDK repository for working examples and API documentation:
API Reference (Source Files)

# 핵심 주제

jbandi jbandi
[0]
[0]
업데이트: 3/22/2026

Skill Overview

Start with fit, limitations, and setup before diving into the repository.

적합한 상황: Ideal for AI agents that need add ui to mcp server. 현지화된 요약: # Add UI to MCP Server Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK (@modelcontextprotocol/ext-apps). This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

이 스킬을 사용하는 이유

추천 설명: add-app-to-server helps agents add ui to mcp server. Add UI to MCP Server Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK (@modelcontextprotocol/ext-apps). This AI agent skill

최적의 용도

적합한 상황: Ideal for AI agents that need add ui to mcp server.

실행 가능한 사용 사례 for add-app-to-server

사용 사례: Applying Add UI to MCP Server
사용 사례: Applying Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK
사용 사례: Applying Getting Reference Code

! 보안 및 제한 사항

  • 제한 사항: 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)
  • 제한 사항: Identify tools that could become app-only helpers (data the UI

About The Source

The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.

Labs 데모

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

FAQ 및 설치 단계

These questions and steps mirror the structured data on this page for better search understanding.

? 자주 묻는 질문

add-app-to-server은 무엇인가요?

적합한 상황: Ideal for AI agents that need add ui to mcp server. 현지화된 요약: # Add UI to MCP Server Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK (@modelcontextprotocol/ext-apps). This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

add-app-to-server은 어떻게 설치하나요?

다음 명령을 실행하세요: npx killer-skills add jbandi/mcp-apps-demo/add-app-to-server. Cursor, Windsurf, VS Code, Claude Code와 19개 이상의 다른 IDE에서 동작합니다.

add-app-to-server은 어디에 쓰이나요?

주요 활용 사례는 다음과 같습니다: 사용 사례: Applying Add UI to MCP Server, 사용 사례: Applying Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK, 사용 사례: Applying Getting Reference Code.

add-app-to-server 와 호환되는 IDE는 무엇인가요?

이 스킬은 Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer 와 호환됩니다. 통합 설치에는 Killer-Skills CLI를 사용하세요.

add-app-to-server에 제한 사항이 있나요?

제한 사항: 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). 제한 사항: Identify tools that could become app-only helpers (data the UI.

이 스킬 설치 방법

  1. 1. 터미널 열기

    프로젝트 디렉터리에서 터미널 또는 명령줄을 여세요.

  2. 2. 설치 명령 실행

    npx killer-skills add jbandi/mcp-apps-demo/add-app-to-server 를 실행하세요. CLI가 IDE 또는 에이전트를 자동으로 감지하고 스킬을 설정합니다.

  3. 3. 스킬 사용 시작

    스킬이 이제 활성화되었습니다. 현재 프로젝트에서 add-app-to-server을 바로 사용할 수 있습니다.

! Source Notes

This page is still useful for installation and source reference. Before using it, compare the fit, limitations, and upstream repository notes above.

Upstream Repository Material

The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.

Upstream Source

add-app-to-server

# Add UI to MCP Server Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK (@modelcontextprotocol/ext-apps). This AI agent skill

SKILL.md
Readonly
Upstream Repository Material
The section below comes from the upstream repository. Use it as supporting material alongside the fit, use-case, and installation summary on this page.
Upstream Source

Add UI to MCP Server

Enrich an existing MCP server's tools with interactive UIs using the MCP Apps SDK (@modelcontextprotocol/ext-apps).

How It Works

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.

Getting Reference Code

Clone the SDK repository for working examples and API documentation:

bash
1git clone --branch "v$(npm view @modelcontextprotocol/ext-apps version)" --depth 1 https://github.com/modelcontextprotocol/ext-apps.git /tmp/mcp-ext-apps

API Reference (Source Files)

Read JSDoc documentation directly from /tmp/mcp-ext-apps/src/:

FileContents
src/app.tsApp class, handlers (ontoolinput, ontoolresult, onhostcontextchanged, onteardown), lifecycle
src/server/index.tsregisterAppTool, registerAppResource, getUiCapability, tool visibility options
src/spec.types.tsAll type definitions: McpUiHostContext, CSS variable keys, display modes
src/styles.tsapplyDocumentTheme, applyHostStyleVariables, applyHostFonts
src/react/useApp.tsxuseApp hook for React apps
src/react/useHostStyles.tsuseHostStyles, useHostStyleVariables, useHostFonts hooks

Key Examples (Mixed Tool Patterns)

These examples demonstrate servers with both App-enhanced and plain tools — the exact pattern you're adding:

ExamplePattern
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)

Framework Templates

Learn and adapt from /tmp/mcp-ext-apps/examples/basic-server-{framework}/:

TemplateKey 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

Step 1: Analyze Existing Tools

Before writing any code, analyze the server's existing tools and determine which ones benefit from UI.

  1. Read the server source and list all registered tools
  2. For each tool, assess whether it would benefit from UI (returns data that could be visualized, involves user interaction, etc.) vs. is fine as text-only (simple lookups, utility functions)
  3. Identify tools that could become app-only helpers (data the UI needs to poll/fetch but the model doesn't need to call directly)
  4. Present the analysis to the user and confirm which tools to enhance

Decision Framework

Tool output typeUI benefitExample
Structured data / lists / tablesHigh — interactive table, search, filteringList of items, search results
Metrics / numbers over timeHigh — charts, gauges, dashboardsSystem stats, analytics
Media / rich contentHigh — viewer, player, rendererMaps, PDFs, images, video
Simple text / confirmationsLow — text is fine"File created", "Setting updated"
Data for other toolsConsider app-onlyPolling endpoints, chunk loaders

Step 2: Add Dependencies

bash
1npm install @modelcontextprotocol/ext-apps 2npm install -D vite vite-plugin-singlefile

Plus framework-specific dependencies if needed (e.g., react, react-dom, @vitejs/plugin-react for React).

Use npm install to add dependencies rather than manually writing version numbers. This lets npm resolve the latest compatible versions. Never specify version numbers from memory.

Step 3: Set Up the Build Pipeline

Vite Configuration

Create vite.config.ts with vite-plugin-singlefile to bundle the UI into a single HTML file:

typescript
1import { defineConfig } from "vite"; 2import { viteSingleFile } from "vite-plugin-singlefile"; 3 4export default defineConfig({ 5 plugins: [viteSingleFile()], 6 build: { 7 outDir: "dist", 8 rollupOptions: { 9 input: "mcp-app.html", // one per UI, or one shared entry 10 }, 11 }, 12});

HTML Entry Point

Create mcp-app.html (or one per distinct UI if tools need different views):

html
1<!doctype html> 2<html lang="en"> 3 <head> 4 <meta charset="UTF-8" /> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 6 <title>MCP App</title> 7 </head> 8 <body> 9 <div id="root"></div> 10 <script type="module" src="./src/mcp-app.ts"></script> 11 </body> 12</html>

Build Scripts

Add build scripts to package.json. The UI must be built before the server code bundles it:

json
1{ 2 "scripts": { 3 "build:ui": "vite build", 4 "build:server": "tsc", 5 "build": "npm run build:ui && npm run build:server", 6 "serve": "tsx server.ts" 7 } 8}

Step 4: Convert Tools to App Tools

Transform plain MCP tools into App tools with UI.

Before (plain MCP tool):

typescript
1server.tool("my-tool", { param: z.string() }, async (args) => { 2 const data = await fetchData(args.param); 3 return { content: [{ type: "text", text: JSON.stringify(data) }] }; 4});

After (App tool with UI):

typescript
1import { registerAppTool, registerAppResource, RESOURCE_MIME_TYPE } from "@modelcontextprotocol/ext-apps/server"; 2 3const resourceUri = "ui://my-tool/mcp-app.html"; 4 5registerAppTool(server, "my-tool", { 6 description: "Shows data with an interactive UI", 7 inputSchema: { param: z.string() }, 8 _meta: { ui: { resourceUri } }, 9}, async (args) => { 10 const data = await fetchData(args.param); 11 return { 12 content: [{ type: "text", text: JSON.stringify(data) }], // text fallback for non-UI hosts 13 structuredContent: { data }, // structured data for the UI 14 }; 15});

Key guidance:

  • Always keep the content array with a text fallback for text-only clients
  • Add structuredContent for data the UI needs to render
  • Link the tool to its resource via _meta.ui.resourceUri
  • Leave tools that don't benefit from UI unchanged — they stay as plain tools

Step 5: Register Resources

Register the HTML resource so the host can fetch it:

typescript
1import fs from "node:fs/promises"; 2import path from "node:path"; 3 4const resourceUri = "ui://my-tool/mcp-app.html"; 5 6registerAppResource(server, { 7 uri: resourceUri, 8 name: "My Tool UI", 9 mimeType: RESOURCE_MIME_TYPE, 10}, async () => { 11 const html = await fs.readFile( 12 path.resolve(import.meta.dirname, "dist", "mcp-app.html"), 13 "utf-8", 14 ); 15 return { contents: [{ uri: resourceUri, mimeType: RESOURCE_MIME_TYPE, text: html }] }; 16});

If multiple tools share the same UI, they can reference the same resourceUri and the same resource registration.

Step 6: Build the UI

Handler Registration

Register ALL handlers BEFORE calling app.connect():

typescript
1import { App, PostMessageTransport, applyDocumentTheme, applyHostStyleVariables, applyHostFonts } from "@modelcontextprotocol/ext-apps"; 2 3const app = new App({ name: "My App", version: "1.0.0" }); 4 5app.ontoolinput = (params) => { 6 // Render the UI using params.arguments and/or params.structuredContent 7}; 8 9app.ontoolresult = (result) => { 10 // Update UI with final tool result 11}; 12 13app.onhostcontextchanged = (ctx) => { 14 if (ctx.theme) applyDocumentTheme(ctx.theme); 15 if (ctx.styles?.variables) applyHostStyleVariables(ctx.styles.variables); 16 if (ctx.styles?.css?.fonts) applyHostFonts(ctx.styles.css.fonts); 17 if (ctx.safeAreaInsets) { 18 const { top, right, bottom, left } = ctx.safeAreaInsets; 19 document.body.style.padding = `${top}px ${right}px ${bottom}px ${left}px`; 20 } 21}; 22 23app.onteardown = async () => { 24 return {}; 25}; 26 27await app.connect(new PostMessageTransport());

Host Styling

Use host CSS variables for theme integration:

css
1.container { 2 background: var(--color-background-secondary); 3 color: var(--color-text-primary); 4 font-family: var(--font-sans); 5 border-radius: var(--border-radius-md); 6}

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.

Optional Enhancements

App-Only Helper Tools

Tools the UI calls but the model doesn't need to invoke directly (polling, pagination, chunk loading):

typescript
1registerAppTool(server, "poll-data", { 2 description: "Polls latest data for the UI", 3 _meta: { ui: { resourceUri, visibility: ["app"] } }, 4}, async () => { 5 const data = await getLatestData(); 6 return { content: [{ type: "text", text: JSON.stringify(data) }] }; 7});

The UI calls these via app.callServerTool("poll-data", {}).

CSP Configuration

If the UI needs to load external resources (fonts, APIs, CDNs), declare the domains:

typescript
1registerAppResource(server, { 2 uri: resourceUri, 3 name: "My Tool UI", 4 mimeType: RESOURCE_MIME_TYPE, 5 _meta: { 6 ui: { 7 connectDomains: ["api.example.com"], // fetch/XHR targets 8 resourceDomains: ["cdn.example.com"], // scripts, styles, images 9 frameDomains: ["embed.example.com"], // nested iframes 10 }, 11 }, 12}, async () => { /* ... */ });

Streaming Partial Input

For large tool inputs, show progress during LLM generation:

typescript
1app.ontoolinputpartial = (params) => { 2 const args = params.arguments; // Healed partial JSON - always valid 3 // Render preview with partial data 4}; 5 6app.ontoolinput = (params) => { 7 // Final complete input - switch to full render 8};

Graceful Degradation with getUiCapability()

Conditionally register App tools only when the client supports UI, falling back to text-only tools:

typescript
1import { getUiCapability, registerAppTool, RESOURCE_MIME_TYPE } from "@modelcontextprotocol/ext-apps/server"; 2 3server.server.oninitialized = () => { 4 const clientCapabilities = server.server.getClientCapabilities(); 5 const uiCap = getUiCapability(clientCapabilities); 6 7 if (uiCap?.mimeTypes?.includes(RESOURCE_MIME_TYPE)) { 8 // Client supports UI — register App tool 9 registerAppTool(server, "my-tool", { 10 description: "Shows data with interactive UI", 11 _meta: { ui: { resourceUri } }, 12 }, appToolHandler); 13 } else { 14 // Text-only client — register plain tool 15 server.tool("my-tool", "Shows data", { param: z.string() }, plainToolHandler); 16 } 17};

Fullscreen Mode

Allow the UI to expand to fullscreen:

typescript
1app.onhostcontextchanged = (ctx) => { 2 if (ctx.availableDisplayModes?.includes("fullscreen")) { 3 fullscreenBtn.style.display = "block"; 4 } 5 if (ctx.displayMode) { 6 container.classList.toggle("fullscreen", ctx.displayMode === "fullscreen"); 7 } 8}; 9 10async function toggleFullscreen() { 11 const newMode = currentMode === "fullscreen" ? "inline" : "fullscreen"; 12 const result = await app.requestDisplayMode({ mode: newMode }); 13 currentMode = result.mode; 14}

Common Mistakes to Avoid

  1. Forgetting text content fallback — Always include content array with text for non-UI hosts
  2. Registering handlers after connect() — Register ALL handlers BEFORE calling app.connect()
  3. Missing vite-plugin-singlefile — Without it, assets won't load in the sandboxed iframe
  4. Forgetting resource registration — The tool references a resourceUri that must have a matching resource
  5. Hardcoding styles — Use host CSS variables (var(--color-*)) for theme integration
  6. Not handling safe area insets — Always apply ctx.safeAreaInsets in onhostcontextchanged

Testing

Using basic-host

Test the enhanced server with the basic-host example:

bash
1# Terminal 1: Build and run your server 2npm run build && npm run serve 3 4# Terminal 2: Run basic-host (from cloned repo) 5cd /tmp/mcp-ext-apps/examples/basic-host 6npm install 7SERVERS='["http://localhost:3001/mcp"]' npm run start 8# Open http://localhost:8080

Configure SERVERS with a JSON array of your server URLs (default: http://localhost:3001/mcp).

Verify

  1. Plain tools still work and return text output
  2. App tools render their UI in the iframe
  3. ontoolinput handler fires with tool arguments
  4. ontoolresult handler fires with tool result
  5. Host styling (theme, fonts, colors) applies correctly

관련 스킬

Looking for an alternative to add-app-to-server or another community skill for your workflow? Explore these related open-source skills.

모두 보기

openclaw-release-maintainer

Logo of openclaw
openclaw

현지화된 요약: 🦞 # OpenClaw Release Maintainer Use this skill for release and publish-time workflow. It covers ai, assistant, crustacean workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

333.8k
0
인공지능

widget-generator

Logo of f
f

현지화된 요약: Generate customizable widget plugins for the prompts.chat feed system # Widget Generator Skill This skill guides creation of widget plugins for prompts.chat . It covers ai, artificial-intelligence, awesome-list workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf

149.6k
0
인공지능

flags

Logo of vercel
vercel

현지화된 요약: The React Framework # Feature Flags Use this skill when adding or changing framework feature flags in Next.js internals. It covers blog, browser, compiler workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

138.4k
0
브라우저

pr-review

Logo of pytorch
pytorch

현지화된 요약: Usage Modes No Argument If the user invokes /pr-review with no arguments, do not perform a review . It covers autograd, deep-learning, gpu workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

98.6k
0
개발자