When you ask an AI agent to book a restaurant table on a regular website, it has to perform heavy acrobatics behind the scenes. The agent takes a screenshot, dumps a bloated DOM tree and the accessibility tree (the parallel structure of roles, buttons, and labels browsers build for screen readers). Then the model guesses which <div> opens the date picker, misses a required field, takes another screenshot, and burns context parsing your markup. Rename one CSS class or move a block, and the whole flow breaks.
The experimental WebMCP (Web Model Context Protocol) standard aims to remove that guesswork. Instead of feeding raw markup to a neural network, a web page registers typed JavaScript functions with clear descriptions and argument schemas directly with the browser. The agent reads that list and calls the right function directly.
It sounds neat, though the standard is still an early draft: the API breaks every few weeks, only Chromium supports it, and Apple officially opposes it. Let's see how WebMCP works under the hood, how to design and guard a tool, why the browser won't validate JSON schemas for you, and how to test everything without a live LLM.
Why WebMCP exists and how it differs from server-side MCP
WebMCP comes from the W3C Web Machine Learning Community Group, an open W3C incubator where engineers from Google and Microsoft test early browser APIs for AI workloads.
The setup is straightforward. A page registers its actions as typed JS functions called tools. Each tool has a name, a text description, an input schema, and an execute handler. When a user opens the site, an external AI agent or built-in browser assistant asks the browser for available tools and calls one with standard JSON arguments. It never has to decode your page's custom DOM.
If you've used server-side MCP (Model Context Protocol), you might wonder why we need a browser version when you can run an MCP server next to your backend. The difference is execution context. A server-side MCP lives outside the browser: it needs its own API keys, OAuth flows, and manual syncing with what's on the user's screen. WebMCP tools run inside the active browser tab, strictly within a [SecureContext] (HTTPS or localhost). They automatically share the user's current session, cookies, and live UI state.
45-degree isometric architecture diagram: comparing a standalone server-side MCP with external keys against browser-side WebMCP running inside an active SecureContext tab with access to the user's session.
Interestingly, standardized page actions can be useful even without LLMs. Imagine opening a restaurant site and having your browser show a clean "Book a table" button in its own toolbar, prefilled with your saved name and email—no wrestling with a clunky form. It's a nod to the old Semantic Web dream, where machines understand what a page can do.
There is a flip side, though. If WebMCP stays locked to AI agents, some sites might dump convenient features into tools and neglect their regular UI. Visitors without a paid agent would lose out. That's why tool design should always center on the human user, not replace them.
Browser politics: why Chromium is pushing ahead and Apple objects
As of December 2026, WebMCP only exists in Chromium browsers—mainly Chrome and Edge. In standard Chrome, the API sits behind an experimental flag or an Origin Trial, Chrome's early preview program where site owners use a temporary token to enable an experimental feature for real users and gather feedback.
The one notable exception for developers is Polypane 32, released November 18, 2026 on Chromium 160. Its WebMCP panel works out of the box without flipping flags. Other browser vendors are much more cautious.
| Engine or group | Official status | Where to track | Main position |
|---|---|---|---|
| Chromium (Google, Microsoft) | Active development | Chrome Early Preview | Spec authors; available behind a flag and Origin Trial |
| Mozilla (Gecko / Firefox) | neutral | mozilla/standards-positions#1412 | Participating; concerned about boundaries for built-in and iframe agents |
| Apple (WebKit / Safari) | oppose | WebKit/standards-positions#670 | Opposes a separate JS layer; agents should use HTML and ARIA |
| W3C TAG | in progress | w3ctag/design-reviews#1238 | Early review underway; notes lack of multi-engine support |
Apple's objection rests on a clear architectural view. In WebKit issue #670 (an earlier #649 was closed as a duplicate), Safari engineers argue that an AI agent acting for a user is an assistive technology, just like a screen reader. Therefore, it should work through shared HTML and ARIA layers rather than a parallel JavaScript API. Before adding a new standard, the authors need to prove what HTML and current models actually fail to handle. Apple attached concerns covering privacy, security, meaningful user consent, duplication, portability, internationalization, and API design.
Mozilla stays neutral in issue #1412 while asking tough questions: how to separate permissions between a built-in browser agent and third-party iframes, and how to ensure actions truly match user intent. Meanwhile, W3C TAG (#1238) is still reviewing the design and explicitly flags the lack of multi-engine backing.
This leads to a key practical reality: the spec changes every few weeks, and updates regularly break existing code. For instance, the API entry point recently moved from navigator.modelContext to document.modelContext. In the draft WebIDL, it's now defined directly on Document with [SecureContext, SameObject].
Another telling change was dropping declarative forms. Early WebMCP drafts let you put toolname and tooldescription attributes straight onto a <form>, and the browser turned fields with required, min, and max into a tool schema. Chrome and Polypane still support that syntax for now, but it was cut from the spec draft to focus on the JavaScript API first. That speeds up spec work, though it's a bit of a loss: declarative forms forced developers to build a proper human UI before exposing it to agents. A pure JS API makes it easier to ship "AI-only" features.
Registering your first tool with a booking form
Instead of abstract foo and bar examples, let's use a real demo page for a restaurant called Trattoria Polypane. It has a standard reservation form with seven fields: Name*, Email*, Guests*, Date*, Time*, Seating (inside, terrace, or bar), and Notes (allergies, high chair, etc.). We'll register this form as a WebMCP tool named book_table.
Rule number one with experimental browser APIs: always guard with if (document.modelContext). That way Firefox, Safari, and older Chrome builds quietly skip registration without throwing errors.
document.modelContext.registerTool() takes a tool descriptor object and returns a Promise. The object has six main properties: name, description, inputSchema, an optional outputSchema, an optional annotations object, and the execute function. Here is the full book_table registration for Chromium 160:
// Check WebMCP support so Firefox and Safari don't throw
if (document.modelContext) {
document.modelContext
.registerTool({
name: 'book_table',
description:
'Book a table at Trattoria Polypane. Returns a confirmation ' +
'with the booking reference. A booking can not be changed ' +
'afterwards.',
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
description: 'Name the booking is under',
},
email: {
type: 'string',
description: 'Email address to send the confirmation to',
},
date: {
type: 'string',
format: 'date',
description: 'Date of the booking, in YYYY-MM-DD format',
},
time: {
type: 'string',
description:
'Arrival time in 24 hour HH:MM format. ' +
'The kitchen is open from 17:00 to 22:00',
},
guests: {
type: 'integer',
minimum: 1,
maximum: 8,
description: 'Number of guests, from 1 to 8',
},
seating: {
type: 'string',
enum: ['inside', 'terrace', 'bar'],
description: 'Where the guests want to sit. Defaults to inside',
},
notes: {
type: 'string',
description: 'Allergies, a high chair or other requests',
},
},
required: ['name', 'email', 'date', 'time', 'guests'],
},
// Added in Nov 2026 spec: schema for the return value
outputSchema: {
type: 'object',
description: 'The booking that was made',
properties: {
reference: {
type: 'string',
description: 'Reference of the booking, e.g. TP-20261210-4',
},
date: {
type: 'string',
format: 'date',
description: 'Date of the booking',
},
time: {
type: 'string',
description: 'Arrival time in 24 hour HH:MM format',
},
guests: {
type: 'integer',
description: 'Number of guests',
},
},
},
// Flag this action as irreversible
annotations: { consequentialHint: true },
async execute(input) {
// Browser doesn't validate schemas — check manually with Ajv
if (!validate(input)) {
throw new Error(ajv.errorsText(validate.errors));
}
return bookTable(input);
},
})
.catch((error) => {
console.warn('Could not register the book_table tool:', error);
});
}
Here is what's happening. registerTool() is asynchronous: if you pass an invalid name, register two tools with the same name, or leave description empty, the promise rejects and the tool won't appear in the registry. That .catch() at the end isn't just defensive—it surfaces registration errors right in the console.
outputSchema joined the spec draft in November 2026. It works just like inputSchema but describes what execute() returns. That helps when your function returns a structured object or ID like reference: "TP-20261210-4" that an agent can pass to a follow-up tool (to view or cancel the booking). If your tool returns a plain string or status, you can omit outputSchema. Either way, always spell out what the tool returns in description too, since outputSchema is new and some agents don't read it yet.
On a live site, available actions change as the user navigates. For example, an order management tool only makes sense while the user is signed in. registerTool() accepts a second options argument with a standard AbortSignal, just like fetch or addEventListener:
const controller = new AbortController();
// Tie the tool's lifecycle to an abort signal
document.modelContext.registerTool(tool, {
signal: controller.signal,
});
// Later, when the user signs out, unregister the tool
controller.abort();
Calling controller.abort() immediately removes the tool so agents can no longer see it. No separate unregisterTool() method needed—it reuses a standard browser primitive.
Want to try WebMCP across all browsers today? In early November 2026, the working group released an official zero-dependency polyfill, @w3c/webmcp-polyfill. It adds document.modelContext where it's missing and steps aside when native support arrives. No magic, of course: external browser agents still need native browser support. Still, the polyfill lets your own embedded site assistant use the exact same tool layer.
Designing tools for agents: limits, copy, and UI sync
Registering a function is only half the job. A tool can work fine when called from DevTools and still confuse an LLM. The agent can't read your source code; it relies solely on names, descriptions, and JSON Schema.
Model context windows aren't infinite, so the WebMCP community has settled on practical limits for metadata size and tool counts per page:
| Tool parameter | Hard API limit | Recommended target | Why stay within it |
|---|---|---|---|
name | Up to 128 chars (a-z, 0-9, _, -, ., no spaces) | Under 30 chars, snake_case | Short, unique names reduce model confusion |
Tool description | Non-empty string | Up to ~500 chars | Saves context; always state what the function returns |
Property description | Unlimited | Up to 150 chars | Quick format hints (e.g., YYYY-MM-DD, kitchen hours) |
execute return value | Unlimited | Up to ~1,500 chars | Oversized payloads bloat the agent's context |
| Tools per page | Unlimited | Around 10–12 max | One tool, one job; too many hurt tool selection |
Look back at the time field description in book_table: right next to HH:MM, it mentions that the kitchen is open from 17:00 to 22:00. Putting small business rules directly in description saves the agent wasted retries.
The second key rule is updating the page UI. If a tool does more than read static info—changing a setting, adding to cart, placing a booking—execute() should update the visible page. A great example is check_color_contrast on Polypane's color contrast checker. When an agent passes a text and background color pair, the tool returns the contrast ratio and better alternatives, while filling both colors into the page's actual inputs. The user sees the live preview and scores themselves instead of taking the agent's word for it, and can tweak shades by hand.
For the same reason, don't build tools for actions that don't exist in your normal UI. If a discount or booking only works through WebMCP, visitors without an agent get left behind.
The third rule covers errors: never guess what the agent meant. If the model sends an invalid date or omits a required field, abort and throw an Error with a clear message. When execute() throws, the browser sends the error back to the agent so it can fix its parameters and retry. Silently "fixing" bad input and returning success creates a quiet bug where both the agent and the user think a booking worked while garbage sits in your database.
Safety, consequentialHint, and input validation
Any tool that mutates data or spends money is high-risk. A model might misunderstand the user, hallucinate arguments, or fall for a prompt injection hidden in a user comment on the page.
The WebMCP draft provides a ToolAnnotations dictionary to flag risk. Here is how it looks in the official WebIDL:
partial interface Document {
[SecureContext, SameObject] readonly attribute ModelContext modelContext;
};
dictionary ToolAnnotations {
boolean readOnlyHint = false;
boolean untrustedContentHint = false;
boolean consequentialHint = false;
boolean debugging = false;
};
Three annotations cover the main cases:
Photorealistic 3D render of a two-tier WebMCP safety gate: a consequentialHint user confirmation pause and a mechanical Ajv validation gauge before execution.
readOnlyHint— the tool changes nothing (only reads or computes);untrustedContentHint— the tool returns user-generated content you shouldn't blindly trust (reviews, comments, third-party descriptions);consequentialHint— the tool performs an irreversible action with real-world impact: purchases, transfers, deletions, or table bookings.
All three end in Hint for a reason. They aren't hardware locks; they're signals telling the browser and agent how to treat the function. You decide where to draw the line. On check_color_contrast, Polypane intentionally left readOnlyHint off because it updates form fields on the page, even though it doesn't touch a backend. For book_table, consequentialHint: true is a must.
When an agent (such as Claude Desktop connected via Polypane Automation) tries to call a tool with consequentialHint: true, the browser pauses execution and prompts the user: "Allow Claude Desktop to do something risky?" The dialog lets you inspect the exact arguments, click Deny or Allow, or check "Remember my choice".
Annotations alone won't stop malformed inputs, though. And here is WebMCP's biggest practical surprise.
Even if you write guests: { type: 'integer', minimum: 1, maximum: 8 } in inputSchema, the browser won't filter calls. It will happily pass guests: 80, a string instead of a number, or a missing email straight into execute(input). Validation is 100% up to your code.
You don't need to write dozens of manual if checks—you already have inputSchema. The cleanest approach is passing that exact JSON Schema object to a validator like Ajv (with ajv-formats for format: 'date'):
import Ajv from 'ajv';
import addFormats from 'ajv-formats';
const ajv = new Ajv();
// Enable support for format: 'date' and other standard formats
addFormats(ajv);
// Reuse the same inputSchema passed to registerTool()
const validate = ajv.compile(inputSchema);
// Inside the tool object for registerTool()
async function execute(input) {
if (!validate(input)) {
// Return the exact validation failure to the agent
throw new Error(ajv.errorsText(validate.errors));
}
// bookTable() still needs server-side business and auth checks
return bookTable(input);
}
If an agent tries to book for 80 guests, validate(input) returns false and throws a clear message saying guests must be 8 or fewer. The agent reads that error and adjusts its call. Naturally, client-side schema validation doesn't replace server-side checks inside bookTable(): your backend still has to verify table availability, permissions, and rate limits.
Testing in Polypane 32 and whether to ship WebMCP now
Debugging WebMCP tools through a live LLM chat is painful. You write a prompt hoping the model picks the right tool and happens to send the exact edge-case parameters you want to test. Reproducing bugs that way is nearly impossible.
For Chrome, Google maintains GoogleChromeLabs/webmcp-tools with CLI tools, an eval harness, and the Model Context Tool Inspector extension. Meanwhile, the developer browser Polypane 32 (14-day no-card trial on Windows, macOS, and Linux) includes a built-in WebMCP panel right next to the live page.
Polypane 32 interface: the Trattoria Polypane booking form demo on the left and the WebMCP panel showing the book_table tool on the right (Source: polypane.app)
The panel workflow is straightforward. Open the WebMCP tab to see every registered tool on the page: name, first two lines of description, source icon (script or <form>, with hover showing where it was registered), and annotation badges so you can confirm consequentialHint actually made it through. If a tool is missing, registerTool() rejected and the reason is waiting in your console.
Next comes the built-in schema linter. Browsers only reject glaring errors during registration and silently let LLM-breaking mistakes slide. On a deliberately broken book_table schema, Polypane's linter caught three issues the browser ignored:
guestsused typeint, which doesn't exist in JSON Schema (it must beinteger);emailwas listed inrequiredbut missing fromproperties, forcing the agent to send an undocumented field;namehad nodescription, leaving the model to guess the format.
To test execute(), the panel generates an interactive form from your inputSchema alongside a synced raw JSON editor. If you can't figure out what to type into the generated form yourself, your schema and descriptions need work. The synced JSON editor also makes it easy to feed "dirty" inputs (like 80 guests or extra keys) and verify your Ajv validation.
Every run is logged below the form with status (pending → completed or error), timestamp, duration, caller (manual or external agent), and a "Show input" button. Better yet, the log survives page reloads: you can edit execute(), reload the tab, and hit Replay on an earlier call in one click or copy it into the editor.
Once manual tests pass, you can bring in a real agent. Polypane Automation's built-in MCP server lets Claude Desktop connect to the browser so you can give direct prompts like "List the WebMCP tools on this page and check for issues" or "Try booking a table for 12 with book_table and tell me what happens." Automation validates inputs against the schema and guides the agent, while still letting it send invalid payloads for testing. All agent calls show up in the same WebMCP history, and consequentialHint triggers the confirmation dialog.
Pre-launch checklist for your WebMCP tool
- Registration is wrapped in
if (document.modelContext)with.catch()error handling. - Every
requiredfield exists inproperties, types strictly follow JSON Schema (integer, notint), and each property has a concisedescription. -
execute()validates inputs (e.g., with Ajv) against the sameinputSchemaand throws a clearErroron failure. - Irreversible actions set
consequentialHint: true, and business rules plus permissions are re-checked on the server. - Successful calls update the page UI so the user can see the result directly.
So, should you add WebMCP to your site today? If you wrap registration in if (document.modelContext) and reuse existing site functions, risk to regular visitors is zero—unsupported browsers just skip it. For side projects, docs, internal admin panels, and early agentic web experiments, the barrier to entry is tiny and schema design practice pays off either way. Just don't bet production on WebMCP as a stable cross-browser standard yet: the spec still shifts every few weeks, Mozilla is neutral, and Apple opposes it.





