<?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: Harshavardhan Kangala Dayanand</title>
    <description>The latest articles on DEV Community by Harshavardhan Kangala Dayanand (@harshavardhan_kangaladay).</description>
    <link>https://dev.to/harshavardhan_kangaladay</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%2F4008612%2F67eade0e-6fc3-44fe-b39c-5fd57d08d3ec.jpg</url>
      <title>DEV Community: Harshavardhan Kangala Dayanand</title>
      <link>https://dev.to/harshavardhan_kangaladay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshavardhan_kangaladay"/>
    <language>en</language>
    <item>
      <title>Why Playwright MCP Cost Us 5 More Tokens Than We Expected</title>
      <dc:creator>Harshavardhan Kangala Dayanand</dc:creator>
      <pubDate>Mon, 29 Jun 2026 17:59:36 +0000</pubDate>
      <link>https://dev.to/harshavardhan_kangaladay/why-playwright-mcp-cost-us-5x-more-tokens-than-we-expected-5ckf</link>
      <guid>https://dev.to/harshavardhan_kangaladay/why-playwright-mcp-cost-us-5x-more-tokens-than-we-expected-5ckf</guid>
      <description>&lt;p&gt;We built an open-source browser automation MCP because we wanted something simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Observe a webpage once, let an LLM interact with it, then export a Playwright script that actually works.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That sounds straightforward.&lt;/p&gt;

&lt;p&gt;It wasn't.&lt;/p&gt;

&lt;p&gt;While benchmarking against Playwright MCP, we discovered something we hadn't considered: &lt;strong&gt;observation quality isn't the biggest contributor to cost. Iteration is.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The expensive part isn't making the browser agent click buttons.&lt;/p&gt;

&lt;p&gt;It's making the generated automation reusable.&lt;/p&gt;




&lt;h2&gt;
  
  
  The hidden problem with &lt;code&gt;browser_snapshot&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Playwright MCP represents elements using ephemeral references:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button "Login" [ref=e5]
textbox "Email" [ref=e10]
link "Forgot password" [ref=e23]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within an MCP session, this is excellent.&lt;/p&gt;

&lt;p&gt;The model simply responds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;browser_click("e5")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fast.&lt;/p&gt;

&lt;p&gt;Clean.&lt;/p&gt;

&lt;p&gt;Minimal reasoning.&lt;/p&gt;

&lt;p&gt;The problem appears later.&lt;/p&gt;

&lt;p&gt;Every snapshot generates a new set of references.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;e5&lt;/code&gt; today is not &lt;code&gt;e5&lt;/code&gt; tomorrow.&lt;/p&gt;

&lt;p&gt;Those identifiers only exist for the lifetime of that observation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why this matters
&lt;/h2&gt;

&lt;p&gt;Many people aren't using browser agents just to click around.&lt;/p&gt;

&lt;p&gt;They're using them to produce reusable automation.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playwright tests&lt;/li&gt;
&lt;li&gt;CI pipelines&lt;/li&gt;
&lt;li&gt;Documentation examples&lt;/li&gt;
&lt;li&gt;Internal automation scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the LLM tries to generate code like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(...);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the references become useless.&lt;/p&gt;

&lt;p&gt;They're meaningless outside the MCP session.&lt;/p&gt;

&lt;p&gt;The model now has to reconstruct selectors from scratch.&lt;/p&gt;

&lt;p&gt;That usually means:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reading another snapshot&lt;/li&gt;
&lt;li&gt;Parsing the accessibility tree&lt;/li&gt;
&lt;li&gt;Identifying the correct element&lt;/li&gt;
&lt;li&gt;Guessing a locator&lt;/li&gt;
&lt;li&gt;Debugging when it fails&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The browser interaction itself is cheap.&lt;/p&gt;

&lt;p&gt;The retries are not.&lt;/p&gt;




&lt;h1&gt;
  
  
  Measuring the Entire Workflow
&lt;/h1&gt;

&lt;p&gt;Instead of measuring a single observation, we measured the full pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Observe
    ↓
Interact
    ↓
Generate Playwright Script
    ↓
Execute Script
    ↓
Fix Failures if Needed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The numbers were surprising.&lt;/p&gt;

&lt;h2&gt;
  
  
  Playwright MCP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Attempt 1
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Observes page&lt;/li&gt;
&lt;li&gt;Writes ref-based automation&lt;/li&gt;
&lt;li&gt;Exported script cannot be reused&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;≈ 1,099 tokens&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Attempt 2
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Observes page again&lt;/li&gt;
&lt;li&gt;Parses 62–93 accessibility nodes&lt;/li&gt;
&lt;li&gt;Generates &lt;code&gt;getByRole()&lt;/code&gt; selectors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;≈ 1,171 tokens&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Attempt 3
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fixes failed selectors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;≈ 941 tokens&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Total
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3,211 tokens
≈ $0.04 per generated script
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Brocogni
&lt;/h2&gt;

&lt;p&gt;Instead of returning references, Brocogni computes selectors before the LLM ever sees the page.&lt;/p&gt;

