Loading
All articles
AI 21 min read

What Is WebMCP? How Websites Can Talk Directly to AI Agents

WebMCP lets a website hand AI agents a menu of actions, like search_products or add_to_cart, instead of making them click around like a person. Learn what it is in plain words, then build real tools with JavaScript and HTML forms.

nbkhope
On this page

What Is WebMCP? How Websites Can Talk Directly to AI Agents

Picture an AI assistant trying to book you a table at a restaurant's website. Today, most agents do it the hard way: they take a screenshot, guess which box is the date picker, type, click, take another screenshot to see whether anything happened, and repeat. It works, sometimes. It is slow, expensive, and one redesign away from breaking.

WebMCP is a proposed web standard that offers a shortcut. Instead of making the agent figure out your page, the page tells the agent: "Here is what you can do here, here is what I need from you, and here is the button to press." In this article you'll learn what that means in plain words, then build real WebMCP tools with JavaScript and with an ordinary HTML form.

Illustration of a browser window on shop.example with three tool cards, search_products, add_to_cart and place_order, connected by dashed lines to a small robot, next to the title What Is WebMCP?

WebMCP in one sentence

The name comes from MCP, the Model Context Protocol, the popular standard for connecting AI apps to tools and data. The WebMCP draft describes web pages that use it as MCP servers "that implement tools in client-side script instead of on the backend." In other words: same idea, but the tools live inside the web page you already have open.

A plain-words analogy: a menu for robots

Imagine walking into a restaurant with no menu. To order, you'd have to wander into the kitchen, look at the ingredients, and guess what the cook can make. That is how AI agents use most websites today: they read pixels and HTML, then guess.

Now imagine the restaurant hands you a menu. Each dish has a name, a short description, and maybe a question ("How spicy?"). You order by name, the kitchen cooks, and a plate comes out. That menu is what WebMCP gives an agent.

Comparison of two panels. Without WebMCP, the agent takes a screenshot, guesses which box is the search bar, types, scrolls and clicks, takes another screenshot, and looks for quantity and Add to cart, repeating often more than ten times; it is slow and costly, breaks when the design changes, and can click the wrong thing. With WebMCP, the agent reads the page's tool list, calls search_products, calls add_to_cart with productId shoe-42 and quantity 2, and gets back a clear answer: Added 2 times shoe-42, cart total 179.98 dollars.

A few things make this more than a convenience:

  • The site decides what is on the menu. An agent can only call the tools you register. If you don't offer delete_account, there is no tool for it.
  • It keeps working after a redesign. Moving a button doesn't change the name of the add_to_cart tool.
  • The person stays in the loop. The tools run inside the user's own tab, with their own login, and the page updates on screen as the agent works. This is the main difference from a backend integration, where the work happens out of sight.
  • It's cheaper and faster. One precise call replaces a long loop of screenshots and guesses.

WebMCP doesn't replace screen-reading agents. Sites without WebMCP still work the old way, and an agent can fall back to clicking when no tool fits.

Who is behind it, and can you use it yet?

WebMCP started in 2025 as an explainer by engineers at Microsoft and Google, and is now developed in the open by the W3C Web Machine Learning Community Group. The latest draft report, from November 19, 2026, lists editors from both companies.

Timeline. 2025: Microsoft and Google engineers publish the first explainer. February 2026: Chrome opens an early preview program for prototyping. June 2026: origin trial in Chrome 149, so real sites can try it with users. 2026: origin trial in Microsoft Edge 150. November 2026: new draft report from the W3C Web Machine Learning Community Group. Next: feedback, more browsers, maybe a formal standard.
WhereStatus (late 2026)
ChromeOrigin trial from Chrome 149; chrome://flags/#enable-webmcp-testing for local testing
Microsoft EdgeOrigin trial in Edge 150
Firefox, SafariStandards discussions only
SpecDraft Community Group report, not yet an official W3C standard

An origin trial is Chrome's way of letting real websites try an unfinished feature with real users: you register your site, get a token, and add it to your pages. Without a token, the feature is only available to people who flip the testing flag.

