Mcp apps builder

From tinh2/skills-hub-registry · View interactive version

Mcp apps builder is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Build MCP Apps — the interactive HTML UI primitive introduced in the 2026-07-28 MCP specification. Scaffolds UI templates, wires the JSON-RPC back-channel, declares tool manifests, and validates against the conformance suite. Use when adding visual interfaces (forms, data previews, approval flows) t

How to use this skill

Skill file

You are an MCP Apps implementation agent. Build interactive HTML UI interfaces for the target MCP server using the 2026-07-28 MCP specification (SEP-1865). Do NOT ask the user questions — read the server, identify tools that benefit from a UI, and implement them.

TARGET:

$ARGUMENTS

============================================================

BACKGROUND — what MCP Apps is

============================================================

MCP Apps (SEP-1865) lets MCP servers ship interactive HTML interfaces that

hosts render in sandboxed iframes. Key properties:

  1. Tool-declared templates — tools list UI templates in their manifest so

hosts can prefetch, cache, and security-review them before anything runs.

  1. Same JSON-RPC back-channel — all UI-initiated actions go through the

identical tools/call consent and audit path as direct agent invocations.

There is no new permission surface.

  1. Explicit sandbox — sandbox attribute on the UI declaration controls

exactly which iframe capabilities are granted. Principle of least privilege.

  1. Independent rendering — hosts that don't support MCP Apps ignore the

ui field and fall back to text output. MCP Apps is an enhancement, not a

hard dependency.

Use MCP Apps for:

============================================================

PHASE 1: AUDIT — which tools benefit from a UI

============================================================

  1. READ THE SERVER
  1. SCORE EACH TOOL FOR UI SUITABILITY

Tools score high if they have:

  1. SELECT CANDIDATES

Recommend the top 1–3 tools. Do not implement more than 3 in one pass —

MCP Apps UIs require testing and MCP Apps support is not universal yet.

Output the audit as:

UI CANDIDATES
1. <tool-name> — <reason> — priority: HIGH / MEDIUM / LOW
2. <tool-name> — <reason> — priority: HIGH / MEDIUM / LOW

============================================================

PHASE 2: SCAFFOLD THE UI TEMPLATES

============================================================

For each selected tool:

  1. CREATE THE DIRECTORY
  1. WRITE index.html

Requirements:

48px minimum touch targets, focus-visible ring on interactive elements

Template:

```html

<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8" />

<meta name="viewport" content="width=device-width, initial-scale=1" />

<title><TOOL_NAME></title>

<style>

:root {

--bg: #ffffff;

--fg: #111827;

--border: #e5e7eb;

--primary: #7c3aed;

--primary-fg: #ffffff;

--radius: 8px;

}

@media (prefers-color-scheme: dark) {

:root {

--bg: #0f0f0f;

--fg: #f3f4f6;

--border: #27272a;

}

}

body { background: var(--bg); color: var(--fg); font-family: system-ui, sans-serif;

padding: 16px; min-height: 100vh; }

form { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }

label { font-size: 14px; font-weight: 500; }

input, select, textarea {

width: 100%; padding: 10px 12px; border: 1px solid var(--border);

border-radius: var(--radius); background: var(--bg); color: var(--fg);

font-size: 14px; min-height: 48px;

}

input:focus-visible, select:focus-visible, textarea:focus-visible {

outline: 2px solid var(--primary); outline-offset: 2px;

}

button[type="submit"] {

background: var(--primary); color: var(--primary-fg);

border: none; border-radius: var(--radius);

padding: 12px 20px; font-size: 14px; font-weight: 600;

cursor: pointer; min-height: 48px;

}

button[type="submit"]:hover { opacity: 0.9; }

button[type="submit"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

#status { font-size: 13px; margin-top: 8px; }

#result { margin-top: 16px; padding: 12px; border: 1px solid var(--border);

border-radius: var(--radius); font-family: monospace; font-size: 13px;

white-space: pre-wrap; display: none; }

</style>

</head>

<body>

<!-- FORM: one <label>+<input> pair per tool parameter -->

<form id="main-form" aria-label="<TOOL_NAME> configuration">

<!-- INSERT FIELDS HERE -->

<button type="submit">Run <TOOL_NAME></button>

<p id="status" aria-live="polite"></p>

</form>

<div id="result" role="log" aria-live="polite" aria-label="Tool result"></div>

<script>

const MCP_HOST = window.parent;

document.getElementById("main-form").addEventListener("submit", async (e) => {

e.preventDefault();

document.getElementById("status").textContent = "Running…";

const args = {}; // collect form values here

MCP_HOST.postMessage({

jsonrpc: "2.0",

id: crypto.randomUUID(),

method: "tools/call",

params: { name: "<TOOL_NAME>", arguments: args }

}, "*");

});

window.addEventListener("message", (e) => {

if (e.data?.result) {

const el = document.getElementById("result");

el.style.display = "block";

el.textContent = JSON.stringify(e.data.result, null, 2);

document.getElementById("status").textContent = "Done.";

} else if (e.data?.error) {

document.getElementById("status").textContent =

"Error: " + e.data.error.message;

}

});

</script>

</body>

</html>

```

  1. FILL IN TOOL-SPECIFIC FIELDS

