AI Shqipe
valon-hajredini.aishqipe.com/posts/webmcp-explained-chrome-ai-agents
Valon Hajredini
Subscribe

WebMCP: How Chrome Is Turning Websites Into Tools for AI Agents

Google and Microsoft's browser-side Model Context Protocol lets a page hand an agent a list of things it can do. Here is how it works, how to add it to your site today, who benefits, and where it is going.

The agent
Gemini in Chrome, a browser extension or any client the browser lets in. It asks the tab what tools it has instead of reading the DOM.
The page
Registers tools through document.modelContext or declares them on HTML forms. The tools run inside the tab with the user's session.
search_products
imperativeRegistered with registerTool(): a name, a description, a JSON Schema and an execute() function.
checkout
declarativeA normal form with toolname and tooldescription attributes. No JavaScript needed.
Tool call
Structured input, validated against the schema, delivered to your execute() function.
Result
Whatever execute() returns goes straight back to the agent as text or JSON.
WebMCP in one picture: the page publishes tools, the agent calls them, everything happens in the open tab.

For two years the way an AI agent used a website was embarrassing: take a screenshot, send it to a vision model, guess which pixel is the Add to cart button, click, and hope. WebMCP is Google and Microsoft's answer. Announced in February 2026 and in a public Chrome origin trial since Chrome 149 in May, it lets a web page tell the browser, in plain JSON Schema, what it can do — and lets an agent call those actions the same way it calls any other MCP tool. If you build for the web, this is the first agent standard that lands in your HTML rather than on your backend.

What WebMCP actually is

WebMCP, the Web Model Context Protocol, is a draft Community Group report from the W3C Web Machine Learning group, edited by Brandon Walderman at Microsoft and Khushal Sagar and Dominic Farolino at Google. It borrows the vocabulary of Anthropic's Model Context Protocol — tools, names, descriptions, input schemas — but flips where they live. In classic MCP a server process exposes tools over HTTP or stdio. In WebMCP the web page is the server, the browser is the transport, and the tool's code runs in the tab, as the logged-in user, with the UI updating in front of them.

That distinction matters. Most sites have no public API and never will. But every site has buttons, forms and JavaScript functions that already do the work. WebMCP is a way to label those so an agent can use them without scraping, and without you standing up a separate server just for robots.

Screenshot agent
Needs a vision model on every step, breaks when the layout changes, and cannot tell a decorative button from a real one.
Page as pixels
The agent sees rectangles. Meaning has to be inferred, and inference is where most browser-agent failures come from.
WebMCP agent
Any model that can call tools. No vision needed for the action itself, so cheaper and far more reliable.
Page as tools
Each tool has a name, a description and a JSON Schema. The agent picks by meaning, fills the schema, and calls.
Result
execute() returns a value straight to the agent. No parsing of the resulting page.
The problem WebMCP solves: guessing from pixels versus calling a declared, typed action.

How it works

There are two ways to expose a tool, and most sites will end up using both. The declarative API turns a form you already have into a tool with two attributes. The imperative API registers a JavaScript function with a schema for anything that is not a form.

Declarative: annotate a form

Add toolname and tooldescription to a form and the browser reads its fields as the tool's parameters. Field names become property names, required stays required, a select's options become an enum, and toolparamdescription lets you explain a field to the model. Nothing about the form changes for a human visitor.

code
<form toolname="supportRequest"
      tooldescription="Submit a request for customer support."
      action="/support" method="post" toolautosubmit>
  <label>First name <input name="firstName" required></label>
  <label>Email <input name="email" type="email" required></label>
  <select name="team" required
          toolparamdescription="Which team should handle this request.">
    <option value="returns">Return my purchase</option>
    <option value="shipping">Check my package</option>
    <option value="website">Get website help</option>
  </select>
  <textarea name="message"></textarea>
  <button type="submit">Send</button>
</form>

With toolautosubmit the browser fills the form and submits it as if the user had. Without it, you handle the submit event yourself: the event now carries an agentInvoked flag and a respondWith() method, so you can call preventDefault(), do the work with fetch, and hand a result string back to the agent. Two new events, toolactivated and toolcancel, tell you when an agent starts or abandons a tool, and the CSS pseudo-classes :tool-form-active and :tool-submit-active let you highlight what the agent is touching — which is exactly what a user wants to see.