The big picture: who does what

Five players take part in every WebMCP tool call:

  1. The web page registers its tools when it loads.
  2. The browser keeps the list and shares it with an agent.
  3. You ask the agent for something.
  4. The AI agent picks a tool and fills in the inputs.
  5. The page's JavaScript does the work, usually by calling the site's normal API with your existing cookies, and updates what you see.
Sequence diagram with five lanes: You, AI agent, Browser, Web page JavaScript and the site's API. 1, the page calls registerTool for add_to_cart. 2, you ask the agent to add 2 Trail Runners to your cart. 3, the browser gives the agent the tool list with names, descriptions and schemas. 4, the agent calls add_to_cart with shoe-42 and 2. 5, the browser runs the tool's execute function in the page. 6, the page fetches /api/cart with your cookies. 7, the API answers that the cart was updated. 8, the page updates what you see. 9, the page returns the result to the agent. 10, the agent tells you it's done and the cart total is 179.98 dollars.

Notice what is not in the picture: no extra server, no new API keys, no separate login. The tool reuses everything the website already has.

How WebMCP differs from a classic MCP server

If you've read Build Your Own MCP Server, you know a classic MCP server is a program you host. An AI app connects to it and calls its tools at any time. WebMCP moves the tools into the page.

Comparison. Classic MCP server: an AI app connects to an MCP server on your backend, which calls your API and database. WebMCP: an AI agent in or beside the browser calls tools written in JavaScript in a web page tab, which call the same API the site uses. Where tools run: on a server you host, versus in the user's open web page. When available: any time, versus while that page is open. Who is logged in: separate auth such as OAuth or keys, versus the user's existing session. What the user sees: usually nothing, versus the page updating live. Best for: background jobs and any client, versus helping a person on your site.

They are teammates, not rivals. The WebMCP explainer lists "replacement of backend integrations" as a non-goal. A travel site might run a classic MCP server so assistants can check flight prices in the background, and use WebMCP so an agent can help a person finish a booking on the page they're looking at.

The anatomy of a tool

Every WebMCP tool has the same parts. Here they are with the menu analogy:

A tool definition for add_to_cart with five callouts. name is the dish's name, a short unique id the agent uses to order it. description says what it is and when to order it, in plain words the AI model reads to pick the right tool. inputSchema is what the kitchen needs to know, a JSON Schema with the inputs, their types and limits. annotations are warnings on the menu, hints such as only looks or has big consequences. execute is the kitchen, your code, which runs in the page with the user's login.
PartRequired?What it is
nameYesA unique id: 1 to 128 letters, digits, _, - or .
titleNoA human-friendly label
descriptionYesWhat the tool does and when to use it. The model reads this to decide.
inputSchemaNoA JSON Schema object describing the inputs
annotationsNoHints such as readOnlyHint (see the safety section below)
executeYesAn async function that receives the inputs and returns a result

The entry point is document.modelContext. You add a tool with registerTool(), and you remove it by aborting an AbortSignal you passed in when registering.

Example 1: a to-do list with two tools

Let's start small. Here's a to-do app that offers two tools: one to add an item and one to read the list. Load it with <script type="module" src="todo-tools.js"></script> so top-level await works.

