npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

browser-cognition-mcp

v1.1.0

Published

Brocogni -- Making Playwright make sense to AI agents. MCP server for semantic browser observation and self-healing selectors.

Readme


An AI agent with a browser is powerful. An AI agent that understands what it sees in the browser is unstoppable.

Brocogni is an open-source MCP server that sits between your AI agent and Playwright. Instead of dumping raw HTML into your agent's context (noisy, fragile, token-wasting), it compiles pages into a structured semantic map the agent can navigate, reason about, and act on in real time.

Two modes:

  • Agentic browsing loop -- The agent calls Brocogni tools directly: navigate, observe, click, extract, diff. Each step feeds back into reasoning. The browser is the environment, the agent is the brain.
  • Self-healing script generation -- The agent observes a page and generates vanilla Playwright code with automatic fallback selectors that survive frontend rebuilds.

No SaaS. No data leaves your machine. MIT.

▶️ Watch the 15-second demo


Before / After

Before -- fragile selectors that break on every deploy:

await page.click('.btn-primary');
await page.fill('.css-x83kf2 > input', 'hello');

Works today. Fails tomorrow when Tailwind classes rebuild.

After -- semantic selectors with self-healing fallbacks:

await page.click('role=button[name="Sign in"]');
await page.fill('role=textbox[name="Email"]', 'hello');

If the primary selector breaks, the fallback chain handles it:

role=button[name='Sign in']
  -> button:has-text('Sign in')
  -> xpath=//button[contains(text(),'Sign in')]
  -> css=div:has(> button) + button

The engine anchors unnamed elements to named siblings using relational XPath and CSS adjacent selectors. If a button has no accessible name but sits next to a labeled input, Brocogni finds it anyway.


How it works

AI Agent
   |
   | MCP protocol (stdio)
   v
Brocogni MCP Server
   |
   | Playwright + CDP
   v
 AX Tree  -->  DOM Geometry  -->  Selector Engine
                                       |
                                       v
                         Self-healing selectors
                         (ARIA / CSS / XPath / relational)

The agent calls MCP tools in a loop: navigate to a URL, observe the page as structured semantic nodes, find targets by role or name, click to trigger new states, diff before/after to catch dynamic content. Actionable nodes carry role, name, bounding box, visibility, enabled state, and ranked selectors with fallback chains. The agent never sees raw HTML.


Install

npx playwright install chromium
npx browser-cognition-mcp

Then connect your agent:

Claude Code

claude mcp add brocogni -- npx -y browser-cognition-mcp

Cursor

Settings -> Features -> MCP -> Add New
Name: brocogni  |  Type: stdio  |  Command: npx -y browser-cognition-mcp

Claude Desktop

npx browser-cognition-mcp install

OpenCode Zero setup -- reads opencode.json automatically.


MCP Tools

| Tool | What it does | |---|---| | browser_navigate | Open a URL | | browser_observe | Compile page into semantic node map | | browser_find_targets | Search by role, name, or purpose | | browser_get_selector_plan | Get primary + fallback selectors | | browser_act | Click, fill, or hover | | browser_verify | Preflight: visible, enabled, compatible | | browser_delta | Diff two page states | | browser_screenshot | Capture viewport as PNG | | browser_evaluate | Run JS in page context | | browser_save_cookies | Persist session cookies | | browser_info | Page URL, title, iframe count |

Also exposes a write-robust-playwright-script prompt that teaches agents how to use these tools effectively.


Tests

npm test

Deterministic, no browser required. Covers semantic extraction, DOM fusion, selector ranking, relational fallbacks, delta computation, and action verification.


FAQ

Does it need API keys? No. Every observation runs locally. No accounts, no telemetry, no data leaves your machine.

Which agents does it work with? Any MCP-compatible agent: Claude Code, Claude Desktop, Cursor, OpenCode, and others.

Does it add runtime bloat to my project? No. Brocogni is a dev-time MCP server. It generates vanilla Playwright code -- no runtime dependencies introduced.

What happens when a selector fails? The fallback chain activates automatically. ARIA -> text -> XPath -> relational sibling. The agent tries each one in order.


Contributing

Bug reports, feature requests, and PRs welcome. See CONTRIBUTING.md. Security issues? SECURITY.md.


License

MIT. Go build something.