document.modelContext) that Gemini in Chrome, the Model Context Tool Inspector extension, DevTools’ WebMCP pane and other in-browser agents use to discover and call a page’s tools.
Why Use WebMCP?
Agents Act Through Your Code
Agents call the operations you define (search, add to cart, fill a form) instead of guessing clicks on the DOM
One Definition, Every Client
The same tools serve MCP clients, React hooks, and in-browser agents
Hookable Like Any Call
Every agent call runs the
tools:call-tool flow: hooks, authorities, quota and availableWhen applyPage-Aware Tools
Tools from
server.registerTool() and React’s useDynamicTool appear and disappear with the UIInstallation
Quick Start
WebMcpPlugin.init(), with or without options.
With React, pass the same server to the provider. Tools that components register with useDynamicTool are server tools, so the plugin exposes them too:
How It Works
1
List
Once the server is ready, the plugin lists its tools through the
tools:list-tools flow on the 'webmcp' surface — so availableWhen, authorities and list hooks decide what agents see.2
Register
Each listed tool is registered with
document.modelContext.registerTool(), with an AbortSignal the plugin keeps.3
Stay in Sync
When the server’s tools change (
server.registerTool(), useDynamicTool, a remote app connecting), the plugin re-lists and registers, re-registers or unregisters only what changed. A burst of changes syncs once.4
Call
An agent’s call runs the
tools:call-tool flow on the 'webmcp' surface, with the agent’s cancellation signal linked to the tool’s this.signal.5
Clean Up
server.dispose() unregisters every tool.Choosing What Agents See
The'webmcp' call surface decides per tool:
surface is offered everywhere. For a decision the metadata can’t express, use the include option:
Plugin Options
Calling as the Signed-In User
By default the server sees an anonymouswebmcp caller in one session. When the page knows its user, pass it:
refresh() on the bridge so the exposed tools follow:
How Tools Are Translated
Trying It in Chrome
WebMCP is in origin trial in Chrome and Edge (Chrome 149–162). For local development:- Open
chrome://flags/#enable-webmcp-testing, enable it, and restart Chrome. - Optionally enable
chrome://flags/#devtools-webmcp-supportfor the DevTools pane. - Open your page, then DevTools → Application → WebMCP to list the page’s tools and run them, or use the Model Context Tool Inspector extension to have an agent call them.
Other Browsers
Wheredocument.modelContext is missing, the plugin does nothing and the server works as usual; isWebMcpSupported() tells you up front. To reach agents in other browsers, install a polyfill that provides document.modelContext before creating the server — for example @mcp-b/global, which also bridges the page’s tools to the MCP-B browser extension — or pass one as the modelContext option.
Security
- Secure context. WebMCP exists only on HTTPS pages (and
localhost). - Permissions policy. The
toolsfeature defaults to'self': top-level pages and same-origin iframes may register tools. A cross-origin iframe needs<iframe allow="tools">, andPermissions-Policy: tools=()turns WebMCP off. - Cross-origin exposure is opt-in. Tools are offered to other origins only through
exposedTo, and the other origin must ask for them. - Treat agent input as user input. Agents call your tools with arguments a model chose. Validate them (zod
inputSchemas do), keep consequential operations behinddestructiveHint: trueso agents can ask the user first, and keep anything an agent must never do off the'webmcp'surface.
Limitations
- Tools only. WebMCP has no resources or prompts; they stay MCP-only.
- No elicitation or sampling. WebMCP has no channel back to the agent (
requestUserInteractionwas removed from the draft), so a tool that elicits fails when an in-browser agent calls it. - The declarative API is not covered. HTML forms with
toolnameattributes are registered by the browser, not by FrontMCP. - The API is still changing. The plugin targets the WebMCP draft of 2026-09-30 (
registerToolwith anAbortSignal); earlier Chrome builds withnavigator.modelContextare not supported.