<?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>Forem: Pedro E. Ríos</title>
    <description>The latest articles on Forem by Pedro E. Ríos (@tacosyhorchata).</description>
    <link>https://forem.com/tacosyhorchata</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3842810%2F47862ea7-4b3c-40a6-ae4f-15280c37b29b.jpeg</url>
      <title>Forem: Pedro E. Ríos</title>
      <link>https://forem.com/tacosyhorchata</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tacosyhorchata"/>
    <language>en</language>
    <item>
      <title>CSS Selectors Were Breaking My AI Agent. So I Eliminated Them.</title>
      <dc:creator>Pedro E. Ríos</dc:creator>
      <pubDate>Wed, 25 Mar 2026 08:48:58 +0000</pubDate>
      <link>https://forem.com/tacosyhorchata/css-selectors-were-breaking-my-ai-agent-so-i-eliminated-them-5bei</link>
      <guid>https://forem.com/tacosyhorchata/css-selectors-were-breaking-my-ai-agent-so-i-eliminated-them-5bei</guid>
      <description>&lt;p&gt;I was building an AI agent that needed to browse real websites — fill out forms, click buttons, navigate multi-step flows. Pretty standard stuff for an AI agent in 2025.&lt;/p&gt;

&lt;p&gt;Every tool I tried eventually broke.&lt;/p&gt;

&lt;p&gt;The Playwright MCP server worked fine at first. Then a site redesigned its nav and all the CSS selectors went stale. The agent started failing on &lt;code&gt;button.submit-btn-v2&lt;/code&gt; when the class had changed to &lt;code&gt;button.cta-primary&lt;/code&gt;. I'd fix it, it'd break again next week. I was playing whack-a-mole with selectors.&lt;/p&gt;

&lt;p&gt;The deeper problem: &lt;strong&gt;CSS selectors are a human abstraction that AI agents were never meant to use.&lt;/strong&gt; They assume you know the structure of the DOM ahead of time. An AI agent doesn't. It's exploring.&lt;/p&gt;

&lt;h2&gt;
  
  
  The insight that changed everything
&lt;/h2&gt;

&lt;p&gt;Browsers already have a built-in representation of a page that doesn't depend on CSS classes — the &lt;strong&gt;accessibility tree&lt;/strong&gt;. It's the structure screen readers use. It describes what's on the page in terms of roles, labels, and relationships, not implementation details.&lt;/p&gt;

&lt;p&gt;Instead of &lt;code&gt;button.submit-btn-v2&lt;/code&gt;, you get &lt;code&gt;[button] "Submit"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That button will still be &lt;code&gt;[button] "Submit"&lt;/code&gt; after a redesign. The label might change, but the semantic meaning stays stable far longer than CSS class names.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Interact MCP works
&lt;/h2&gt;

&lt;p&gt;I built &lt;a href="https://github.com/TacosyHorchata/interact-mcp" rel="noopener noreferrer"&gt;Interact MCP&lt;/a&gt; around this idea. Every interaction is two steps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Snapshot the page&lt;/strong&gt;&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="nf"&gt;interact_snapshot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Returns something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@e1 [heading] "Sign in to GitHub"
@e2 [textbox] "Username or email address"
@e3 [textbox] "Password"  
@e4 [button] "Sign in"
@e5 [link] "Forgot password?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Act on refs&lt;/strong&gt;&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="nf"&gt;interact_fill&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@e2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;myuser@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;interact_fill&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@e3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mypassword&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;interact_click&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@e4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. No CSS selectors. No XPath. No fragile locators. The agent sees a clean map of the page and acts on stable refs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The performance problem I also solved
&lt;/h2&gt;

&lt;p&gt;The other issue with existing tools: cold starts. Every time a browser automation MCP server handles a request, many implementations spin up a fresh Chromium instance. That's 1-3 seconds per action before you even do anything.&lt;/p&gt;

&lt;p&gt;Interact MCP keeps a &lt;strong&gt;persistent Chromium instance&lt;/strong&gt; alive between calls. The browser is always ready. Result: &lt;strong&gt;5-50ms per action&lt;/strong&gt; instead of 500ms-2000ms.&lt;/p&gt;

&lt;p&gt;For an agent running a 20-step task, that's the difference between 10 seconds and 40 seconds — or 1 second and 1 second. It compounds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other things I added
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Snapshot diffing&lt;/strong&gt; — &lt;code&gt;interact_snapshot_diff&lt;/code&gt; shows exactly what changed after an action. The agent doesn't need to re-parse the entire page to understand what happened.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cookie migration&lt;/strong&gt; — Import cookies from your real Chrome, Arc, or Brave browser. Your agent can pick up authenticated sessions without you setting up auth flows manually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handoff mode&lt;/strong&gt; — Some sites block headless browsers. When that happens, &lt;code&gt;interact_handoff&lt;/code&gt; opens a visible Chrome window so you can solve the CAPTCHA or complete the OAuth flow, then &lt;code&gt;interact_resume&lt;/code&gt; hands control back to the agent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI-friendly errors&lt;/strong&gt; — Error messages are written for LLMs, not humans. Instead of &lt;code&gt;ElementNotFound: no element matches .submit-btn&lt;/code&gt;, you get &lt;code&gt;Element @e4 not found. The page may have changed. Call interact_snapshot() to get fresh refs.&lt;/code&gt; The agent can self-correct without human intervention.&lt;/p&gt;

&lt;h2&gt;
  
  
  Works with any MCP client
&lt;/h2&gt;

&lt;p&gt;Claude Code, Cursor, Claude Desktop — anything that speaks MCP. Built on Playwright and the MCP SDK. MIT licensed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"interact"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"interact-mcp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;GitHub: &lt;a href="https://github.com/TacosyHorchata/interact-mcp" rel="noopener noreferrer"&gt;https://github.com/TacosyHorchata/interact-mcp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're building AI agents that touch the web, I'd love to hear what you think. What tools are you using for browser automation right now? What keeps breaking?&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>showdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