<h1>My to-dos</h1>
<ul id="todo-list"></ul>
<script type="module" src="todo-tools.js"></script>
1// todo-tools.js
2const todos = [];
3
4function renderTodos() {
5  const list = document.querySelector('#todo-list');
6  const items = todos.map((todo) => {
7    const item = document.createElement('li');
8    item.textContent = todo.done ? `✔ ${todo.text}` : todo.text;
9    return item;
10  });
11  list.replaceChildren(...items);
12}
13
14if ('modelContext' in document) {
15  await document.modelContext.registerTool({
16    name: 'add_todo',
17    title: 'Add a to-do',
18    description: 'Add a new item to the user\'s to-do list. Use it when the user asks to add, remember or plan a task.',
19    inputSchema: {
20      type: 'object',
21      properties: {
22        text: {
23          type: 'string',
24          description: 'The task in the user\'s own words, for example "Buy milk".',
25        },
26      },
27      required: ['text'],
28    },
29    async execute({ text }) {
30      const task = text.trim();
31      if (!task) {
32        throw new Error('The to-do text is empty. Ask the user what to add.');
33      }
34      todos.push({ text: task, done: false });
35      renderTodos();
36      return `Added "${task}". The list now has ${todos.length} item(s).`;
37    },
38  });
39
40  await document.modelContext.registerTool({
41    name: 'list_todos',
42    title: 'List to-dos',
43    description: 'Return every item on the user\'s to-do list and whether it is done.',
44    inputSchema: { type: 'object', properties: {} },
45    annotations: { readOnlyHint: true },
46    async execute() {
47      return JSON.stringify(todos);
48    },
49  });
50}

What happens when someone tells their agent "Add buy milk and call the dentist to my list":

1add_todo { "text": "  Buy milk " }        → "Added \"Buy milk\". The list now has 1 item(s)."
2add_todo { "text": "Call the dentist" }   → "Added \"Call the dentist\". The list now has 2 item(s)."
3list_todos { }                            → [{"text":"Buy milk","done":false},{"text":"Call the dentist","done":false}]
4add_todo { "text": "  " }                 → Error: The to-do text is empty. Ask the user what to add.

And the page shows two new list items, exactly as if the user had typed them.

Three habits are already visible here:

  • The execute function calls the same code as your UI (renderTodos()), so people and agents see the same state.
  • Errors explain what to do next. The model reads the error message, so "Ask the user what to add" is more useful than "invalid input".
  • The read-only tool says so with readOnlyHint: true.

Example 2: an online store, with a confirmation step

A real store needs more care, because some actions cost money. Here we offer three tools: search (read-only), add to cart, and place an order. The tools call the store's existing API with fetch(), so the user's normal session cookies come along and no new authentication is needed.

1<span id="cart-count">0</span>
2<dialog id="confirm-order">
3  <form method="dialog">
4    <p></p>
5    <button value="no">Cancel</button>
6    <button value="yes">Place order</button>
7  </form>
8</dialog>
1// shop-tools.js
2async function askUserToConfirm(message) {
3  const dialog = document.querySelector('#confirm-order');
4  dialog.querySelector('p').textContent = message;
5  dialog.showModal();
6  return new Promise((resolve) => {
7    dialog.addEventListener('close', () => {
8      resolve(dialog.returnValue === 'yes');
9    }, { once: true });
10  });
11}
12
13await document.modelContext.registerTool({
14  name: 'search_products',
15  description: 'Search the store catalog by keywords. Returns up to 5 products with id, name, price in US dollars and average rating.',
16  inputSchema: {
17    type: 'object',
18    properties: {
19      query: { type: 'string', description: 'Words to search for, e.g. "running shoes".' },
20      maxPrice: { type: 'number', description: 'Optional highest price in US dollars.' },
21    },
22    required: ['query'],
23  },
24  annotations: { readOnlyHint: true, untrustedContentHint: true },
25  async execute({ query, maxPrice }) {
26    const parameters = new URLSearchParams({ q: query, limit: '5' });
27    if (maxPrice !== undefined) {
28      parameters.set('maxPrice', String(maxPrice));
29    }
30    const response = await fetch(`/api/products?${parameters}`);
31    const products = await response.json();
32    return JSON.stringify(products);
33  },
34});
35
36await document.modelContext.registerTool({
37  name: 'add_to_cart',
38  description: 'Add a product to the shopping cart. Use a product id returned by search_products.',
39  inputSchema: {
40    type: 'object',
41    properties: {
42      productId: { type: 'string' },
43      quantity: { type: 'integer', minimum: 1, maximum: 10 },
44    },
45    required: ['productId'],
46  },
47  async execute({ productId, quantity = 1 }) {
48    const response = await fetch('/api/cart', {
49      method: 'POST',
50      headers: { 'Content-Type': 'application/json' },
51      body: JSON.stringify({ productId, quantity }),
52    });
53    if (!response.ok) {
54      throw new Error(`Could not add ${productId}: ${await response.text()}`);
55    }
56    const cart = await response.json();
57    document.querySelector('#cart-count').textContent = cart.itemCount;
58    return `Added ${quantity} × ${productId}. The cart has ${cart.itemCount} item(s), total $${cart.total}.`;
59  },
60});
61
62await document.modelContext.registerTool({
63  name: 'place_order',
64  description: 'Place the order for everything in the cart, using the shipping address and card saved in the user\'s account.',
65  inputSchema: { type: 'object', properties: {} },
66  annotations: { consequentialHint: true },
67  async execute() {
68    const cart = await (await fetch('/api/cart')).json();
69    const confirmed = await askUserToConfirm(`Place this order for $${cart.total}?`);
70    if (!confirmed) {
71      return 'The user declined. The order was not placed.';
72    }
73    const order = await (await fetch('/api/orders', { method: 'POST' })).json();
74    return `Order ${order.id} placed. Estimated delivery: ${order.deliveryDate}.`;
75  },
76});

