---
title: "WebMCP: expose tools AI agents can call - Serpwise"
description: "WebMCP lets your site declare structured tools - search, filters, signups - that in-browser AI agents invoke directly instead of guessing from the DOM."
url: "https://serpwise.ai/learn/webmcp/"
source: "https://serpwise.ai/learn/webmcp/"
---
[← Back to Learn](/learn/)

AI & Bot Visibility Warning

# WebMCP: expose tools AI agents can call

WebMCP lets your site declare structured tools - search, filters, signups - that in-browser AI agents invoke directly instead of guessing from the DOM.

Today an AI agent completes a task on your site by *actuating* - simulating clicks and keystrokes, interpreting each control as it goes. Every step is a chance to misread the page. [WebMCP](https://github.com/webmachinelearning/webmcp) is a proposed browser standard that replaces guessing with declaration: your site exposes named **tools** (like `search_site`, `filter_results`, or `request_demo`) with typed inputs, and the browser agent calls them directly. Google’s [Lighthouse Agentic Browsing](https://developer.chrome.com/docs/lighthouse/agentic-browsing/scoring) audit checks whether a page registers valid WebMCP tools.

It is an evolving browser standard - treat this as a high-leverage, progressive enhancement for in-browser AI agents.

## Why it matters

- **Reliability.** A declared tool with a JSON schema or typed form parameters removes ambiguity. The agent knows the action exists, what arguments it takes, and what it returns - fewer failed or wrong actions.
- **You keep control.** Tools execute visibly on your page, through your UI, so users see what happened and your brand and design stay intact.
- **First-mover signal.** As agentic browsing matures, sites that expose clean tools will convert agent-driven sessions that others lose to DOM actuation errors.

## The two APIs

WebMCP offers a [declarative API](https://developer.chrome.com/docs/ai/webmcp/declarative-api) (annotate HTML forms) and an [imperative API](https://developer.chrome.com/docs/ai/webmcp/imperative-api) (register tools in JavaScript).

### Declarative: annotate a form

Add `toolname` and `tooldescription` to a `<form>`, and `toolparamdescription` to its fields. For read-only `GET` forms like site search or catalog filters, add `toolautosubmit` so the browser agent can execute the query without an extra confirmation prompt.

```
<form
	action="/search"
	method="get"
	toolname="site_search"
	tooldescription="Search pages and content across example.com"
	toolautosubmit
>
	<input
		name="q"
		type="search"
		toolparamdescription="Search query keywords (text)"
	/>
	<button type="submit">Search</button>
</form>
```

When an agent calls `site_search`, the browser focuses the form, populates the fields, and runs the action through your normal UI.

### Imperative: register in JavaScript

For capabilities that aren’t tied to a single HTML form (semantic site search, full-page markdown retrieval, product catalog lookup), register tools on `document.modelContext` (or `navigator.modelContext` in earlier Chrome versions):

```
const ctx = document.modelContext ?? navigator.modelContext;
ctx?.registerTool({
	name: "search_site",
	description: "Semantic search across pages and content on example.com.",
	annotations: { readOnlyHint: true, untrustedContentHint: true },
	inputSchema: {
		type: "object",
		properties: { query: { type: "string" } },
		required: ["query"],
	},
	async execute({ query }) {
		const res = await fetch("/mcp", {
			method: "POST",
			headers: { "Content-Type": "application/json" },
			body: JSON.stringify({
				jsonrpc: "2.0",
				id: 1,
				method: "tools/call",
				params: { name: "search_content", arguments: { query } },
			}),
		});
		const data = await res.json();
		return data.result;
	},
});
```

## How to detect it

- Run our free [agent-readiness scanner](/agent-ready) against any URL to check whether WebMCP tools, `/_sw/webmcp.js`, or declarative `<form toolname>` annotations are exposed.
- Install the [Model Context Tool Inspector extension](https://chromewebstore.google.com/detail/model-context-tool-inspec/gbpdfapgefenggkahomfgkhfehlcenpd) in Chrome to inspect registered tools and invoke them manually.
- Statically, look for `<form toolname tooldescription>` markup (declarative), `<script src="/_sw/webmcp.js">` (Serpwise edge bridge), or `document.modelContext` / `navigator.modelContext` references in your scripts (imperative).

## Common pitfalls

- **Dual namespace compatibility.** Chrome evolved `navigator.modelContext` toward `document.modelContext`. Always feature-detect both (`document.modelContext ?? navigator.modelContext`) and never treat WebMCP as a hard runtime dependency.
- **Timing matters for imperative tools.** Tools registered late (after slow client bundles finish hydrating) may miss an agent’s initial snapshot. Register tools as early as possible.
- **Never expose authentication or payment forms.** Tools execute real actions. Never annotate login, registration, password reset, checkout, or credit-card forms (`input[type="password"]`, `autocomplete="cc-*"`) as WebMCP tools.

## Fix at the edge with Serpwise

Turn on **Agent-ready mode → WebMCP bridge** in your domain’s **AI Access** settings to deploy full WebMCP support across every page with **zero origin code changes**:

1. **Same-Origin Imperative Tool Bridge (`/_sw/webmcp.js`)** - Injects a lightweight, CSP-aware script that registers live tools (`search_site`, `get_page`, and `search_products` / `get_product_details` when a product catalog is present) on both `document.modelContext` and `navigator.modelContext`, wired directly to your domain’s [MCP Server](/mcp-server) without exposing API keys in the browser.
2. **Declarative `<form>` Auto-Annotation** - Automatically upgrades safe native forms (`site_search`, `filter_results`, `newsletter_signup`, `contact_us`, `request_demo`) and Serpwise forms (`form[data-sw-action]`) with `toolname`, `tooldescription`, `toolautosubmit` (on read-only `GET` queries), and `toolparamdescription` on every input field.
3. **Sensitive Form Protection & 1-Click Custom Form Activation** - Automatically skips login, password, and payment forms, and lists any custom multi-field forms in your dashboard so you can enable them as WebMCP tools in one click.
4. **`SubmitEvent.agentInvoked` & `respondWith()` Handoff** - Intercepts agent-triggered submissions on Serpwise forms and returns structured JSON completion results directly to the browser agent via `event.respondWith(Promise)`.

[Test your site with the free Agent-Ready Scanner](/agent-ready), explore [MCP Server & WebMCP](/mcp-server), or run a [free SEO & AI audit](/audit).

From diagnosis to deployment

## Find the issue. Ship the fix.

Use Learn to understand the problem, then run Serpwise against your own site to see what can be approved and deployed.

[Run free audit](/audit/) [Book a demo](/demo/)