Skip to main content
The WebMCP Plugin lets a website that runs FrontMCP in the page offer its tools to the agents in the user’s browser. It registers the server’s tools with WebMCP — the browser API (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 apply

Page-Aware Tools

Tools from server.registerTool() and React’s useDynamicTool appear and disappear with the UI

Installation

Quick Start

Install the plugin with 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:
A tool without 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 anonymous webmcp caller in one session. When the page knows its user, pass it:
When what the user may see changes (they sign in or out), call 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:
  1. Open chrome://flags/#enable-webmcp-testing, enable it, and restart Chrome.
  2. Optionally enable chrome://flags/#devtools-webmcp-support for the DevTools pane.
  3. 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.
To serve the API to visitors without the flag, register for the WebMCP origin trial and add the token to your page.

Other Browsers

Where document.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 tools feature defaults to 'self': top-level pages and same-origin iframes may register tools. A cross-origin iframe needs <iframe allow="tools">, and Permissions-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 behind destructiveHint: true so 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 (requestUserInteraction was 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 toolname attributes are registered by the browser, not by FrontMCP.
  • The API is still changing. The plugin targets the WebMCP draft of 2026-09-30 (registerTool with an AbortSignal); earlier Chrome builds with navigator.modelContext are not supported.

API Reference