Building a browser-native AI interface is less about the API and more about surviving contact with reality. A developer behind Craft Quantities, a construction-estimating site, recently exposed roughly 200 tools via the proposed WebMCP API in Chrome 158. The goal was to let an AI agent run entirely client-side, manipulating a drawing canvas and generating PDFs without touching a server. While the showcase demonstrated a 33-tool-call sequence completing in 35 seconds, the real value lies in the three critical bugs a live agent discovered that scripted tests completely missed.
The API and the Architecture
WebMCP, currently available behind the chrome://flags/#enable-webmcp-testing flag, surfaces as document.modelContext in the browser. This allows a webpage to register functions with JSON schemas directly, creating a bridge between the DOM and an LLM. The Craft Quantities implementation uses this to drive a construction canvas, where tools like add_canvas_wall and read_canvas_takeoff execute page commands. Because the logic is client-side, network requests to external servers remain at zero, proving that complex agentic workflows can live entirely within a single tab.
Four Rules for Agent-Friendly Tools
The developer distilled the build process into four non-negotiable design principles. First, return text units explicitly; models misread bare numbers, so "4.15 m of flashing" beats {"q": 47}. Second, avoid echoing large state changes. Early versions returned 50โ70 KB bills of materials per call, burning context rapidly. The fix was returning short confirmations and pointing to a separate read_takeoff_bill tool. Third, enums must reflect actual page state. A test harness running 6,165 calls revealed 166 refusals where tools rejected valid inputs because the schema didn't match the current page context. Finally, visual feedback is mandatory. The UI must outline every field the agent changes to maintain user trust.
Where Scripted Tests Lie
The most instructive part of the post is the unscripted test using Claude. Given a simple prompt to create a deck and export it, the agent navigated the tool suite but hit three specific failures. Search failed on compound queries like "deck 4 x 3 m materials," requiring exact keyword matches. A navigation event silently reset a takeoff to default dimensions, causing the agent to add incorrect sizes before self-correcting. A race condition in the client-side router caused open_page to return the previous page's title. These are classic integration bugs that only appear when an autonomous agent, not a deterministic script, drives the interface.
Key Takeaways
- Real LLM agents expose integration bugs like race conditions and state mismatches that deterministic scripts miss.
- Tool responses should prioritize explicit units and avoid echoing large state objects to save context.
- Schemas must be truthful to the current page state, or agents will fail on valid but contextually inappropriate inputs.
- Visual feedback in the UI is essential for user trust when an agent manipulates complex interfaces.
The Bottom Line
If you are building WebMCP tools, your deterministic test suite is lying to you. You must run at least one unscripted session with a real LLM agent to catch the state resets and race conditions that only emerge when non-deterministic intelligence touches your interface.