How Accessibility Tree Formatting Affects Token Cost in…
    Neura MarketNeura Market/DeepSeek
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityTrending
    DeepSeekBlogHow Accessibility Tree Formatting Affects Token Cost in Browser MCPs
    Back to Blog
    How Accessibility Tree Formatting Affects Token Cost in Browser MCPs
    mcp

    How Accessibility Tree Formatting Affects Token Cost in Browser MCPs

    kuroko February 26, 2026
    0 views

    Token cost in browser automation MCPs has become a real topic — articles like "Playwright MCP Burns...

    Token cost in browser automation MCPs has become a real topic — articles like "Playwright MCP Burns 114K Tokens Per Test" have been making the rounds. Tools are approaching this from different angles: Playwright MCP's --output-mode file option saves snapshots to disk instead of returning them in LLM context, Vercel's agent-browser compresses DOM state to a fraction of the original, and some tools add vision-based fallbacks for layout understanding.

    I've been working on WebClaw, an open-source Chrome extension-based browser MCP. It takes the accessibility tree approach like Playwright MCP, but with a more compact format. I wanted to measure the actual difference — not guess, but measure — so I set up a side-by-side test.

    How I Measured

    Versions tested:

    • Playwright MCP: @playwright/mcp v0.0.68 (npx @playwright/mcp@0.0.68 --headless)
    • WebClaw: webclaw-mcp v0.9.0 + Chrome extension v0.9.0
    • Measured: February 26, 2026

    I registered both Playwright MCP and WebClaw as MCP servers in the same Claude Code session, then ran the same steps on each:

    1. Navigate to the target URL
    2. Call the snapshot tool (browser_snapshot / page_snapshot)
    3. Measure the full response text length in characters
    4. Estimate tokens as characters / 4 (approximation — actual tokenization varies by model)

    Both tools return the complete accessibility tree with no truncation. WebClaw's default is unlimited output (no token budget), so this is a pure format efficiency comparison.

    I picked three pages with different content patterns:

    • Wikipedia — long article with many reference links and navigation templates
    • GitHub — repository page with file listing, README, and sidebar
    • Hacker News — list-style page with 30 items

    Important caveat on fairness: Playwright MCP runs a headless Chromium (not logged in). WebClaw runs in the user's Chrome (logged in to GitHub in my case). This means WebClaw sees more UI on GitHub — authenticated menus, notifications, repo actions — which actually increases its output. The comparison is biased against WebClaw on that page.

    Results: Format Efficiency

    Both tools returning full, untruncated accessibility trees:

    SitePlaywright MCPWebClawDifference
    Wikipedia (MCP article)16,044 tokens (64,176 chars)7,860 tokens (31,439 chars)51% smaller
    GitHub (anthropics/claude-cookbooks)19,409 tokens (77,637 chars)4,304 tokens (17,215 chars)78% smaller
    Hacker News (front page)14,547 tokens (58,189 chars)3,052 tokens (12,207 chars)79% smaller

    The range is 51% to 79% depending on the page. Let me dig into why.

    What Creates the Difference

    Comparing the actual output for the same Wikipedia page:

    Playwright MCP (browser_snapshot):

    - generic [active] [ref=e1]:
      - link "Jump to content" [ref=e2] [cursor=pointer]:
        - /url: "#bodyContent"
      - banner [ref=e4]:
        - navigation "Site" [ref=e6]:
          - generic "Main menu" [ref=e7]:
            - button "Main menu" [ref=e8] [cursor=pointer]
    

    WebClaw (page_snapshot):

    [page "Model Context Protocol - Wikipedia"]
     [banner]
      [nav "Site"]
      [@e2 link]
     [search]
      [@e3 searchbox "Search Wikipedia"]
      [@e4 button "Search"]
    

    The difference comes down to design choices — each reasonable on its own, but they compound:

    Design choicePlaywright MCPWebClaw
    Which elements get refsAll elements (generic, rowgroup, cell...)Only interactive elements (buttons, links, inputs)
    Attribute output[active], [cursor=pointer], /url: on all applicableMinimal — only what's needed for action
    Table representationFull nested structure per cellCompressed single-line rows
    Ref count (GitHub)789 refs245 refs

    Playwright MCP's approach — labeling every element with a ref — gives maximum flexibility for targeting any element. WebClaw trades that completeness for compactness by only labeling things the AI can actually interact with.

    Why the range is so wide (51% to 79%)

    The format savings vary by page structure:

    • GitHub (78%): The file listing table is where the biggest difference shows. Playwright MCP assigns refs to every row, cell, generic wrapper (789 total). WebClaw only labels links and buttons (245 total). Additionally, WebClaw follows the W3C Accessible Name specification, using textContent before the title attribute for buttons and links. On GitHub, many buttons have short display text ("X") but verbose title attributes ("Close dialog") — using the spec-compliant order avoids the bloat.
    • Hacker News (79%): Simple, repetitive table structure. WebClaw's table compression ([row] 1. | link | link) eliminates most of the verbosity. Playwright MCP outputs nested rowgroup > row > cell > generic > link for each of the 30 items.
    • Wikipedia (51%): The article body has many inline links that both tools represent similarly. The savings come primarily from the navigation templates (Generative AI, Artificial Intelligence navboxes) where structural compression helps, but the text content itself is irreducible.

    Controlling Output Size

    WebClaw defaults to unlimited output — no truncation. But when you need to manage token costs, two options are available:

    Interactive elements only — interactiveOnly

    { "interactiveOnly": true }
    

    Strips all text content. A 2,000-line page becomes ~200 lines of buttons, links, and inputs.

    Landmark region focus — focusRegion

    { "focusRegion": "main" }
    

    Only returns the main, nav, header, or footer section. Useful when you know where the content you need is.

    Playwright MCP doesn't have equivalents — it always returns the full tree.

    The Broader Landscape

    This comparison only covers in-context accessibility trees. The ecosystem is moving fast, and there are other approaches worth knowing about:

    • Playwright MCP file output (--output-mode file): Saves snapshots to disk files instead of returning them in LLM context. Clients that support file references can read these without consuming context tokens. A fundamentally different approach to the same problem.
    • DOM compression tools (Vercel's agent-browser, browser-use, etc.): These extract and compress DOM/accessibility tree state, filtering down thousands of nodes to the most relevant elements. Some also support optional vision models for layout understanding as a secondary input.

    WebClaw's approach is narrower: same accessibility tree method as Playwright MCP's browser_snapshot, but with a more compact format. The numbers above show what format choices alone can do — but they don't capture the full picture of what's possible with file-based or DOM compression approaches.

    Why Format Efficiency Still Matters

    Even with file-based alternatives emerging, in-context snapshots remain the default for most MCP setups. A browser automation task rarely reads a page just once — navigate, read, click, read again, fill a form, check the result — that's easily 5-10 snapshot calls. A 51-79% format reduction compounds across those calls.

    Tradeoffs

    I'm biased — I built WebClaw — so let me be upfront about the tradeoffs.

    Where Playwright MCP is the better choice:

    • CI/headless environments (WebClaw needs a visible Chrome window)
    • Cross-browser testing (Chromium, Firefox, WebKit)
    • Zero-install setup (npx one-liner vs. Chrome extension)
    • Complete output — every element gets a ref, nothing is omitted
    • --output-mode file for file-based snapshots

    Where WebClaw fits better:

    • Token-sensitive workflows where format compactness matters
    • Logged-in sessions (runs in your existing Chrome — no re-authentication)
    • Bot-resistant sites (Chrome extension, no WebDriver flags)
    • When you need output size controls (interactiveOnly, focusRegion)

    WebClaw limitations:

    • Requires Chrome + extension install
    • No headless mode
    • No test code generation
    • Uses your real session (the AI operates with your credentials)

    Setup

    Claude Code:

    claude mcp add webclaw -- npx -y webclaw-mcp
    

    Claude Desktop — add to claude_desktop_config.json:

    {
      "mcpServers": {
        "webclaw": {
          "command": "npx",
          "args": ["-y", "webclaw-mcp"]
        }
      }
    }
    

    Then install the Chrome extension: extract the zip, go to chrome://extensions/, enable Developer mode, and load the dist/ folder.

    Wrapping Up

    The takeaway isn't "use WebClaw instead of Playwright MCP" — it's that accessibility tree format choices matter more than you'd expect. Assigning refs to every element vs. only interactive ones, including [cursor=pointer] hints vs. omitting them, following the W3C accessible name spec vs. using title attributes — these small decisions compound into a 51-79% difference on real pages.

    The browser MCP space is evolving quickly. File-based snapshots, DOM compression tools, and hybrid approaches are all worth watching. If you're hitting token limits with your current setup, the data here might help you understand why — and what to try next.

    If you want to reproduce these measurements or try WebClaw, the repo is open. Issues and feedback welcome — this is a solo project and I'm still figuring out the right tradeoffs.

    GitHub: github.com/kuroko1t/webclaw npm: npx -y webclaw-mcp


    WebClaw is MIT-licensed open source.

    Tags

    mcpaiwebdevplaywright

    Comments

    More Blog

    View all
    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught megemma

    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught me

    I ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...

    X
    xbill
    Hey DEV, I'm Tobore. Let's actually connect.community

    Hey DEV, I'm Tobore. Let's actually connect.

    Hey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...

    L
    Laurina Ayarah
    I burned through thousands of AI tokens. Then a friend did it for freeai

    I burned through thousands of AI tokens. Then a friend did it for free

    (yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...

    P
    Paulo Henrique
    Claude might be saturating your machineai

    Claude might be saturating your machine

    My laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...

    S
    Sidhant Panda
    Automated GitHub Code Reviews Using Google Geminigithubactions

    Automated GitHub Code Reviews Using Google Gemini

    I Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...

    D
    Darren "Dazbo" Lester
    What is an "agentic harness," actually?ai

    What is an "agentic harness," actually?

    I've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...

    T
    Tilde A. Thurium

    Stay up to date

    Get the latest DeepSeek prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for DeepSeek and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this DeepSeek resource

    • Auto-translate Blog Articles with Google Translate and Airtable Storagen8n · $9.99 · Related topic
    • Sync Zendesk Knowledge Base Articles to Airtable with Markdown Conversionn8n · $14.99 · Related topic
    • Convert YouTube Videos to SEO Articles with Supadata, Claude Sonnet 4, and WordPressn8n · $14.99 · Related topic
    • Generate SEO-Friendly Arabic Articles and Save to Notionn8n · $14.99 · Related topic
    Browse all workflows