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.

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.

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.

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_carttool. - 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.

| Where | Status (late 2026) |
|---|---|
| Chrome | Origin trial from Chrome 149; chrome://flags/#enable-webmcp-testing for local testing |
| Microsoft Edge | Origin trial in Edge 150 |
| Firefox, Safari | Standards discussions only |
| Spec | Draft 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:
- The web page registers its tools when it loads.
- The browser keeps the list and shares it with an agent.
- You ask the agent for something.
- The AI agent picks a tool and fills in the inputs.
- The page's JavaScript does the work, usually by calling the site's normal API with your existing cookies, and updates what you see.

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.

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:

| Part | Required? | What it is |
|---|---|---|
name | Yes | A unique id: 1 to 128 letters, digits, _, - or . |
title | No | A human-friendly label |
description | Yes | What the tool does and when to use it. The model reads this to decide. |
inputSchema | No | A JSON Schema object describing the inputs |
annotations | No | Hints such as readOnlyHint (see the safety section below) |
execute | Yes | An 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
executefunction 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_productsis markeduntrustedContentHintbecause 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_orderis markedconsequentialHint, 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
quantitylimits (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>toolnameandtooldescriptionturn the form into a tool. Remove either one and the tool goes away.toolparamdescriptionexplains a field to the model. The browser builds the input schema from the fields themselves: theirname,type,required,min,maxand<option>values.- Without
toolautosubmit, the agent fills in the form and the person clicks Reserve. Addtoolautosubmitonly 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.

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:

A checklist for safe, useful tools:
- 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.
- Confirm risky actions in your own UI, as
place_orderdoes, in addition toconsequentialHint. - Validate everything in
execute()and on the server. The schema guides the model; it isn't security. - Ask for raw values, not computed ones.
shipping: "Express"is easier for a model to get right thanshippingId: 1. - 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."
- One job per tool.
create_eventthat creates an event beatsstart_event_creation_processthat redirects somewhere. - Return messages the model can act on, including in errors.
- Mark untrusted output with
untrustedContentHintwhenever results include user-generated text. - 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

- Enable the flag. In Chrome, open
chrome://flags/#enable-webmcp-testing, set it to Enabled and relaunch. - Add a tool with one of the examples above. Serve the page over
https://orhttp://localhost, since WebMCP only works in secure contexts. - 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.
- 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. - 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
executefunction 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
- WebMCP draft Community Group report, W3C Web Machine Learning Community Group, November 19, 2026
- WebMCP repository and explainers, including the declarative API explainer and implementation status
- WebMCP documentation, Chrome for Developers
- WebMCP origin trial announcement, Chrome for Developers, June 9, 2026
- WebMCP early preview, Chrome for Developers, February 10, 2026
Read next

What Is the JavaScript Programming Language? A Simple Guide to the Language of the Web
A friendly, jargon-free guide to JavaScript, the programming language that makes websites interactive. Learn what it does in your browser, how it was born in 10 days, why it gets faster as it runs, and where it's used beyond the web.

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.

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.
Comments
Be kind and specific. Comments with links from new accounts appear after a moderator reviews them.