WebMCP is a proposed browser API that lets a web page register its own tools, functions with JSON schemas, for an AI agent running in the browser. In Chrome 158 you can try it behind a flag (chrome://flags/#enable-webmcp-testing), where it shows up as document.modelContext.

I've spent the last weeks exposing a construction-estimating site, Craft Quantities, through it: about 200 tool names across calculators, whole-job takeoffs, a drawing canvas and a project estimator. Here's what the result looks like and what I learned building it.

The showcase: one sentence → a whole house

▶ Watch it run live in your browser: https://craftquantities.com/developers/webmcp/#showcase

The brief: "Single-storey 3-bedroom house, 12 × 9 m, slab on grade, timber frame, drywall inside, asphalt-shingle gable roof. Give me the materials and a PDF for the client."

The run, all inside one browser tab:

  1. create_project makes a new project.
  2. add_canvas_wall draws the Construction Canvas wall by wall, add_canvas_opening adds 8 openings and add_canvas_room names 5 rooms.
  3. read_canvas_takeoff works out every trade from the drawing: slab, framing, roof, drywall and insulation.
  4. add_canvas_to_project sends the takeoff to the project as 125 lines.
  5. open_project_tab shows the schedule.
  6. download_project_file produces the PDF bill, and the end card shows its first page.

33 tool calls, about 35 seconds. Most calls take single-digit milliseconds. A counter of requests to other servers stays at 0 the whole time, because everything is computed client-side.

To be clear: the showcase is a scripted sequence of the real tools, the same calls an assistant makes. It's labelled that way on the page. The unscripted test is further down.

What a good tool looks like

Here is a trimmed version of one real tool:

document.modelContext.registerTool({ name: "add_canvas_wall", description: "Draws one wall on the canvas from one point to another, as the wall tool does. " + "One step of the canvas's history: Undo takes it back.", inputSchema: { type: "object", additionalProperties: false, required: ["from", "to"], properties: { from: { $ref: "#/$defs/point" }, to: { $ref: "#/$defs/point" }, role: { type: "string", enum: ["exterior", "interior", "partition"] }, }, // a point's x/y accept "3.6 m", "12 ft 6 in" or { value, unit } }, async execute({ from, to, role }) { /* ...the page's own wall command... */ }, }); 

Four rules made the biggest difference:

1. Return text an agent can quote, with the units inside it. Answer "47 boards, 4.15 m of flashing", not {"q": 47}. Models misread bare numbers, especially across unit systems.

2. Write tools shouldn't echo big state. Early on, every write tool on a takeoff page returned the whole bill of materials, 50–70 KB per call. That burns the agent's context in a few steps. Now a write tool returns a short confirmation plus "read_takeoff_bill has the full bill".

3. Enums must be truthful per page. A tool that offers "build-sheet" on a page that has no build sheet is the most common failure. I wrote a harness that opens every page kind (about 400 pages), generates valid arguments from each schema and runs every tool in a fresh browser context. It made 6,165 calls. On the first run, zero threw, but 166 were refused: the tool rejected input that its own schema said was valid. After making each enum come from the page itself, 25 refusals are left, and they're legitimate state refusals.

4. Echo agent actions in the UI. The playground outlines every field a tool changed and scrolls it into view. Without that, people don't trust what the agent did.

A playground that works without WebMCP

Most browsers don't expose WebMCP yet, so the playground loads the real page in a same-origin iframe. The page registers its tools into a small in-page registry instead of document.modelContext. The panel calls them over postMessage, accepts messages only from its own parent, and uses no eval. It shows each step's tool, arguments, JSON result and timing. In a browser with WebMCP enabled, the same tools register natively.

Test with a real agent, not just your scripts

Before recording anything, I gave Claude one sentence: "materials for a 4 × 3 m deck in a new project, then export it." It had native WebMCP in Chrome and nothing else: no clicking, only the page's tools.

It got there: search → deck takeoff → metric → 4 × 3 m → new project → add → export. Along the way it hit three bugs that my scripted tests never found:

  • Search returned nothing for "deck 4 x 3 m materials". Only "deck" worked, and an agent will never guess that.
  • A takeoff silently reset to its default 6 × 4 m after the agent navigated away to create the project. The agent added the wrong sizes, noticed when it re-read the bill, and fixed it. The tool should never have let that happen. Now add_takeoff_to_project takes the measurements and the target project in one call.
  • open_page returned the previous page's title, a race with the client-side router.

All three are fixed. If you're building WebMCP tools, run one real agent session before you trust your own test suite.

Try it

Scope note: it counts material quantities. It doesn't do structural design or code checks, and it has no prices.

Happy to answer questions about tool design, the iframe bridge or the test harness in the comments.