/webmcp:webmcpfrom WebMCP
Makes websites usable by in-browser AI agents via WebMCP. Guides planning which paths to expose and shipping them as declarative form annotations, imperative tools, or a bridge to an existing MCP server.
Ships in WebMCP. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
WebMCP lets a page register tools that in-browser AI agents can call. It is not a remote MCP server and not an MCP App / ChatGPT widget.
Canonical surface: document.modelContext.registerTool(...).
Fallback (deprecated): navigator.modelContext.
Declarative surface: HTML <form> attributes (toolname, tooldescription).
document.modelContext, navigator.modelContext, registerTool,
webmcp-proxy, or declarative form toolsDo not use this skill for building remote MCP servers, ChatGPT/Claude MCP Apps, or Skybridge UIs.
Copy and track:
WebMCP Progress:
- [ ] 1. Design: inventory + strategy + paths (stop for user agreement)
- [ ] 2. Wire runtime (native / polyfill) if the chosen strategy needs JS
- [ ] 3. Implement the agreed strategy (Declarative / Imperative / Bridge)
- [ ] 4. Dogfood with Chrome DevTools MCP
- [ ] 5. Harden (security, lifecycle, errors)
Do not implement until step 1 is agreed. Path choice is a product decision.
Read references/strategies.md first.
Talk to the user. Propose; do not assume. Goal: a short list of paths and which strategy ships each one.
main.tsx, router root) and stack
(vanilla / React-Next / Vue / other). If several apps exist, ask which one
first.<form>s that should become tools as-is?Declarative — expose existing forms as tools. Add missing WebMCP meta on
existing form DOM (toolname, tooldescription, toolparamdescription,
optional toolautosubmit) so each form is a declarative tool. Fast, visual
(browser fills the form). See references/declarative-forms.md.
Imperative — craft dedicated paths. Unlike Declarative tools (via form),
registerTool packages a real agent path. Example: a 4-step checkout tunnel as
one tool from step 1 that fills everything and redirects to the last step.
Plan with the user: which scenarios, what input, what UI/state outcome.
See references/tool-design.md.
Bridge — expose an existing MCP server. Reuse the tools and paths already
designed for a shipped MCP server. webmcp-proxy is a fast first patch that
registers those tools on WebMCP for any AI browsing agent. It lacks visual
feedback in the browser. It can leverage existing webapp credentials if
the MCP server uses the same OAuth client. See
references/proxy-existing-mcp.md.
Proposed WebMCP paths:
- [strategy] path — input → UI/state outcome
- …
Out of scope this round: …
Skip a polyfill for Declarative only if you are not registering JS tools.
Imperative and Bridge need document.modelContext (native or polyfill).
function getModelContext() {
return document.modelContext ?? navigator.modelContext ?? null;
}
| Situation | What to do |
|---|---|
| Target browsers with native WebMCP | Feature-detect; graceful no-op if missing |
| Need tools without native support | @mcp-b/webmcp-polyfill (or @mcp-b/global) before register/proxy |
| Bridge (existing MCP HTTP/SSE) | webmcp-proxy — do not reimplement each tool |
Secure context (HTTPS or localhost) is required. Details: references/runtime.md.
Patch templates/components: attributes only, plus optional respondWith if the
agent should get a structured result. Do not rewrite forms into JS tools unless
the user switched to Imperative.
Default = imperative API. Snippets: references/frameworks.md.
const mc = document.modelContext ?? navigator.modelContext;
if (!mc?.registerTool) {
// Browser has no WebMCP — leave human UI working; skip registration.
} else {
const controller = new AbortController();
await mc.registerTool(
{
name: "search_docs",
title: "Search docs",
description:
"Search published documentation by keyword and return up to five matches.",
inputSchema: {
type: "object",
properties: {
query: {
type: "string",
description: "Topic or phrase to search for.",
},
},
required: ["query"],
},
annotations: {
readOnlyHint: true,
untrustedContentHint: false,
},
async execute({ query }, { signal }) {
const res = await fetch(
`/api/search?q=${encodeURIComponent(query)}`,
{ signal },
);
if (!res.ok) {
throw new Error(`Search failed (${res.status}). Retry with a shorter query.`);
}
const hits = await res.json();
return { matches: hits.slice(0, 5) };
},
},
{ signal: controller.signal },
);
}
Hard requirements for imperative tools:
registerTool{ signal } on registration for cleanupexecute’s { signal } for fetch / long workannotations.readOnlyHint accuratelyuntrustedContentHint: true when return data comes from users / third partiesdescription or return payloads[a-zA-Z0-9_.-], length 1–128; one tool = one agreed pathInstall webmcp-proxy, point it at the MCP URL, confirm CORS and OAuth. Do not
hand-wrap each remote tool.
See references/proxy-existing-mcp.md.
Do not call the work done until tools are exercised as an agent would.
With Chrome DevTools MCP (Chrome Dev 145+ / Canary preferred):
navigate_page / existing tab)list_webmcp_tools — confirm names match the agreed proposalexecute_webmcp_tool with toolName + JSON input string for each toolIf DevTools MCP isn’t available, use page console:
const tools = await document.modelContext.getTools();
console.table(tools.map(t => ({ name: t.name, description: t.description })));
Checklist: references/verify.md.
allow="tools"; child tools use
exposedTo: ['https://parent.origin'] when sharingMore: references/security.md.
Need WebMCP on this site?
│
├─ Ping-pong paths with the user first (never skip)
│
├─ Existing HTML forms that should stay forms?
│ → Declarative: toolname / tooldescription
│
├─ Packaged agent scenario (tunnels, store updates, redirects)?
│ → Imperative: registerTool
│
└─ Existing remote MCP tools to reuse on the page?
→ Bridge: webmcp-proxy
webmcp-proxynavigator.modelContext alone with no document.modelContext preferunregisterTool() (removed) instead of aborting the registration signalexecutereferences/declarative-forms.md (opens in a new tab)references/frameworks.md (opens in a new tab)references/proxy-existing-mcp.md (opens in a new tab)references/runtime.md (opens in a new tab)references/security.md (opens in a new tab)references/strategies.md (opens in a new tab)references/tool-design.md (opens in a new tab)references/verify.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alpic-ai/webmcp --plugin webmcpOther plugins' skills for the same job