code
document.querySelector('form').addEventListener('submit', async (e) => {
  if (!e.agentInvoked) return;          // a human: let the form submit normally
  e.preventDefault();
  const body = new FormData(e.target);
  e.respondWith(
    fetch('/support', { method: 'POST', body })
      .then(r => r.ok ? 'Ticket created.' : 'Could not create ticket.')
  );
});

/* show the visitor what the agent is doing */
form:tool-form-active { outline: 2px dashed #3b82f6; }

Imperative: register a function

For anything dynamic — searching a catalogue, adding to a cart, changing a map view — you call document.modelContext.registerTool() with a name, a description, a JSON Schema and an async execute function. Pass an AbortSignal and the tool disappears when you abort, which is how a single-page app unregisters tools as the user navigates. Since Chrome 153 unregistering no longer kills an in-flight execution.

code
const controller = new AbortController();

await document.modelContext.registerTool({
  name: 'add_to_cart',
  description: 'Add a product to the shopping cart by SKU.',
  inputSchema: {
    type: 'object',
    properties: {
      sku:      { type: 'string', description: 'Product SKU shown on the page' },
      quantity: { type: 'integer', minimum: 1, default: 1 }
    },
    required: ['sku']
  },
  annotations: { readOnlyHint: false },
  async execute({ sku, quantity = 1 }, { signal }) {
    const item = await cart.add(sku, quantity, { signal });
    return { ok: true, cartTotal: cart.total(), added: item };
  }
}, { signal: controller.signal });

// later, e.g. on route change
controller.abort();

Three details are worth knowing. Tool names are 1 to 128 characters of letters, digits, underscores, hyphens and dots. The annotations field carries readOnlyHint, so an agent can call a search freely but ask before a purchase, and untrustedContentHint, which tells the agent that what the tool returns might contain user-generated text it should not obey. And the API is document.modelContext: the spec moved it there from navigator.modelContext in July, so older articles and demos will show the old name.

  • document.modelContext.getTools() lists what the page currently exposes; listen for the toolchange event to react when the list changes.
  • document.modelContext.executeTool(name, json) lets your own scripts or tests invoke a tool exactly as an agent would.
  • Cross-origin: an iframe needs allow="tools" in its Permissions Policy, the tool has to name the origins it is exposed to, and the caller has to ask for them explicitly with fromOrigins. Nothing crosses an origin boundary by default.

Play with the flow below. Pick a tool on the left and watch what the browser does with the call — validation, execution in the tab, and the result going back to the agent.

Interactive · runs in a sandboxed frameisolated

How to use it today

  • Local testing — enable chrome://flags/#enable-webmcp-testing in Chrome 149 or later (it first appeared in Chrome 146 Canary behind a WebMCP for testing flag).
  • Production — register your origin for the WebMCP origin trial at developer.chrome.com/origintrials. It runs from Chrome 149 to Chrome 156, so real visitors on current Chrome can be served tools now.
  • Calling your tools — install Google's Model Context Tool Inspector extension. It lists a page's tools, lets you invoke them by hand, and can run an agent simulation that sends a natural-language prompt to Gemini 3 Flash and watches it pick and call tools.
  • Types and frameworks — the webmcp-types package gives TypeScript definitions; usewebmcp wraps registration in a React hook that registers on mount and aborts on unmount; Angular ships experimental support in its own tree.
  • Auditing — Lighthouse has included agentic-browsing audits since May. Most report Not Applicable on sites without WebMCP today, but the form-coverage check is expected to become a warning, which is Google's usual way of nudging adoption.
  • Reference apps — Chrome's demos are a Pizza Maker and a React travel-booking app for the imperative API, and Le Petit Bistro, a restaurant site, for the declarative one.

Who wins on this

Google, first and most obviously. Chrome is the only browser shipping WebMCP, Gemini in Chrome is promised as the first mainstream agent that consumes it, and Lighthouse will soon nag sites that do not implement it. If the standard takes, the browser with the best agent becomes the place people get things done, and Google owns that browser. It also gets a cleaner story than screenshot agents: tools run visibly in the user's tab, with the user's own session, which makes the site owner the one in control of what an agent may do.

Microsoft co-authored the spec and ships it behind a flag in Edge, so Copilot gets the same door. Big transactional sites win next: Expedia, Booking.com, Shopify, Etsy, Instacart, Target, Redfin, Credit Karma and TurboTax were named as early experimenters, and the logic is simple — an agent that can call checkout() on your site is a customer, whereas an agent that scrapes your prices and buys elsewhere is not. WebMCP lets those sites decide exactly what an agent can touch, keep their branding in the loop, and skip building a second API for machines.

Front-end developers win a surprising amount. Until now agent-readiness meant a backend MCP server, auth, hosting and a separate deployment. WebMCP is two HTML attributes or one JavaScript call in code you already own, and it inherits the user's login for free. Users win reliability: a tool call either validates or it does not, while a click on a guessed pixel fails silently.

Who does not win: general-purpose browsing agents that live on the screenshot model, because their edge — working on any site — stops being special once sites publish tools. Firefox and Safari, which sit in the discussions but have not committed to implement, risk being the browsers where agents stay dumb. And the openness question is real: a draft Community Group report is not a W3C standard, and a spec where one vendor ships the browser, the agent and the audit tool is a spec that vendor can steer.

WebMCP versus MCP: not a replacement

  • MCP: tools live on a server, any client can connect, works headless and in the background. Best for APIs, data and enterprise integrations.
  • WebMCP: tools live in a page, only the browser hosting that page can call them, needs an open tab. Best for actions that already exist in a UI and should happen as the logged-in user, in front of them.
  • Both use the same mental model — name, description, JSON Schema input, structured result — so a team that has written one will find the other familiar. Expect agents to use MCP for the long-running work and WebMCP for the last step on a site.

Where this goes

February 2026
Chrome announces the early preview; Chrome 146 Canary gets a WebMCP for testing flag.
May 2026
Public origin trial opens in Chrome 149, headlined at I/O. Lighthouse gains agentic-browsing audits the same month.
July 2026
The spec moves the API from navigator.modelContext to document.modelContext; Chrome 150 deprecates the old path while the trial keeps serving it.
August 2026
draftStill a Community Group draft, not on the W3C standards track. Pilots named, deployments unconfirmed, no mainstream agent consuming tools yet.
Chrome 156
The origin trial's last version. The decision point: ship by default, extend, or rework based on trial data.
Six months from announcement to a live origin trial. The next six decide whether it becomes a default.

The honest state of WebMCP in August 2026 is a standard with everything except users. The spec is active, the origin trial is live, the tooling is decent, and almost no production site exposes a tool — because almost no agent calls one. Claude, ChatGPT Agent, Perplexity and even Gemini do not consume WebMCP tools in the wild yet. That will change the day Gemini in Chrome ships with it on, and the first travel or commerce pilot publishes a conversion number. Everything after that is a stampede: once one retailer shows that agent checkouts convert, the rest add two attributes to a form.

Three things are still unsettled. The declarative form section of the spec is literally marked TODO, so attribute names could shift. Security is the hard one: a tool runs with the user's session, so a prompt injection in a product review that talks an agent into calling checkout() is a confused-deputy attack with real money attached, and the spec's mitigations — input length limits, untrustedContentHint, shared attack datasets — are a start, not an answer. Expect browsers to require a user confirmation for any tool without readOnlyHint. And standardisation: for this to be the web's agent layer rather than Chrome's, it needs Firefox and Safari to implement, or the standards track, or both.

The bet I would make: WebMCP becomes to agents what responsive design became to phones — not optional, not glamorous, and eventually assumed. The web survived the shift to mobile by describing itself better to a new kind of client. This is the same move for a client that reads schemas instead of screens. Start with your forms. Sources: Chrome's WebMCP early preview announcement, the declarative and imperative API docs, the WebMCP draft specification, and Spronta's State of WebMCP, July 2026.

Share

Related

Claude Sonnet 5.5: Opus-Level Scores at Half the Price, and Where It Still Falls Short
Gemini 4 Argon: Google's New Frontier Model, the Benchmarks, the Price and What It Can Do
Claude Opus 5.5: Every Benchmark, From Anthropic, Cursor, Artificial Analysis, Sonar and ARC Prize