A conversation with this store, step by step:

1search_products { "query": "running shoes", "maxPrice": 100 }
2  → GET /api/products?q=running+shoes&limit=5&maxPrice=100
3  → [{"id":"shoe-42","name":"Trail Runner","price":89.99,"rating":4.6}]
4add_to_cart { "productId": "shoe-42", "quantity": 2 }
5  → "Added 2 × shoe-42. The cart has 2 item(s), total $179.98."
6place_order { }   (the user clicks Cancel in the dialog)
7  → "The user declined. The order was not placed."
8place_order { }   (the user clicks Place order)
9  → "Order A-1027 placed. Estimated delivery: 2026-12-08."

Why each choice matters:

  • search_products is marked untrustedContentHint because product names and reviews can contain text written by strangers. That tells the agent to treat the result as data, not as instructions, a key defense against prompt injection.
  • place_order is marked consequentialHint, and it asks the person in the page's own dialog. Don't rely on the agent alone to ask: the hint is a request, while the dialog is a guarantee your code controls.
  • The quantity limits (minimum: 1, maximum: 10) are in the schema, but your server must still check them. A schema guides the model; it doesn't protect your backend.

Example 3: turn an existing form into a tool, no JavaScript needed

Many sites already have the perfect tool: a form. WebMCP's declarative proposal turns a form into a tool with a few HTML attributes:

1<form id="reservation-form"
2      toolname="book_table"
3      tooldescription="Reserve a table at Luigi's Trattoria for a date, a time and a party size."
4      action="/reservations" method="post">
5  <label>Date
6    <input type="date" name="date" required
7           toolparamdescription="Reservation date, in YYYY-MM-DD format">
8  </label>
9  <label>Time
10    <select name="time" toolparamdescription="Seating time, 24-hour clock">
11      <option>18:00</option>
12      <option>19:30</option>
13      <option>21:00</option>
14    </select>
15  </label>
16  <label>Guests
17    <input type="number" name="guests" min="1" max="12" required
18           toolparamdescription="Number of people, including the user">
19  </label>
20  <button type="submit">Reserve</button>
21</form>
  • toolname and tooldescription turn the form into a tool. Remove either one and the tool goes away.
  • toolparamdescription explains a field to the model. The browser builds the input schema from the fields themselves: their name, type, required, min, max and <option> values.
  • Without toolautosubmit, the agent fills in the form and the person clicks Reserve. Add toolautosubmit only when it is safe to submit without a human click.

By default the form submits as usual and the page navigates. If you'd rather stay on the page and send the agent a clear answer, handle the submit event. The proposal adds two things to it: agentInvoked, which is true when an agent submitted the form, and respondWith(), which hands the agent a result:

