How Cloudflare WebMCP Lets an AI Agent List Page Tools and Call Them with JSON (2026)
The agent should not guess which button to press. The site registers tools on document.modelContext. The agent asks for the current page’s list, then sends the arguments as one JSON string. The model only fills that JSON. The page’s own script runs the tool, or it calls the same-origin /mcp endpoint.
Before you read
| Object | Public fact as of 2026-10-20 | How an agent uses it |
|---|---|---|
| Page bridge | Developer preview on 6 August. After Agent Readiness is on, the edge adds /.webmcp/bridge.js to HTML. Origin code stays put | If the browser has no WebMCP, the bridge returns and the page is unchanged |
| document.modelContext | 28 September Browser Run: Lab and Kitesurf both use this API. Lab no longer exposes navigator.modelContextTesting | Register with registerTool. Do not copy navigator.modelContext from the experimental adapter |
| list_webmcp_tools | Chrome DevTools MCP hides this category by default. Cloudflare’s docs say --category-experimental-webmcp. Chrome’s docs say --categoryExperimentalWebmcp | List the current page only. The list can grow after a call |
| execute_webmcp_tool | pageId and toolName are required. input is optional and is a JSON string. On navigation, in-page executeTool may return null | Parse the string, then check inputSchema. null is not a failure |
lookup_amenity, search_location, and complete_booking come from Chrome’s public hotel demo, not from a Cloudflare production API. orders.example.test, A-1042, and sk_demo_not_real are fictional. The 6 August bridge is still the site-side preview. 28 September renamed the browser API.
The agent calls a tool the page registered, not a button coordinate
On 6 August Cloudflare opened a developer preview of WebMCP. The dashboard path is WebMCP under Agent Readiness. HTMLRewriter then adds one same-origin script to each HTML response: /.webmcp/bridge.js. The sample tag carries data-packs="c2pa,mcp-server-client" and data-mcp-url="/mcp". Content Credentials and Site MCP Server are on by default. In this preview every tool runs in the visitor’s browser. There is no round trip to a Cloudflare server for the tool itself. The Site MCP pack calls the site’s /mcp with the visitor’s own same-origin session.
- Register: for each tool from
tools/list, the bridge callsdocument.modelContext.registerTool.inputSchemais copied across. - List: the agent reads the current page with Chrome DevTools MCP’s
list_webmcp_tools. Without the experimental category flag, those two tools are absent. - Call:
inputonexecute_webmcp_toolis a JSON string. The page’sexecuteis what causes the side effect.
This is not the same path as the cf CLI JSON contract. That piece is an agent searching commands and calling the Cloudflare API. This piece is tools already registered on the page a visitor is looking at. The general chain for clicking, coding, and task agents is the browser-agent tool chain. The on-the-wire shape of tools/call is how a coding agent calls MCP.
Do not collapse three JSON shapes into one success
When the bridge turns one of the site’s own MCP tools into a page tool, execute posts JSON-RPC to the same-origin /mcp. The 6 August post shows this shape. The tool name and the order id below are fictional:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "lookup_order",
"arguments": {
"order_id": "A-1042"
}
}
}
The agent does not hand that object over as-is. The Chrome DevTools MCP tool reference says execute_webmcp_tool needs pageId (number) and toolName (string). input is an optional JSON string. The current handler JSON.parses it and requires an object. pageId 1 below is only an illustration:
{
"pageId": 1,
"toolName": "lookup_order",
"input": "{\"order_id\":\"A-1042\"}"
}
The list itself comes from document.modelContext.getTools(). Chrome’s write-up includes name, title, description, origin, inputSchema, and annotations as the fields you can copy into JSON. window is a live object, so leave it out. Why a required field cannot live only in the prompt: why AI needs JSON Schema. The object below uses that field list and a fictional site:
{
"name": "lookup_order",
"title": "",
"description": "Look up one order by id",
"origin": "https://orders.example.test",
"inputSchema": {
"type": "object",
"properties": {
"order_id": { "type": "string" }
},
"required": ["order_id"]
},
"annotations": {
"readOnlyHint": true,
"consequentialHint": false,
"untrustedContentHint": true,
"debugging": false
}
}
Return values are not one shape either. The edge bridge passes the MCP CallToolResult through. The experimental adapter in the Agents SDK flattens content to a string, and it still documents navigator.modelContext. The current Chrome DevTools MCP handler prints status, output, and errorText. Read the shape of the channel you actually called.
The bridge, the remote browser, and the confirm button are three different things
The same docs describe two browsers. They are not one switch:
| What you see | What it means |
|---|---|
| Lab, lab=true on the URL | Experimental Chrome. wrangler browser create --lab works, the session shows up in wrangler browser list, and a live view can be opened. The docs say not to use it for production. |
| Kitesurf, browser=kitesurf on the URL | It has its own WebMCP and does not need a lab session. It does not accept keep_alive. Sessions are absent from list and have no live view. An agent cannot click a tool that is waiting for a person. |
| A new tool after search_location | The hotel demo starts with lookup_amenity, search_location, and view_hotel. filter_search_results appears after search_location runs with query Paris. The list follows page state. |
| complete_booking | The documented demo pauses until a person selects Confirm Reservation. An empty input is the JSON text of an empty object, not a bare object parameter. Use a fictional guest such as ada@example.test. Do not copy the address from the demo page. |
Kitesurf does not implement the WebMCP tools permissions policy or origin filtering. Tools registered in an iframe or a popup are not exposed through CDP. Lab sessions count against the regular limits. The token belongs in the MCP client’s Authorization header. The sample values are sk_demo_not_real and acct_demo_1042.
Six checks before a page call is allowed
Do not start by pasting a token into the prompt:
- A person turns WebMCP on in the dashboard. Confirm the HTML contains
/.webmcp/bridge.js. A browser withoutdocument.modelContextmakes the bridge return. - Copy the flag from the page you are reading. The Browser Run docs write
--category-experimental-webmcp. Chrome’s own docs write--categoryExperimentalWebmcp. Do not mix the two spellings. - Call list_webmcp_tools first. Trust only the list for the current
pageId. If a call changes the page, list again. - Use inputSchema as the gate. If
requiredis missing, do not call. Cross-origin tools stay out ofgetTools()unlessfromOriginsnames them. - Make input a string first. Run
JSON.stringifyon the object, then put that text in the parameter. If the parse is not an object, the current handler rejects it. - Move human-confirmation tools to a Lab live view. On Kitesurf the agent cannot see that button. In this preview,
signatureVerifiedon the closer Content Credentials inspect stays false. A decoded claim is not a checked signature.
When the page navigates, Chrome says executeTool may return null. In the hotel demo, search_location sends the page to the results. null means the call handed off a navigation. It is not a failure sitting in errorText.
Spread the three JSON values out before a write
Most failures are a stale list, an input passed as an object, or a null read as a failed delete.
- format the
getTools()result next to the arguments you are about to send, then use schema validation to see that everyrequiredentry ininputSchemais present. - Use JSONPath extract to pull
$.name,$.origin, and$.inputSchema.required. Stop if origin is not the site you meant to call. - Use JSON Diff on the
tools/callarguments and the object inside theexecute_webmcp_toolstring. If the fields disagree, fix the arguments before the prompt. - If the return has only
status,output, anderrorText, read that channel. Do not wrap it in anothersuccessobject. - Do not paste tokens, account ids, or a real guest email into a public formatter. JSONSort runs locally in the browser.
When the three pieces match, the agent is calling a tool the page registered. Indentation itself is not an error.
Common mistakes
- Reading the 6 August preview as an agent that simply clicks less. The product difference is the tool list and the JSON arguments. Screenshot-and-click is a different article.
- Copying navigator.modelContext from the Agents SDK experimental adapter. The 6 August bridge, the 28 September Browser Run changelog, and Chrome’s current write-up all use
document.modelContext. That adapter also flattens the result to a string. - Passing input as an object. The tool reference says a JSON string. If parsing fails, or the parsed value is not an object, the current handler does not run the tool.
- Treating a navigation as a failed call.
executeToolmay return null when the page navigates. Look at the page first, then aterrorText. - Asking the agent to press Confirm Reservation on Kitesurf. There is no live view, and the session is not in
wrangler browser list. Use Lab for a confirmation, or run the tool by hand from the WebMCP panel in the Kitesurf playground. - Merging the two flag spellings. Cloudflare’s docs and Chrome’s docs do not spell the category flag the same way. Copy the page you have open. Do not commit the token. The sample is
sk_demo_not_real.
FAQ
Is WebMCP the browser version of the cf CLI?
No. cf searches Cloudflare API commands on the machine you run it, and stdout is indented JSON. WebMCP registers tools on the page a visitor is looking at, for an agent in that browser. One calls the account API. The other calls the current page.
Does the switch edit my origin?
The preview adds one script at the edge. Origin files stay put. If the browser has no WebMCP, the bridge finds no registration surface and returns, so the page behaves as before. When a surface exists, tools run in the visitor’s browser. Only the Site MCP pack then calls same-origin /mcp with that visitor’s session.
Why did the tool list grow after one call?
That is how the hotel demo works. After search_location sends the page to the results, filter_search_results is registered. The list belongs to the current page. It is not a permanent catalog of the whole site. List again after the page changes.
Can the agent finish complete_booking alone?
The documented demo pauses until a person selects Confirm Reservation. A Kitesurf session has no live view, so the agent cannot press that button. A Lab session can open the view with wrangler browser view and let a person confirm. That wait is human-in-the-loop. An extra JSON field does not skip it.
Why is the return sometimes a string and sometimes three keys?
The channels differ. The edge bridge returns an MCP CallToolResult. The Agents SDK experimental adapter flattens content to a string for the API it was written against. Chrome DevTools MCP currently prints status, output, and errorText. Do not assume every channel has a success envelope.
Conclusion
Cloudflare WebMCP lets an agent call tools the current page has registered, using JSON. The bridge registers them, list_webmcp_tools returns this page’s list, and execute_webmcp_tool sends the arguments as one JSON string. The model fills that JSON. The page script runs the tool.
Check first that lookup_order came from the current page’s list, that order_id came from inputSchema, and that orders.example.test appears only in the illustration. When those three match, the page data can change.
Further reading
- How the cf CLI calls the Cloudflare API with JSON Search a command, read the schema, parse stdout. Not a page tool
- Browser, coding, and task agents The click-the-page chain. This piece is only the Cloudflare page-tool difference
- How a coding agent calls MCP The on-the-wire shape of tools/call
- Why AI needs JSON Schema Why a required field cannot live only in the prompt
- JSONSort’s local tools Format, validate, diff, JSONPath
- All posts More notes on JSON and AI development
Changelog: First published