WebMCP is a proposed web standard that lets a page register JavaScript functions as tools, with names, descriptions and JSON Schemas, so a browser agent can call them directly instead of clicking through your UI. It is available in Chrome through an origin trial that started in Chrome 149 and has been extended to Chrome 162, and it is still changing: the first of a series of announced breaking changes ships in Chrome 160, which reaches stable on January 5, 2027, with a stabilized subset of the API targeted for early 2027. If you register WebMCP tools today, you should write them defensively now.
This guide explains what WebMCP is, how to expose tools from a page with the current document.modelContext API, exactly what has changed release by release, a version-tolerant helper I tested against the official polyfill, and how to test tools before an agent ever sees them.
What WebMCP is (and how it differs from MCP)
The Model Context Protocol connects an AI client to a server process over JSON-RPC. If you have built one, as in our guide on how to build an MCP server, you know the server runs outside the browser and the user's session has to be re-created with tokens. WebMCP borrows MCP's tool model (name, description, input schema, result) but runs inside the page. The tool's execute callback is ordinary client-side JavaScript, so it reuses the user's logged-in session, your app state, and your existing functions, and the user can watch the result happen in the UI.
Chrome's WebMCP overview describes the problem it solves as "actuation": agents simulating clicks and typing, step by step, each step open to misinterpretation. With WebMCP, the page declares what an element or action is for. The spec lives in the Web Machine Learning Community Group's webmcp repository. It is a Community Group draft, not a W3C Standard.
There are two APIs:
- Imperative API:
document.modelContext.registerTool()with a JavaScript callback. This is what the spec currently defines. - Declarative API:
toolnameandtooldescriptionattributes on a<form>, from which the browser synthesizes a tool. Chrome implements it, but the explainer says it is "not part of the specification at this time."
Current status and dates
| Item | Status | Source |
|---|---|---|
| Origin trial | Started Chrome 149; extended through Chrome 162 | Chrome Status entry |
| Local testing | chrome://flags/#enable-webmcp-testing |
Chrome docs |
| Chrome 160 stable | January 5, 2027 | Chromium schedule |
| Chrome 162 stable | February 2, 2027 | Chromium schedule |
| Breaking-change warning | November 23, 2026, by Chrome AI DevRel lead André Cipriani Bandarra | LinkedIn post |
| Edge | Origin trial in Edge 150 | implementation status |
| Firefox, Safari | Standards-position discussions only | implementation status |
Bandarra's post, published on his personal LinkedIn rather than as a Chrome announcement, says to expect "significant changes" in "the next few weeks," that they "will be breaking changes," and that they "will allow us to ship a stabilized subset of the API in early 2027." He names the first change (spec PR #348, the Tool interface) but not the rest, so nobody outside the team knows the full list yet. Chrome's WebMCP updates page, first published November 26, 2026, is where each change gets documented; it is the page to watch.
How to expose a WebMCP tool from a page
Here is a complete tool using the current API shape. It follows the patterns in Chrome's Imperative API docs (last updated November 26, 2026):
const registration = new AbortController();
await document.modelContext.registerTool({
name: "add_to_cart",
description: "Add a product to the user's cart by SKU. Use search_products first to find SKUs.",
inputSchema: {
type: "object",
properties: {
sku: { type: "string", description: "Product SKU, for example TSHIRT-M" },
qty: { type: "integer", minimum: 1, description: "Quantity, defaults to 1" },
},
required: ["sku"],
},
annotations: { readOnlyHint: false, consequentialHint: false },
async execute({ sku, qty = 1 }, { signal }) {
const res = await fetch("/api/cart", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sku, qty }),
signal, // cancelled if the user or agent stops the call
});
if (!res.ok) {
return `Could not add ${sku}: ${res.status}. Check the SKU with search_products.`;
}
renderCart(await res.json()); // update the visible UI too
return `Added ${qty} x ${sku} to the cart.`;
},
}, { signal: registration.signal });
// Later, when the tool no longer applies (route change, logout):
registration.abort();
A few details that matter:
registerTool()returns a Promise (since Chrome 151). Await it, and catch rejections; it rejects withNotAllowedErrorwhen thetoolsPermissions Policy blocks registration, for example in a cross-origin iframe withoutallow="tools".- Unregistration is by
AbortSignal. There is nounregisterTool()anymore (removed in Chrome 148). Only the code that registered a tool can remove it. executereceives{ signal }as its second argument (since Chrome 153). Pass it tofetch()and other async work.- Annotations are hints for agents.
readOnlyHintmarks safe reads,consequentialHintmarks irreversible real-world actions that should get explicit user confirmation,untrustedContentHintmarks output containing user-generated or external data (a prompt-injection signal), anddebuggingmarks developer-only tools. - Return useful errors instead of throwing for bad input. Chrome's guidance is to validate strictly in code and loosely in the schema, and return an actionable message so the agent can retry.
The declarative version is just HTML, which is the cheapest way to start if your feature already is a form:
<form toolname="search_products" tooldescription="Search the product catalog by keyword." action="/search">
<label for="q">Search</label>
<input id="q" name="q" type="text" required>
<button type="submit">Search</button>
</form>
The browser builds the input schema from the fields, using each field's <label> (or a toolparamdescription attribute) as the property description. Without toolautosubmit, the agent fills the form and the user clicks submit.
What has changed so far, release by release
The updates page is the authoritative changelog. Condensed, with the change that hurts most first:
| Chrome | Change | What breaks |
|---|---|---|
| 147 | provideContext() and clearContext() removed |
Any code that replaced the whole tool set |
| 148 | unregisterTool() replaced by AbortSignal; toolparamtitle removed |
Manual unregistration |
| 150 / 152 | navigator.modelContext deprecated, then removed in 152 |
Every call site using navigator |
| 151 | registerTool() returns a Promise |
Unhandled rejections; code assuming sync availability |
| 153 | execute(input, { signal }); unregistering no longer cancels in-flight calls |
Code relying on unregistration as cancellation |
| 155 | executeTool() takes an object, not a JSON string; inputSchema from getTools() is an object, not a string |
Agent-side code that stringified or parsed |
| 156 | toolactivated / toolcancel events moved from window to document.modelContext |
Declarative form listeners |
| 159 | Optional outputSchema on registerTool() |
Nothing (additive) |
| 160 | getTools() returns a Tool interface instead of a RegisteredTool dictionary; window renamed to source; empty schemas and annotations are null; new waitForToolsUntil() |
Serializing or spreading tool objects; reading tool.window |
The Chrome 160 change in detail
The Chrome 160 change comes from spec PR #348, merged November 19, 2026. Each Tool now carries an internal unique ID that executeTool() uses, which fixes races such as a tool being unregistered while it runs and prepares for tools from opaque-origin documents and workers. The cost is that Tool is a platform object, not a plain dictionary:
JSON.stringify(tool)returns"{}".{...tool}copies nothing.structuredClone(tool)throws.- A
Toolrefers to one specific registration. If the page unregisters and re-registers a tool with the same name, the oldToolobject no longer works; callgetTools()again.
This mostly affects agent-side code (extensions, in-page assistants, test harnesses) that reads tools. If you only register tools from your page, Chrome 160 probably does not break you. But the stated plan is more breaking changes before the stable subset, and some will likely touch registration.
How to write WebMCP code that survives the changes
The pattern that has worked across every change so far is: feature-detect, isolate WebMCP calls in one module, treat every field as optional, and never rely on a tool object's shape. Here is the helper module I use:
// webmcp-tools.js: version-tolerant WebMCP registration helpers.
export function getModelContext() {
// navigator.modelContext was removed in Chrome 152; keep the fallback only
// while you still support origin-trial users on older builds.
return globalThis.document?.modelContext ?? globalThis.navigator?.modelContext ?? null;
}
export async function registerTools(tools, { signal } = {}) {
const mc = getModelContext();
if (!mc) return { supported: false };
const registrations = Promise.allSettled(
tools.map((tool) =>
// registerTool returns a Promise since Chrome 151; await works either way.
Promise.resolve(mc.registerTool(tool, { signal })),
),
);
// Chrome 160+: tell agents to wait until registration settles.
mc.waitForToolsUntil?.(registrations);
const results = await registrations;
const failed = results.filter((r) => r.status === "rejected");
failed.forEach((r) => console.warn("WebMCP registration failed:", r.reason));
return { supported: true, failed: failed.length };
}
// Normalize Tool (Chrome 160+) and RegisteredTool (older) into a plain object.
export function describeTool(tool) {
const schema = tool.inputSchema;
return {
name: tool.name,
title: tool.title ?? "",
description: tool.description,
origin: tool.origin,
inputSchema: typeof schema === "string" ? JSON.parse(schema) : (schema ?? null),
outputSchema: tool.outputSchema ?? null,
annotations: tool.annotations ?? null,
source: tool.source ?? tool.window ?? null,
};
}
Why each piece is there:
- One
AbortControllerper scope. In a single-page app, create one controller per route or component and abort it on unmount. This is the same pattern Chrome's Chrome 160 example uses for SPA route changes, and it means you never track tool names manually. waitForToolsUntil?.()with optional chaining. It exists only from Chrome 160. Agents wait until the promise settles (or 10 seconds) before reading tools, which matters when tools depend on fetched config. Chrome is still deciding whether the cutoff for calling it is the end of<head>parsing orDOMContentLoaded(issue #328), so register early: an inline or<head>script is the safe choice.describeTool()reads fields explicitly instead of spreading or serializing, which is exactly what breaks in Chrome 160, and it handles the pre-155 string schema.
If you use React, Angular or Vue, Chrome's docs point to experimental integrations (use-webmcp-tool for React, useWebMCP in @vueuse/core for Vue) that tie registration to component lifecycle. Those packages will need updates as the API moves, so pin their versions and read their changelogs, or keep the thin wrapper above and own the lifecycle yourself.
The origin trial token itself goes in a meta tag or an Origin-Trial response header, per Chrome's origin trials guide:
<meta http-equiv="origin-trial" content="YOUR_ORIGIN_TRIAL_TOKEN">
Remember that an origin trial is time-limited. When the trial ends (currently after Chrome 162), the API disappears for users without the flag unless it has shipped, so WebMCP must always be a progressive enhancement. Every tool should do something a human can also do through the normal UI.
How to test WebMCP tools
1. Unit-test registration with the polyfill
The W3C-hosted @w3c/webmcp-polyfill (0.2.1 at the time of writing) installs document.modelContext where it is missing and already follows the Chrome 160 shape. I ran the helper above against it in Node 24 with jsdom, registering an add_to_cart tool, executing it, then aborting the registration:
register: { supported: true, failed: 0 }
JSON.stringify(tool): {}
execute: "{\"content\":[{\"type\":\"text\",\"text\":\"Added 2 x TSHIRT-M. Cart has 1 line(s).\"}]}"
after abort: 0
stale tool: NotFoundError The requested tool was not found or is not accessible.
Two useful confirmations: JSON.stringify(tool) really returns {}, and executing a Tool object after its registration is aborted fails with NotFoundError. Write tests that assert both, because they are the behaviors most likely to catch agent-side code written against the old dictionary shape. The polyfill is not Chrome, so treat it as a contract test, not proof of browser behavior. For type checking, Chrome recommends the webmcp-types package.
2. Inspect in Chrome DevTools
With the testing flag on, Chrome DevTools has had experimental WebMCP debugging in the Application panel since Chrome 149, where you can see registered tools and how the browser parsed their JSON Schema. Check that every schema property has a description and that required fields are marked. Paste a schema into a JSON formatter if you need to eyeball a large one.
3. Drive it with a real model
Chrome publishes two extensions for this: the Model Context Tool Inspector, which lists and runs tools with natural-language prompts using your own Gemini API key, and an example agentic extension that honors annotations such as consequentialHint. Try ambiguous prompts, not just happy paths.
4. Write evals, not only tests
Chrome's WebMCP evals guide lists the failure modes to cover: the agent picks the wrong tool, calls tools in the wrong order, or passes wrong arguments (adds shoes instead of a t-shirt). Those are description and schema problems, not code bugs, and they only show up when a model is in the loop. Keep a small set of user intents with expected tool calls and rerun it whenever you change a description.
Security notes before you ship tools
Chrome's docs warn that Chrome extensions can query and execute WebMCP tools through content scripts. Treat every tool as a public API endpoint that runs with the user's privileges: re-check authorization inside execute, never trust the agent's arguments, mark irreversible actions with consequentialHint, and flag tools that return user-generated content with untrustedContentHint so agents can delimit it. Cross-origin exposure is opt-in through exposedTo on registration and fromOrigins on getTools(); leave both off unless you have a specific partner integration. If you also publish an llms.txt file, remember that it only describes your site, whereas WebMCP tools act on it.
Frequently Asked Questions
Is WebMCP the same as MCP?
No. MCP connects AI clients to separate server processes over JSON-RPC. WebMCP runs inside a web page and exposes client-side JavaScript functions to browser agents. It reuses MCP's tool concepts but not its transport. For server-side MCP changes this year, see our MCP 2026-07-28 spec migration guide.
How do I enable WebMCP in Chrome?
For local development, enable chrome://flags/#enable-webmcp-testing and relaunch. For real users, register for the WebMCP origin trial (Chrome 149 through 162) and add the token to your pages with a meta tag or response header.
Should I use navigator.modelContext or document.modelContext?
Use document.modelContext. navigator.modelContext was deprecated in Chrome 150 and removed in Chrome 152. Keep a navigator fallback only if you still need to support older origin-trial builds.
What changes in WebMCP in Chrome 160?
getTools() returns Tool interface objects instead of dictionaries, tool.window becomes tool.source, empty schemas and annotations become null, and serializing, spreading or cloning a tool no longer works. Chrome 160 also adds document.modelContext.waitForToolsUntil().
When will WebMCP be stable?
Chrome's AI DevRel lead said on November 23, 2026 that breaking changes over the following weeks will allow a stabilized subset to ship in early 2027. No release number or date has been published, and there is no commitment from Firefox or Safari.
Do WebMCP tools work in headless browsers?
Chrome's docs say it may be possible, but the API is primarily designed for local browser workflows with a human in the loop. Do not design an automation pipeline around headless WebMCP yet.
Bottom Line
WebMCP is the most practical way to make a web app reliable for browser agents, and it is still an origin trial with breaking changes on a published path. Register tools through one small wrapper that feature-detects document.modelContext, uses AbortSignal for lifecycle, calls waitForToolsUntil when it exists, and never serializes tool objects. Test with the polyfill in CI and with a real model before release, keep every tool a progressive enhancement, and check Chrome's updates page each release until the stable subset lands in early 2027.