taliawedged117/census-mcp-server/add-app-tool
Claude Code and agent skill by taliawedged117/census-mcp-server
- community
Checking that the SKILL.md file is still in the repository.
Scaffold an MCP App tool + UI resource pair. Use when the user asks to add a tool with interactive UI, create an MCP App, or build a visual/interactive tool.
Install
npx vskill@latest install taliawedged117/census-mcp-server/add-app-toolSKILL.md
The same SKILL.md was published earlier as ficaviolaodorata520/met-museum-mcp-server/add-app-tool.
When to Use
App tools are rarely the right choice. Reach for one only when all of the following hold:
- A human will actively interact with the result in real time — not just an LLM consuming text.
- The target deployment runs in a client that supports MCP Apps. Many clients (Claude Code, Cursor, most chat UIs) are tool-only and will only ever see the
format()text fallback you have to maintain anyway. - The interaction the UI enables — scrubbing a dense table, approving a multi-step plan, filling a structured form — is core to the workflow, not nice-to-have rendering.
App tools cost more than standard tools: an iframe + CSP setup, app.ontoolresult / callServerTool plumbing, host-context wiring (theme, fonts, styles), and a format() text path that has to be content-complete because most clients see only that. Two surfaces to keep in sync, two failure modes per change.
Default to add-tool. This skill is the how-to once that bar is cleared — the "whether to" decision belongs in design-mcp-server.
Context
MCP Apps extend the standard tool pattern with an interactive HTML UI rendered in a sandboxed iframe by the host. Each MCP App consists of two definitions:
- App tool (
.app-tool.ts) — usesappTool()builder, declaresresourceUripointing to the UI resource - App resource (
.app-resource.ts) — usesappResource()builder, serves the bundled HTML
Both builders are exported from @cyanheads/mcp-ts-core. They handle _meta.ui.resourceUri, the compat key (ui/resourceUri), and the correct MIME type (text/html;profile=mcp-app) automatically.
For the full API, Context interface, and error codes, read the framework's CLAUDE.md/AGENTS.md (loaded at session start).
Steps
- Confirm the three conditions in "When to Use" apply — if any is uncertain, default to
add-toolinstead. Then gather the tool's name, purpose, input/output shape, and what the UI should display from the user's request — ask only if genuinely absent - Choose a URI — convention:
ui://{{tool-name}}/app.html - Create the app tool at
src/mcp-server/tools/definitions/{{tool-name}}.app-tool.ts - Create the app resource at
src/mcp-server/resources/definitions/{{tool-name}}-ui.app-resource.ts - Register both in the project's existing
createApp()arrays (directly insrc/index.tsfor fresh scaffolds, or via barrels if the repo already has them) - Run `bun run devcheck` — the linter validates
_meta.uiand cross-checks tool/resource pairing - Smoke-test with
bun run rebuild && bun run start:stdio(orstart:http)
App Tool Template
App Resource Template
UI Notes
- Ship self-contained HTML. Author with Vite +
vite-plugin-singlefileor inline the SDK. Live CDN imports in aui://resource are a CSP footgun (every domain has to be whitelisted on_meta.ui.csp.resourceDomains), a supply-chain footgun (third-party JS executes inside the host's iframe), and a runtime footgun (every render needs network). Theunpkgline in the template is for prototyping only. - CSP. MCP Apps iframes run under deny-by-default CSP. With
appResource(), put_meta.ui.csp.resourceDomainson the definition; the builder mirrors it into returnedresources/readcontent items. With plainresource(), attach_meta.uiyourself informat(). - Adopt the host's visual identity, don't impose your own. App UIs render inside the host's iframe alongside its native UI. Three host hooks layer on top of your CSS:
applyDocumentTheme(hostContext.theme)— setscolor-schemeand adata-themeattribute on<html>applyHostStyleVariables(hostContext.styles.variables)— installs host CSS custom properties on:root(host decides the names, e.g.--mcp-color-bg-primary)applyHostFonts(hostContext.styles.css.fonts)— installs@font-facerules for the host's font stack
Author CSS to consume these via var(--mcp-color-bg-primary, /* fallback */ #fff). Don't hardcode brand colors that fight the host.
- Pre-connect baseline.
app.connect()is async — host context arrives a frame or two after first paint. Without a baseline, the UI flashes unstyled or wrong-themed on light hosts. Ship aprefers-color-scheme-aware default so the first frame is sensible:
``css :root { color-scheme: light dark; --bg: #fff; --fg: #111; } @media (prefers-color-scheme: dark) { :root { --bg: #0c0d12; --fg: #ededef; } } body { background: var(--bg); color: var(--fg); } ``
Host vars override these once onhostcontextchanged fires.
- `format()` for app tools. The first
textcontent block is typically JSON that the UI parses viaontoolresult. Additional blocks are the human-readable fallback that non-app hosts and LLMs consume — they must render every field the LLM needs to reason about. JSON-only payloads leave model-visible context blind. - App resource `format()`.
appResource()already preserves raw HTML for the default app MIME type and mirrors definition_meta.uiinto content items. Add a customformat()only when you need extra per-read metadata or non-default content shaping.
Registration
If the repo already uses definitions/index.ts barrels, update those instead of changing the registration pattern.
Checklist
- [ ] App tool created at
src/mcp-server/tools/definitions/{{tool-name}}.app-tool.tsusingappTool() - [ ] App resource created at
src/mcp-server/resources/definitions/{{tool-name}}-ui.app-resource.tsusingappResource() - [ ]
resourceUrimatches between tool and resource (ui://{{tool-name}}/app.html) - [ ] Zod schemas: all fields have
.describe(), only JSON-Schema-serializable types - [ ]
format()first block isJSON.stringify(result)— the full output object for the UI to parse viaapp.ontoolresult. Subsequent blocks are human-readable, content-complete fallback for non-app hosts and LLMs - [ ] App resource
_meta.ui.csp.resourceDomainslists every external domain loaded by the UI - [ ] UI bundles or inlines the client SDK for the shipped HTML, and handles
app.ontoolresult - [ ] UI applies host context updates via
app.onhostcontextchanged - [ ] App resource has a
listcallback returning at least one URI so resource-aware clients can discover it - [ ] Both registered in the project's existing
createApp()arrays (directly or via barrels) - [ ] Handler tested directly via
createMockContext(), oradd-testskill run to scaffold the test file - [ ]
bun run devcheckpasses (linter validates_meta.uiand tool/resource pairing) - [ ] Smoke-tested with
bun run rebuild && bun run start:stdio(orstart:http)
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/add-app-tool/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/taliawedged117/census-mcp-server/add-app-tool)