WebMCP exposure
WebMCP is an imperative browser API — document.modelContext.registerTool(...) — that lets a page offer tools to an AI agent running in or alongside the browser. It is being specified in the W3C Web Machine Learning Community Group. webmcpui controls can register themselves as tools.
Opt in with expose
<wmcp-input label="Email" name="email" type="email" expose></wmcp-input>
<!-- registers a "fill-email" tool an agent can call -->
On connect, the element registers an imperative WebMCP tool; on disconnect, it unregisters. It is feature-detected — a complete no-op when no agent/host is present (the common case today), so the control is always a good form control first.
The generated tool
For the example above, the registered tool is:
| Field | Value |
|---|---|
name | fill-email (fill_ + the name attribute) |
title | Email (the label, for the agent's native UI) |
description | Set the value of the "Email" field. |
inputSchema | { type: 'object', properties: { value: { type: 'string' } }, required: ['value'] } |
outputSchema | the result shape below |
annotations | { consequentialHint: true } only when the consequential attribute is set |
When the agent calls the tool, the element applies the value exactly as if a user typed it — updating state, running validation, announcing errors, and firing input/change events.
Tool results
WebMCP has no result envelope of its own: execute returns any JSON-serializable value, the host stringifies it for the agent, and outputSchema says what to expect. Every webmcpui tool returns a plain object with ok, one human-readable message, and element-specific detail:
{ "ok": true, "message": "Set \"Email\" to \"[email protected]\".", "field": "Email", "value": "[email protected]", "valid": true }
{ "ok": false, "message": "Set \"Email\" but validation failed: Enter a valid email", "error": "Enter a valid email", "field": "Email", "value": "nope", "valid": false }
Anything the agent should reason about — a validation failure, a disabled control, a form that did not submit — comes back as a value with ok: false, never as a thrown error. That is deliberate: a rejected execute reaches the agent only as a bare OperationError with the message dropped, so refusing in the result is the only way to tell it why. The same helpers are exported for your own tools: toolOk(message, detail), toolFailed(message, detail), and toolResultSchema(detail).
Customizing the tool
<wmcp-input
name="email"
label="Work email"
expose
tool-name="set-work-email"
tool-description="Set the customer's work email address."
></wmcp-input>
tool-nameoverrides the generatedfill-<name>.tool-descriptionoverrides the generated description.consequentialmarks the toolconsequentialHint: true, so the agent confirms with the user before calling it. Submit buttons set it by default.
Generated names are kebab-case (fill-email, open-booking, submit-book), matching the examples in Chrome's WebMCP documentation; the spec allows _, - and . equally, and tool-name can use any of them. Tool names must match the spec's [A-Za-z0-9_.-]{1,128}. A name that doesn't (spaces, brackets, non-ASCII) is sanitized — user[email] becomes fill-user-email — with a console warning in development; set tool-name to choose the name yourself.
Controls with enumerated values (<wmcp-select>, <wmcp-radio-group>) generate an enum-typed schema so the agent knows the exact allowed values.
Tool names are page-global. Two
exposed controls that resolve to the same tool name — say two fields that both becomefill-email— collide, and the host rejects the duplicate, so the second control won't be agent-callable. webmcpui logs a console warning when it sees this; give one control a uniquename, or override it withtool-name.
Only on a secure context
WebMCP is a secure-context feature, so document.modelContext exists only on HTTPS pages — it's undefined on plain HTTP (localhost counts as secure). webmcpui's feature detection reads that as "no host present" and quietly does nothing, so your controls stay perfectly good form controls. If you're testing exposure on an http:// staging box and see no tools, that's why.
If you feature-detect yourself, the recommended check is:
if (isSecureContext && 'modelContext' in document) { /* host present */ }
Iframes and permissions policy
WebMCP is gated by the tools Permissions Policy feature, which defaults to 'self'. Controls inside a cross-origin <iframe> only get a modelContext if the embedding page allows it:
<iframe src="https://widgets.example.com/booking" allow="tools"></iframe>
Tools are also scoped to the document that registered them: they disappear on navigation, and by default are visible only to same-origin documents in the same tab.
Designed for a human in the loop
WebMCP is explicitly a human-in-the-loop API — its own goals call out cooperative workflows where a person delegates to an agent while keeping visibility and control, and rule out fully autonomous, headless operation. There is, as yet, no built-in confirmation or user-prompting primitive in registerTool (a requestUserInput() is under discussion). What the spec does offer is a set of tool annotations — readOnlyHint, consequentialHint, untrustedContentHint — that tell the agent how careful to be. So consent stays a UI decision you make: an agent can set a value or open a dialog, but the consequential step — submitting, confirming — remains a deliberate human action. That's the line webmcpui draws by default.
Imperative and declarative
The API webmcpui builds on is the imperative one (registerTool), which is the only standards-track path today. A declarative companion — native attributes (toolname, tooldescription, toolparamdescription, toolautosubmit) that annotate a plain <form> — was removed from the spec in October 2026 and kept as a "future exploration" explainer; Chrome still ships it in the origin trial. webmcpui uses the imperative path under the hood because it's the lower-level primitive and the only one that covers interaction beyond forms — a button's click or a dialog's open aren't expressible as form annotations.
For forms themselves, webmcpui speaks the declarative vocabulary too: <wmcp-form> exposes a whole form as one tool with a schema synthesized the way Chrome does it, and exposeForm() / observeDeclarativeForms() from @webmcpui/webmcp/forms do the same for any plain <form toolname tooldescription> on any page — a polyfill for the declarative API on top of the imperative one, which steps aside where the browser has native support.
Spec status
As of late 2026 WebMCP is a W3C CG draft shipping behind origin trials in Chrome 149–162 and Edge 150+ (Edge's runs to March 2027), at Chrome's "prepare to ship" stage with no Intent to Ship yet. The entry point is document.modelContext only — navigator.modelContext was deprecated in Chrome 150 and removed in 152. Agents consuming page tools today include Brave Leo, ChatGPT Desktop and Meta's Ray-Ban Display; Gemini in Chrome's integration is still in developer trials. The surface still shifts month to month, so everything here is additive and feature-detected: adopting webmcpui costs nothing today and pays off as hosts ship. To try it locally, enable chrome://flags/#enable-webmcp-testing; to exercise exposure without a real host, use the fake agent. We keep a running gap analysis against the spec.