<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex Tănasie</title>
    <description>The latest articles on DEV Community by Alex Tănasie (@craftquantities).</description>
    <link>https://dev.to/craftquantities</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4275040%2Fbc62f370-237e-418d-9a22-79c4a408f493.jpg</url>
      <title>DEV Community: Alex Tănasie</title>
      <link>https://dev.to/craftquantities</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/craftquantities"/>
    <language>en</language>
    <item>
      <title>What I learned building ~200 WebMCP tools (and letting a real agent break them)</title>
      <dc:creator>Alex Tănasie</dc:creator>
      <pubDate>Mon, 30 Nov 2026 20:24:01 +0000</pubDate>
      <link>https://dev.to/craftquantities/what-i-learned-building-200-webmcp-tools-and-letting-a-real-agent-break-them-cco</link>
      <guid>https://dev.to/craftquantities/what-i-learned-building-200-webmcp-tools-and-letting-a-real-agent-break-them-cco</guid>
      <description>&lt;p&gt;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 (&lt;code&gt;chrome://flags/#enable-webmcp-testing&lt;/code&gt;), where it shows up as &lt;code&gt;document.modelContext&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I've spent the last weeks exposing a construction-estimating site, &lt;a href="https://craftquantities.com" rel="noopener noreferrer"&gt;Craft Quantities&lt;/a&gt;, 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The showcase: one sentence → a whole house
&lt;/h2&gt;

&lt;p&gt;▶ &lt;strong&gt;Watch it run live in your browser:&lt;/strong&gt; &lt;a href="https://craftquantities.com/developers/webmcp/#showcase" rel="noopener noreferrer"&gt;https://craftquantities.com/developers/webmcp/#showcase&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The brief: &lt;em&gt;"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."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The run, all inside one browser tab:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;create_project&lt;/code&gt; makes a new project.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;add_canvas_wall&lt;/code&gt; draws the Construction Canvas wall by wall, &lt;code&gt;add_canvas_opening&lt;/code&gt; adds 8 openings and &lt;code&gt;add_canvas_room&lt;/code&gt; names 5 rooms.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;read_canvas_takeoff&lt;/code&gt; works out every trade from the drawing: slab, framing, roof, drywall and insulation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;add_canvas_to_project&lt;/code&gt; sends the takeoff to the project as &lt;strong&gt;125 lines&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;open_project_tab&lt;/code&gt; shows the schedule.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;download_project_file&lt;/code&gt; produces the PDF bill, and the end card shows its first page.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;To be clear: the showcase is a &lt;em&gt;scripted&lt;/em&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a good tool looks like
&lt;/h2&gt;

&lt;p&gt;Here is a trimmed version of one real tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;modelContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;registerTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"add_canvas_wall"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"Draws one wall on the canvas from one point to another, as the wall tool does. "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="s2"&gt;"One step of the canvas's history: Undo takes it back."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;inputSchema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;additionalProperties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"to"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"#/$defs/point"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"#/$defs/point"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;enum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"exterior"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"interior"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"partition"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;// a point's x/y accept "3.6 m", "12 ft 6 in" or { value, unit }&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ...the page's own wall command... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four rules made the biggest difference:&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;2. Write tools shouldn't echo big state.&lt;/strong&gt; 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".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Enums must be truthful per page.&lt;/strong&gt; A tool that offers &lt;code&gt;"build-sheet"&lt;/code&gt; 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 &lt;strong&gt;166 were refused&lt;/strong&gt;: 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.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  A playground that works without WebMCP
&lt;/h2&gt;

&lt;p&gt;Most browsers don't expose WebMCP yet, so the &lt;a href="https://craftquantities.com/developers/webmcp/" rel="noopener noreferrer"&gt;playground&lt;/a&gt; loads the real page in a same-origin iframe. The page registers its tools into a small in-page registry instead of &lt;code&gt;document.modelContext&lt;/code&gt;. The panel calls them over &lt;code&gt;postMessage&lt;/code&gt;, accepts messages only from its own parent, and uses no &lt;code&gt;eval&lt;/code&gt;. It shows each step's tool, arguments, JSON result and timing. In a browser with WebMCP enabled, the same tools register natively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test with a real agent, not just your scripts
&lt;/h2&gt;

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

&lt;p&gt;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:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Search returned nothing&lt;/strong&gt; for "deck 4 x 3 m materials". Only "deck" worked, and an agent will never guess that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A takeoff silently reset&lt;/strong&gt; 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 &lt;code&gt;add_takeoff_to_project&lt;/code&gt; takes the measurements and the target project in one call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;open_page&lt;/code&gt; returned the previous page's title&lt;/strong&gt;, a race with the client-side router.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Showcase and playground: &lt;a href="https://craftquantities.com/developers/webmcp/" rel="noopener noreferrer"&gt;https://craftquantities.com/developers/webmcp/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The same calculators as a remote MCP server: &lt;a href="https://craftquantities.com/developers/mcp/" rel="noopener noreferrer"&gt;https://craftquantities.com/developers/mcp/&lt;/a&gt; (&lt;code&gt;com.craftquantities/engine&lt;/code&gt; in the official MCP registry)&lt;/li&gt;
&lt;li&gt;Open data and a 3,820-item benchmark (CC BY 4.0, DOI &lt;a href="https://doi.org/10.5281/zenodo.24679327" rel="noopener noreferrer"&gt;10.5281/zenodo.24679327&lt;/a&gt;): &lt;a href="https://craftquantities.com/developers/open-data/" rel="noopener noreferrer"&gt;https://craftquantities.com/developers/open-data/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scope note: it counts material quantities. It doesn't do structural design or code checks, and it has no prices.&lt;/p&gt;

&lt;p&gt;Happy to answer questions about tool design, the iframe bridge or the test harness in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>javascript</category>
      <category>mcp</category>
    </item>
  </channel>
</rss>