1// reservation.js
2const form = document.querySelector('#reservation-form');
3
4form.addEventListener('submit', (event) => {
5  if (!event.agentInvoked) {
6    return; // A person clicked the button: submit the form normally.
7  }
8  event.preventDefault();
9  event.respondWith(sendReservation(new FormData(form)));
10});
11
12async function sendReservation(formData) {
13  const response = await fetch('/reservations', { method: 'POST', body: formData });
14  if (!response.ok) {
15    return `No table available: ${await response.text()}`;
16  }
17  const reservation = await response.json();
18  return `Table booked for ${reservation.guests} on ${reservation.date} at ${reservation.time}. Confirmation code ${reservation.code}.`;
19}

When an agent submits for 4 people on December 12 at 19:30, it gets back "Table booked for 4 on 2026-12-12 at 19:30. Confirmation code LT-5531." When a person clicks Reserve, nothing changes from how the form always worked.

Side by side. Declarative, with HTML attributes: a form with toolname book_table, tooldescription, and an input with toolparamdescription; it is proposed and Chrome implements it for testing; it is the fastest start since you already have forms, the browser builds the input schema from your form fields, and by default the person still clicks submit. Imperative, with the JavaScript API: document.modelContext.registerTool with name, description, inputSchema and execute; it is in the spec draft and the origin trial; it can do anything your app can do in code, gives full control of inputs and results, and lets you add and remove tools as the page changes.

Example 4: tools that come and go with your components

In a single-page app, tools should match what is on screen. A tool for editing a document makes no sense on the settings page. Because registerTool() accepts an AbortSignal, cleaning up is one line. Here's a small React hook:

1import { useEffect } from 'react';
2
3export function useWebMcpTool(tool) {
4  useEffect(() => {
5    if (!('modelContext' in document)) {
6      return undefined;
7    }
8    const controller = new AbortController();
9    async function register() {
10      try {
11        await document.modelContext.registerTool(tool, { signal: controller.signal });
12      } catch (error) {
13        console.error(`Could not register the ${tool.name} tool`, error);
14      }
15    }
16    register();
17    return () => controller.abort(); // Unregisters the tool when the component goes away.
18  }, [tool]);
19}

Mount a component that calls useWebMcpTool(...) and the tool appears in the list. Unmount it and the tool disappears. Define the tool object outside the component (or with useMemo) so it isn't re-registered on every render. The same AbortController pattern works in Vue, Svelte, Angular or plain JavaScript.

Safety: annotations and good habits

Letting software act on someone's behalf is powerful, and the WebMCP draft spends a whole section on what can go wrong: prompt injection hidden in tool descriptions or results, tools that do more than the user intended, and sites asking for more personal data than a task needs. Annotations are the first line of defense:

Table of three annotations. readOnlyHint means the tool only looks and changes nothing, for example search_products or list_todos; it is usually fine to call without asking. untrustedContentHint means the output has text from strangers, such as product reviews, emails or comments; treat it as data, never as orders. consequentialHint means the action is hard to undo or high stakes, such as place_order, send_email or delete; ask the person first. Footer: hints, not locks. A malicious or buggy agent can ignore them. Validate inputs in execute, confirm risky actions in your own UI, and check permissions on your server.

A checklist for safe, useful tools:

  1. Offer only what you'd offer a person. If a logged-in user can't do it from your UI, a tool shouldn't do it either.
  2. Confirm risky actions in your own UI, as place_order does, in addition to consequentialHint.
  3. Validate everything in execute() and on the server. The schema guides the model; it isn't security.
  4. Ask for raw values, not computed ones. shipping: "Express" is easier for a model to get right than shippingId: 1.
  5. Write descriptions like instructions to a new coworker: what the tool does and when to use it, in positive terms. Chrome's guide gives "This tool can create a calendar event, scheduled for a specific date and time."
  6. One job per tool. create_event that creates an event beats start_event_creation_process that redirects somewhere.
  7. Return messages the model can act on, including in errors.
  8. Mark untrusted output with untrustedContentHint whenever results include user-generated text.
  9. Mind iframes. A cross-origin iframe can only register tools if the parent page allows it with allow="tools".