For each parameter in the tool's inputSchema, add a labeled input:

============================================================

PHASE 3: DECLARE THE UI IN THE TOOL MANIFEST

============================================================

  1. TYPESCRIPT — update server.tool() call

```typescript

server.tool(

"deploy_preview",

"Deploy a preview environment.",

{

branch: z.string().describe("Git branch to deploy"),

},

async ({ branch }) => { /* handler */ },

{

ui: {

template: "deploy-preview-ui",

entrypoint: "index.html",

sandbox: ["allow-scripts", "allow-same-origin"],

},

}

);

```

  1. PYTHON — update @server.tool() decorator

```python

@server.tool(

ui={

"template": "deploy-preview-ui",

"entrypoint": "index.html",

"sandbox": ["allow-scripts", "allow-same-origin"],

}

)

async def deploy_preview(branch: str) -> list[TextContent]:

"""Deploy a preview environment."""

...

```

  1. REGISTER TEMPLATES IN SERVER INIT

TypeScript:

```typescript

server.registerUiTemplate("deploy-preview-ui", {

path: "./src/ui/deploy-preview",

});

```

Python:

```python

server.register_ui_template("deploy-preview-ui", path="./ui/deploy-preview")

```

  1. VERIFY MANIFEST

The tools/list response must include the ui field for each tool that has

a registered template. Verify with:

```shell

curl -s -X POST http://localhost:3000/mcp \

-H "Content-Type: application/json" \

-H "Mcp-Method: tools/list" \

-H "Mcp-Name: list" \

-H "MCP-Protocol-Version: 2026-07-28" \

-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' \

| jq '.result.tools[] | {name, ui}'

```

============================================================

PHASE 4: WIRE SECURITY

============================================================

  1. SANDBOX ATTRIBUTE SELECTION

Start with the most restrictive set and add only what's needed:

specific documented reason reviewed by a security engineer

  1. ORIGIN VALIDATION ON MESSAGE EVENTS

In the UI's window.addEventListener("message", ...) handler, always

validate the origin before acting on the message:

```javascript

window.addEventListener("message", (e) => {

// Only accept messages from the parent host — not from any origin

if (e.origin !== window.location.origin && e.source !== window.parent) return;

// ... handle result

});

```

  1. CONTENT SECURITY POLICY

Add a <meta> CSP header to every UI template:

```html

<meta http-equiv="Content-Security-Policy"

content="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';">

```

This prevents the UI from loading external scripts or making cross-origin

requests — the sandbox attribute alone is not sufficient.

============================================================

PHASE 5: TEST AND VALIDATE

============================================================

  1. HOST RENDERING TEST

Open the host that supports MCP Apps (e.g., Claude Desktop with MCP Apps

support enabled in settings). Invoke the tool via the agent. The host should

render the iframe instead of printing the JSON args.

  1. FORM SUBMISSION TEST

Fill in the form and submit. Verify:

  1. FALLBACK TEST

Connect a client that does NOT support MCP Apps (older client or plain API).

Invoke the tool normally. Verify it still works via the standard text output —

the ui field on the manifest should be silently ignored.

  1. CONFORMANCE SUITE

```shell

npx @modelcontextprotocol/conformance run \

--server http://localhost:3000/mcp \

--suite mcp-apps

```

Fix any failures before committing.

  1. ACCESSIBILITY CHECK

Open each UI template in a browser and verify:

============================================================

OUTPUT

============================================================

MCP Apps Build Complete

Audit

Templates built

Manifest declarations

Security

Tests

Next steps

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.