101 Stars Building a Pure-Rust Browser Engine for LLM Agents

flashbrowse just crossed 101 stars on GitHub and shipped v1.2.1.
It is a single-binary headless browser controller and accessibility-tree compressor written in pure Rust. No Node.js, no Python, no JVM, and no Playwright or Puppeteer shims. It talks raw Chrome DevTools Protocol (CDP JSON-RPC 2.0) over WebSocket and exposes both a CLI and a native MCP stdio server for Claude Code, Cursor, and Codex.
If you have wired a browser MCP into an agent, you already know the two bottlenecks: context windows fill up with DOM or AXTree noise, and wrapper runtimes add cold-start and memory overhead. Here is what the token difference looks like on real sites (measured with interestingOnly: false for Puppeteer and Playwright, which is the full accessibility tree an agent actually has to sift through):
| URL | flashbrowse | Puppeteer | Playwright | raw HTML |
|---|---|---|---|---|
example.com | 272 t | 1,358 t | 814 t | 145 t |
news.ycombinator.com | 2,143 t | 47,930 t | 19,269 t | 8,620 t |
github.com | 1,719 t | 40,137 t | 17,102 t | 131,319 t |
(Token estimate: 1 token = 4 characters.)
Quickstart (CLI and MCP)
Install the binary (macOS / Linux):
curl -fsSL https://raw.githubusercontent.com/nhrbuilds/flashbrowse/main/install.sh | sh Windows (PowerShell):
irm https://raw.githubusercontent.com/nhrbuilds/flashbrowse/main/install.ps1 | iex Or via Cargo:
cargo install --locked --git https://github.com/nhrbuilds/flashbrowse flashbrowse-cli Download managed Chrome-for-Testing once (~120 MB, or skip if Chrome is already on your PATH), then open a page or start the MCP server:
flashbrowse setup flashbrowse open example.com flashbrowse mcp For multi-step workflows from the shell, pass --session-id to keep Chromium alive between calls:
flashbrowse open example.com --session-id s1 flashbrowse act a3 --session-id s1 --action click flashbrowse close --session-id s1 If you need pre-flight diagnostics in CI or before debugging an agent failure, run flashbrowse doctor (exits 1 on any blocking check):
flashbrowse doctor (v1.0.2) [PASS] chromium /usr/bin/google-chrome-stable (Google Chrome 147.0.7727.116) [PASS] managed-chrome installed at /home/user/.cache/flashbrowse/chrome [PASS] cache-dir /home/user/.cache/flashbrowse (writable=true) [PASS] temp-space 6327 MB free in /tmp [PASS] memory 15526 MB available [PASS] sessions 0 stored (flashbrowse close --session-id <id> to stop) [PASS] orphan-browsers 0 flashbrowse-managed browser(s) still running How It Works Under the Hood
The workspace is split into focused crates:
crates/flashbrowse-cdp CDP client, launcher, transport, protocol types crates/flashbrowse-bidi Firefox BiDi groundwork (discovery only) crates/flashbrowse-core session, stealth, interceptor, tree compression, actions crates/flashbrowse-mcp MCP JSON-RPC stdio server crates/flashbrowse-cli CLI binary (`flashbrowse`) Three design choices drive most of the behavior:
1. Wait for the final tree, not an arbitrary sleep
Playwright and Puppeteer snapshots often fire after domcontentloaded + a short delay. On Hacker News, a domcontentloaded snapshot can yield 65 tokens instead of 1,770.
flashbrowse polls Runtime.evaluate every 100 ms and exits only when:
- The DOM has been quiet (250 ms for static/large trees, 600 ms after observed changes, 1,200 ms for small pages that may still hydrate).
-
readyState == "complete"(or the network is idle). - The AX tree is non-empty when the DOM has content (Chromium populates the AX tree ~400 ms after the DOM settles).
- Two consecutive AX content fingerprints match.
Repeated opens produce byte-identical trees, which is enforced by a truncation guard test in CI.
2. Document-order AXTree compression
Chromium returns the accessibility tree breadth-first. flashbrowse-core rebuilds the hierarchy and walks it depth-first in document order, folding layout wrappers and deduplicating repeated nodes while keeping every piece of visible text and every interactive element mapped to an ephemeral action ID (ActionMap).
3. One MCP for text and pixels
In agent-default mode, images, fonts, and trackers are blocked at the network layer. When an agent calls browser_screenshot on the same MCP session, flashbrowse temporarily lifts the blocklist and re-requests blocked images (because Chrome never retries a blocked request on its own) until images report img.complete, then captures the screenshot without changing the compressed action tree.
What Broke Along the Way
Building a browser controller for agents surfaces bugs that do not show up in happy-path demos. A few real ones we hit:
Blocking CSS leaked hidden content
Blocking images saves 17-42% of page bytes and fonts save 2-12%. Blocking CSS only saves 1-3% (18% on Hacker News), so early on it looked like an easy win.
It was not. Chromium excludes display:none and visibility:hidden elements from the accessibility tree because of CSS. On a local test page with CSS blocked, a display:none element containing SECRET HIDDEN CONTENT appeared directly in the AX tree. An agent could read text no user can see and try to click invisible elements.
So interceptor.rs blocks trackers, fonts, and images (keeping alt text, which Chromium 147 still exposes as the accessible name), and never blocks CSS.
Our token count went up from 813 to 1,215
On our 30-row benchmark table, an earlier version of flashbrowse reported 813 tokens. When we built a fidelity oracle comparing raw Accessibility.getFullAXTree JSON against our compressed output, we discovered the compressor was dropping table cells.
Fixing that bug raised the payload to 1,215 tokens. We kept the fix and updated the README numbers. A smaller token count earned by silently dropping visible data is a bug, not an optimization. Across all 8 fidelity fixture pages, the compressor now hits 100% visible text recall (0 missing strings) with 90.6%-98.7% byte reduction vs raw AXTree JSON.
OS process lifecycles and iframes (v1.2.0 and v1.2.1)
Getting persistent --session-id sessions right across OSes took two targeted fixes:
- Linux (
v1.2.0):flashbrowsesetsPR_SET_PDEATHSIGon child browser processes so ephemeral runs never leak Chromium. That also killed persistent--session-idbrowsers as soon as the spawning CLI exited. SkippingPR_SET_PDEATHSIGfor persistent sessions fixed it. - Windows (
v1.2.1): Persistent Chrome launches were inheriting the CLI's stdout/stderr pipe handles, causing callers likeCommand::output()to hang until Chromium exited. Detaching stdio and terminating the process tree cleanly oncloseresolved it. - Iframes (
v1.2.0): Child<iframe>accessibility trees are now spliced into the root AX tree in document order viaPage.getFrameTree, with out-of-process iframe (OOPIF) layout offset translation so clicks inside iframes hit the right viewport coordinates.
Benchmarks and 90-Minute Soak Data
Every benchmark in the repo runs sequentially (one tool at a time, one page open at a time) against the same Chrome 147 binary on a 30-row table with 60 links (30 iterations, 0 failures, 0 leaked processes):
| Tool | min | median | p95 | max | agent payload |
|---|---|---|---|---|---|
| flashbrowse | 490 ms | 524 ms | 568 ms | 1,579 ms | 1,215 tokens |
| Puppeteer | 538 ms | 564 ms | 666 ms | 731 ms | 21,817 tokens |
| Playwright | 541 ms | 579 ms | 786 ms | 843 ms | 8,589 tokens |
(The single 1,579 ms max on flashbrowse is the initial session open that spawns Chromium.)
For long-running stability, scripts/soak.mjs drives sequential MCP loops (open -> act -> scroll -> markdown -> screenshot) across local and public URLs. In a 90-minute mixed soak (5,401 s, 7 URLs):
- Throughput: 3,366 iterations, 13,152 tool calls (
2.435/s), 0 errors (0.00%) - Latency and drift:
p50 = 255 ms,p95 = 1,288 ms,drift_ratio = 0.985(first-tenth259 ms-> last-tenth255 ms) - Memory and cleanup:
leak_gate.ok = true(post-warmup119,804 kB->116,340 kB), 0 leaked Chrome processes at exit
You can also measure your own workloads locally with flashbrowse bench <url> and inspect historical latency/token stats via flashbrowse stats (backed by ~/.cache/flashbrowse/metrics.jsonl).
Honest Limits (Where Rivals Still Win)
flashbrowse is an agent layer on top of Chrome, not a full replacement for Playwright or Puppeteer:
- Flat text tree: Nesting and bounding-box geometry are dropped. A vision model can call
browser_screenshot, but it still acts through text-tree action IDs (no set-of-marks overlay yet). - Spatial and visual tasks: Canvas apps, charts, drag distances, and map clicks are out of scope for the text tree.
- Cross-browser and test tooling: Playwright and Puppeteer win on Firefox/WebKit support, trace viewers, and visual regression suites.
- Stealth limits: Built-in stealth handles naive bot checks, not determined fingerprinting (Canvas/Audio/TLS entropy remain).
Try It and Tell Us What Breaks
If you are building coding or web agents and want to cut your browser token bill without maintaining a Node/Python sidecar:
- Check out the repo: github.com/nhrbuilds/flashbrowse (Apache-2.0)
- Run
flashbrowse doctorandflashbrowse bench <your-target-url> - Open an issue if a real-world site drops text, misroutes an iframe click, or trips up the settle loop
What is the biggest pain point you hit with browser MCPs today: token bloat, stale element IDs, or process cleanup? Drop a comment below.