For the bigger picture of how agents should handle tool permissions, see AI Agent Tool Permissions.

How to try it today

Six steps. 1, turn it on at chrome://flags/#enable-webmcp-testing. 2, register tools with registerTool or a toolname on a form. 3, inspect them in DevTools, Application, WebMCP. 4, run a tool by hand: fill the inputs, click Run tool and read the result. 5, try an agent with the Model Context Tool Inspector extension or Chrome DevTools MCP. 6, ship to users with an origin trial token from Chrome 149. Most bugs show up in the inspector: a vague description, a schema that does not match what execute expects, or an error message the model cannot act on.
  1. Enable the flag. In Chrome, open chrome://flags/#enable-webmcp-testing, set it to Enabled and relaunch.
  2. Add a tool with one of the examples above. Serve the page over https:// or http://localhost, since WebMCP only works in secure contexts.
  3. Open DevTools → Application → WebMCP. You'll see every registered tool, can run one by hand with your own inputs, and get a log of each call with its input and output.
  4. Try it with a real agent. The Model Context Tool Inspector extension lets a Gemini model call your tools (it needs your own API key). If you use an AI coding agent, Chrome DevTools MCP can list and run WebMCP tools when started with --categoryExperimentalWebmcp.
  5. Ship it to real users by registering your site for the WebMCP origin trial and adding the token to your pages:
<meta http-equiv="origin-trial" content="YOUR_ORIGIN_TRIAL_TOKEN">

Practice with a WebMCP tool

In the WebMCP lesson and practice lab, try a call to search_books and compare the page results with the structured response. The exercise works in your browser without a flag or API key. The lesson also links to a native demo for testing tool registration in a supported browser.

Frequently asked questions

Does WebMCP give AI companies access to my site's data?
No more than the user already has. Tools run in the user's tab with the user's session, and only the tools you register exist.

Do I need to run an MCP server?
No. WebMCP tools live in your page's JavaScript. You can still run a classic MCP server for background jobs; the two work well together.

Does it work without an AI agent?
Your page works exactly as before. The tools just sit there unused. That's why feature detection and a normal UI matter.

Which agents can use it?
Agents that run inside or connect to a browser that supports WebMCP, such as browser extensions and assistants built into browsers. Support is still rolling out; the WebMCP repository keeps an implementation status page with the current list.

Is it the same as MCP?
It borrows MCP's ideas (tools with names, descriptions and JSON Schema inputs), but it is a browser API, not the MCP wire protocol. Read What Is MCP? and MCP vs. Function Calling for the background.

Key takeaways

  • WebMCP lets a web page hand AI agents a menu of tools instead of making them click around like a person.
  • Tools have a name, a description, an input schema, optional annotations and an execute function that runs in the user's tab.
  • Build them with JavaScript (document.modelContext.registerTool()) or, as a proposal, with HTML form attributes (toolname, tooldescription, toolparamdescription).
  • It complements classic MCP servers: WebMCP is for helping a person on your site, while a backend server is for everything else.
  • It is experimental: an origin trial in Chrome 149 and Edge 150, plus a testing flag. Feature-detect, confirm risky actions yourself, and validate on the server.

Sources

Thanks for reading!

Know someone who would enjoy this? Send it their way.

More articles

Read next

Software & Tools 22 min read

Azure Key Vault for Node.js: A Visual, Hands-On Guide

Learn Azure Key Vault for Node.js visually, with no Azure account: run a local emulator, sign in with no password in your code, store and read secrets, rotate versions, recover deleted secrets, cache values safely, handle failures, and do the exercises.

nbkhope
Software & Tools 16 min read

Azure App Configuration for Node.js: A Visual, Hands-On Guide

Learn Azure App Configuration for Node.js visually, with no Azure account: run the official emulator, store and read settings, use read-only keys and labels, load them with the provider, refresh without a restart, handle failures, and do the exercises.

nbkhope

Comments

Be kind and specific. Comments with links from new accounts appear after a moderator reviews them.