&lt;p&gt;The observation already contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ranked selectors&lt;/li&gt;
&lt;li&gt;Fallback selectors&lt;/li&gt;
&lt;li&gt;Semantic purpose&lt;/li&gt;
&lt;li&gt;Bounding boxes&lt;/li&gt;
&lt;li&gt;Only actionable elements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model simply copies them into the Playwright script.&lt;/p&gt;

&lt;p&gt;One observation.&lt;/p&gt;

&lt;p&gt;One generation.&lt;/p&gt;

&lt;p&gt;Done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1,535 tokens
≈ $0.01 per generated script
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Across roughly &lt;strong&gt;200 generated scripts/month&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Solution&lt;/th&gt;
&lt;th&gt;Monthly Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Playwright MCP&lt;/td&gt;
&lt;td&gt;~$7.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Brocogni&lt;/td&gt;
&lt;td&gt;~$1.33&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That's roughly an &lt;strong&gt;81% reduction&lt;/strong&gt; in token cost in our benchmark.&lt;/p&gt;

&lt;p&gt;More importantly, it's fewer failed iterations.&lt;/p&gt;




&lt;h1&gt;
  
  
  Signal Density Matters
&lt;/h1&gt;

&lt;p&gt;Another observation was how much unnecessary information reaches the LLM.&lt;/p&gt;

&lt;p&gt;A typical Playwright MCP snapshot contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;62–93 accessibility nodes&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only around &lt;strong&gt;9&lt;/strong&gt; are actually interactive.&lt;/p&gt;

&lt;p&gt;The model must determine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which nodes matter&lt;/li&gt;
&lt;li&gt;Which are actionable&lt;/li&gt;
&lt;li&gt;Which selector should be generated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That reasoning consumes tokens.&lt;/p&gt;

&lt;p&gt;Brocogni instead returns only actionable elements.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Playwright MCP&lt;/th&gt;
&lt;th&gt;Brocogni&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Elements returned&lt;/td&gt;
&lt;td&gt;62–93&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Actionable&lt;/td&gt;
&lt;td&gt;Mixed&lt;/td&gt;
&lt;td&gt;9/9 (100%)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LLM filters nodes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pre-computed selectors&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fallback selector chains&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The observation is slightly richer.&lt;/p&gt;

&lt;p&gt;The downstream reasoning becomes dramatically simpler.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Architectural Difference
&lt;/h1&gt;

&lt;p&gt;The distinction comes from where the work happens.&lt;/p&gt;

&lt;p&gt;Playwright MCP exposes browser state.&lt;/p&gt;

&lt;p&gt;The LLM performs much of the interpretation.&lt;/p&gt;

&lt;p&gt;Brocogni shifts that interpretation server-side.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chrome DevTools Protocol
          │
          ▼
Accessibility Tree
          │
          ▼
DOM Snapshot
          │
          ▼
Geometry Extraction
          │
          ▼
Actionability Filtering
          │
          ▼
Purpose Inference
          │
          ▼
Ranked Selector Generation
          │
          ▼
Structured JSON Observation
          │
          ▼
LLM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By the time the model receives the observation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selectors already exist&lt;/li&gt;
&lt;li&gt;Fallback chains already exist&lt;/li&gt;
&lt;li&gt;Only actionable elements remain&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The LLM doesn't need to reverse-engineer the DOM.&lt;/p&gt;




&lt;h1&gt;
  
  
  This Isn't a Criticism of Playwright MCP
&lt;/h1&gt;

&lt;p&gt;Playwright MCP is extremely well designed for interactive browser agents.&lt;/p&gt;

&lt;p&gt;If your goal is simply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Navigate a website."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;it's an excellent choice.&lt;/p&gt;

&lt;p&gt;Our benchmark looked at a different workflow:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Generate Playwright code that someone will commit to a repository."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Those are different optimization problems.&lt;/p&gt;

&lt;p&gt;For the second case, reusable selectors matter more than ephemeral references.&lt;/p&gt;




&lt;h1&gt;
  
  
  Brocogni
&lt;/h1&gt;

&lt;p&gt;Brocogni is an open-source MCP server focused on browser automation for LLMs.&lt;/p&gt;

&lt;p&gt;Instead of exposing raw browser state, it provides structured observations that are immediately usable for automation generation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Ranked CSS, ARIA, XPath and text selectors&lt;/li&gt;
&lt;li&gt;Fallback selector chains&lt;/li&gt;
&lt;li&gt;Actionable element filtering&lt;/li&gt;
&lt;li&gt;Semantic purpose inference&lt;/li&gt;
&lt;li&gt;Bounding box information&lt;/li&gt;
&lt;li&gt;MIT licensed&lt;/li&gt;
&lt;li&gt;Zero telemetry&lt;/li&gt;
&lt;li&gt;Fully local execution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/hrshx3o5o6/brocogni" rel="noopener noreferrer"&gt;https://github.com/hrshx3o5o6/brocogni&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://brocogni.vercel.app/" rel="noopener noreferrer"&gt;https://brocogni.vercel.app/&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;I'd love feedback from people building browser agents or using Playwright MCP in production.&lt;/p&gt;

&lt;p&gt;If you've measured similar token costs—or found different tradeoffs—I'd be interested to compare approaches.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>opensource</category>
      <category>playwright</category>
    </item>
  </channel>
</rss>
