WebMCP
WebMCP is a JavaScript API, incubated as a Draft Community Group Report in the W3C Web Machine Learning Community Group, that lets a web page register tools (functions with natural language descriptions and JSON Schema inputs) for agents, browser agents and assistive technologies to call. With this skill the agent registers, scopes, annotates and unregisters page tools, and reviews them against the draft's security and privacy considerations.
Follow the workflow below step by step. Every rule here comes from a source in Sources, with the section it cites (§ names refer to the WebMCP draft). When a rule and the pinned source disagree, the source wins; when the source has a newer revision than the pin, follow the refresh steps.
Draft posture: build, pinned to the Draft Community Group Report of 30 September 2026, commit d61d0e6d297ddb6bff3510b1330dbb215c6ef43c. The API can change without notice; feature-detect it and keep tool logic behind a thin registration layer.
Inputs (fill in, or ask before starting)
- Role: tool owner (a page that registers tools), in-page agent (a page or iframe that discovers and executes tools), or reviewer.
- Embedding: top-level only, or same-origin or cross-origin iframes that register or consume tools.
- Target version: the WebMCP Draft Community Group Report (default, posture build: implement it at the pinned commit). The WebMCP navigator.modelContext drafts are legacy: read them and upgrade from them, never write new code against them. No preview exists. See
references/versions.md. - Revision: the pinned commit in Sources, unless the user names another.
- Sources: when refreshing this skill or when a rule looks out of date, re-read every URL in Sources, compare the repository's latest commit and the published report date with the pin, check the implementation status page, and update the pins.
Invariants
- The entry point is
document.modelContext(§ Extensions to Document). Earlier drafts usednavigator.modelContext; the getter moved toDocumentin pull request #184. Feature-detect with"modelContext" in document. - Secure contexts only.
modelContext,ModelContextand the event interfaces are[SecureContext](WebIDL in § API). - Tool names are unique per document, 1 to 128 characters of ASCII alphanumerics,
_,-or., anddescriptionis non-empty; otherwiseregisterTool()rejects withInvalidStateError(§ ModelContext Interface, registerTool steps). inputSchemamust serialize to JSON; serialization errors reject registration (registerTool steps). The schema is a JSON Schema object (§ ModelContextTool Dictionary).- Unregister by aborting the
signalpassed at registration (§ ModelContextRegisterToolOptions). Unregistering does not cancel an execution already in progress (§ unregister a tool, note). - Results must be JSON-serializable. The
executepromise's value is serialized to a JSON string; a value that cannot be serialized fails the call (§ imperative execute steps). - Access is gated by the
toolspolicy-controlled feature with default allowlist'self'(§ Permissions policy integration). Cross-origin iframes needallow="tools";Permissions-Policy: tools=()disables WebMCP for a document and all its descendants (§ Mitigations). - Tools are not exposed cross-origin unless listed in
exposedTo, which only accepts potentially trustworthy origins (registerTool steps; Chrome imperative API guide). - Hints are hints. Annotations do not enforce anything; the tool's
executecallback must still validate inputs, authorization and preconditions (explainer, Best Practices).
Workflow
- Pick the version. Use the current draft. If the code uses
navigator.modelContext,unregisterTool(),provideContext()orrequestUserInteraction(), it is navigator-era: plan the upgrade (step 8). ->references/versions.md✓ New code targetsdocument.modelContextat the pinned commit. - Decide which tools to expose. One well-defined function per tool, few tools per page state, names and descriptions that say what the tool does.
->
references/api.md✓ Every tool has a valid unique name, a description, and an input schema with adescriptionon each property. - Register tools. Call
document.modelContext.registerTool(tool, { signal })after feature detection, inside a secure context. ->references/api.md✓ Registration resolves; anAbortControllerper tool or per page state controls its lifetime. - Annotate. Set
readOnlyHint,untrustedContentHintandconsequentialHintfrom what the tool actually does. ->references/api.md,references/security.md✓ Read-only tools say so; tools that return user-generated or external content setuntrustedContentHint; purchases, transfers and deletions setconsequentialHint. - Handle execution. Validate inputs, check authorization against current state, honor
options.signal, return JSON-serializable results and clear error messages, and update the visible UI. ->references/api.md✓ Calls with stale or invalid arguments fail with an actionable message instead of acting. - Scope embedding. Set
Permissions-Policyand iframeallowattributes; useexposedToandfromOriginsonly for origins you trust. ->references/security.md✓ Documents that should not register tools sendPermissions-Policy: tools=(); no tool is exposed to an origin you would not share the data with. - Review security and privacy. Check tool metadata, inputs and outputs against the draft's risk list.
->
references/security.md✓ No tool asks for parameters it does not need, and no tool path skips checks the UI path performs. - Upgrade (only when asked). Follow the navigator-era checklist: move to
document.modelContext, awaitregisterTool(), unregister with anAbortSignal, and replacerequestUserInteraction()with page UI. ->references/versions.md✓ Nonavigator.modelContext,unregisterTool()orModelContextClientremains, and the tools behave as before.
Verify before done
- Code uses
document.modelContext, notnavigator.modelContext, and does nothing when the API is absent. - Every tool name matches
^[A-Za-z0-9_.-]{1,128}$and is unique in its document. - Each
registerTool()call either passes asignalor is meant to live for the whole document. -
executereturns JSON-serializable values and handlesoptions.signal. - Annotations match behavior: no
readOnlyHint: trueon a tool that changes state. - The
toolsPermissions-Policy and iframeallowattributes match where tools should run. - Tool inputs are validated and authorized in
execute, as for any other client-side entry point.
Reference index
references/versions.md: the current draft and the navigator-era drafts, what changed between them, and the upgrade checklist. Load for steps 1 and 8.references/api.md: the WebIDL, every dictionary member, registration and unregistration rules, execution, discovery, events, and examples. Load for steps 2 to 5.references/security.md: Permissions-Policy, cross-origin exposure, annotations as mitigations, and the draft's prompt injection, misrepresentation, over-parameterization and private browsing risks. Load for steps 4, 6 and 7.
Related skills
mcp-authorizationfor authorization of server-side MCP tools, which WebMCP mirrors in the browser:npx skills add ScaleDockHQ/scaledock-skills --skill mcp-authorization.owasp-agenticfor reviewing tool misuse, goal hijack and human-in-the-loop controls:npx skills add ScaleDockHQ/scaledock-skills --skill owasp-agentic.
Sources
Status uses the publishing body's own maturity term. Checked is the date the source was last read.
- WebMCP (published report): Draft Community Group Report (W3C Web Machine Learning CG), 30 September 2026, checked 2026-10-02. Draft posture: build.
- WebMCP spec source, index.bs: Draft Community Group Report, commit d61d0e6 (2026-09-30), checked 2026-10-05. Draft posture: build.
- WebMCP explainer, README.md: Explainer (non-normative), commit d61d0e6 (2026-09-30), checked 2026-10-02.
- WebMCP implementation status: Informative, commit d61d0e6 (2026-09-30), checked 2026-10-02.
- WebMCP pull request #184: Move the modelContext getter to Document: Merged change, commit c7b5c70 (2026-05-27), checked 2026-10-05.
- WebMCP spec source, index.bs, last navigator.modelContext commit: Draft Community Group Report (superseded), commit a816d2e (2026-05-20), checked 2026-10-05.
- WebMCP index.bs commit history: Repository history, 2026-01-26 to d61d0e6 (2026-09-30); main at 6891d0e (2026-10-02) changes only an explainer, checked 2026-10-05.
- Chrome for Developers: WebMCP: Origin trial documentation, last updated 2026-10-01, checked 2026-10-02.
- Chrome for Developers: WebMCP Imperative API: Origin trial documentation, last updated 2026-09-21, checked 2026-10-02.
- Chrome for Developers: WebMCP tool security: Origin trial documentation, last updated 2026-09-01, checked 2026-10-02.