Making Playwright make sense to AI agents.

Brocogni is an open-source MCP server that compiles web pages into structured semantic maps for AI agents. Instead of dumping raw HTML (noisy, fragile, token-wasting), it delivers pre-computed selectors with confidence scores and fallback chains. The LLM gets understanding, not data.

npx browser-cognition-mcp
The Problem

LLMs shouldn't reverse-engineer the DOM.

Every time your AI agent observes a page, someone pays for the tokens. The standard @playwright/mcp returns a raw accessibility tree with ephemeral ref IDs (e.g. e5, e10, e23).

The LLM must parse 62–93 mixed nodes, figure out what is actionable, and then guess selectors from scratch. Because these references expire dynamically, each new session starts from zero.

1
Write ref-based script
Refs expire, script broken
2
Re-observe page, guess getByRole locators
75% correct
3
Debug 1-2 failed selectors, re-observe again
Script finally works
81%

less tokens than @playwright/mcp for a complete observe → act → export workflow.

Swipe left to scroll table →
Metric @playwright/mcp Brocogni Brocogni (compact)
Observation tokens 351 1,365 1,365
Attempts to working script 3 1 1
Total tokens (all attempts) 3,211 1,535 1,535
Total cost per script $0.04 $0.01 $0.01
Selector durability Expire per snapshot Persistent (CSS/XPath) Persistent (CSS/XPath)
Works after page refresh? No Yes Yes
LLM must filter elements? Yes (62-93 nodes) No (9 nodes, pre-filtered) No (9 nodes, pre-filtered)

The hidden cost of @playwright/mcp isn't the observation. It's the iteration. Each failed attempt burns another snapshot + LLM reasoning tokens. Brocogni's richer observation eliminates ALL downstream reasoning and retries.

Signal Density

9 semantic nodes vs 62–93 AX nodes.

Brocogni strips away everything that isn't actionable. Only 7 ARIA roles survive filtering: button, link, textbox, combobox, checkbox, radio, menuitem, and tab.

Everything else is noise. The LLM never sees layout containers, empty headings, or static decorational DOM nodes.

@playwright/mcp returns
  • generic "main"
  • generic "navigation"
  • link "About"
  • generic "div"
  • button "Search"
  • heading "Results"
  • textbox "Query"
  • generic "div"
  • generic "section"
  • listitem
Brocogni returns
  • button "Search"
  • textbox "Query"
  • combobox "Category"
  • checkbox "Free shipping"
  • button "Submit"
Feature @playwright/mcp Brocogni
Pre-computed selectors
Bounding boxes
Purpose inference
Fallback chains
Confidence scores
Architecture

The Pipeline

AI Agent
Requests browser actions or page observations
Brocogni Server
JSON-RPC protocol (stdio bridge)
CDP AX Tree
DOM Geometry
Inference & Fusion
Actionable filtering, purpose mapping, bounding boxes
Selector Engine
Ranked candidates: ARIA → CSS/XPath → Relational

1. Observe

CDP accessibility tree, DOM snapshot, and CSSOM geometries are extracted in a single combined execution to minimize context switches.

2. Infer

Filters down to the 7 actionable ARIA roles, fuses visual bounding boxes, and infers purpose. No static structure or noise reaches the LLM.

3. Export

Generates ranked fallback selector chains. Each locator is scored based on uniqueness, layout stability, and accessibility hierarchy.

Reliability

Write robust scripts.

Before — fragile selectors Fails on layout edits
1await page.click('.btn-primary');
2await page.fill('.css-x83kf2 > input', 'hello');

Works today. Fails tomorrow on tailwind updates or DOM shifts.

After — self-healing selectors Survives rebuilds
1await page.click('role=button[name="Sign in"]');
2await page.fill('role=textbox[name="Email"]', 'hello');

Direct ARIA locator matches that persist across style and structural updates.

Locators Fallback Sequence
role=button[name="Sign in"]
button:has-text("Sign in")
xpath=//button[contains(., "Sign in")]
relational sibling anchor

See it in action

Watch how Brocogni orchestrates browser tasks by providing semantic node mapping.

An AI agent uses Brocogni to navigate a hotel booking page — observes the page, finds input fields and buttons by purpose, fills the form, and exports a reusable Playwright script. All in one shot.

Features

13 MCP Tools

browser_navigate Navigate
Open a target URL in the chromium instance. Handles waits and session initialization.
browser_observe Observe
Compile the current page state into a structured semantic node map with pre-computed selectors.
browser_find_targets Find
Search cached semantic nodes by role, name, or purpose using text or semantic matches.
browser_get_selector_plan Plan
Retrieve the prioritized list of primary and fallback selectors for any node.
browser_act Act
Execute clicks, text fills, selections, or hovers using targeted semantic node IDs.
browser_verify Verify
Perform preflight checks: verify if element is visible, enabled, and action-compatible.
browser_delta Delta
Diff two page states to identify newly added, removed, or modified actionable elements.
browser_screenshot Screenshot
Capture the current browser viewport as a PNG image for visual agent checks.
browser_evaluate Evaluate
Execute arbitrary JavaScript in the context of the page and return serialized outputs.
browser_save_cookies Cookies
Persist browser state by saving cookies locally to avoid repeating sign-in flows.
browser_list_pages Tabs
List all open browser pages, tabs, and contexts currently controlled by the server.
browser_use_page Switch
Switch the active context target page to a specific index in the pages array.
browser_info Info
Retrieve metadata: active URL, page title, layout width/height, and iframe count.
Get Started

One command. Zero accounts.

No API keys. No telemetry. No telemetry servers or cloud relays. Everything runs locally on your machine via Node.js and Playwright.

Simply install the chromium binary on your local machine and hook the stdio bridge into your agent.

npx playwright install chromium
claude mcp add brocogni -- npx -y browser-cognition-mcp
Settings → Features → MCP → Add New
Name: brocogni
Type: stdio
Command: npx -y browser-cognition-mcp
npx browser-cognition-mcp install

Zero setup.

Brocogni reads your project's opencode.json automatically during runtime mapping.

Requires Node 18+ and Playwright installed locally.
Scaling

What it costs at scale

50 scripts / mo
$1.78
@playwright
/
$0.33
Brocogni
Save $1.45
200 scripts / mo
$7.11
@playwright
/
$1.33
Brocogni
Save $5.78
1,000 scripts / mo
$35.53
@playwright
/
$6.64
Brocogni
Save $28.89
FAQ

Questions?

Does it need API keys?
No. Every observation and calculation runs completely locally on your hardware. There are no registration accounts, no telemetry endpoints, and no user data ever leaves your computer.
Which agents does it work with?
Brocogni works with any MCP-compatible client including Claude Code, Claude Desktop, Cursor, Cline, OpenCode, Hermes, and custom applications built on top of the Model Context Protocol SDK.
Does it add runtime bloat to my project?
No. Brocogni is a dev-time tool. It runs during test construction or action selection, exporting standard vanilla Playwright/JS scripts that have no external runtime dependency.
What happens when a selector fails?
The generated selector plan incorporates a robust fallback chain (ARIA → text → XPath → relational sibling). If the primary selector becomes invalid after a site update, the fallback chains are traversed automatically until a match succeeds.
How is this different from @playwright/mcp?
The default @playwright/mcp returns session-based ephemeral reference numbers (like "e15") that cannot be used for writing persistent test files. Brocogni generates durable, pre-computed CSS/XPath selectors and includes layout bounding box geometry coordinates.
Can I contribute?
Yes, Brocogni is fully open source. PRs, bug reports, and features suggestions are welcome. Take a look at the guidelines in the GitHub repository.