Documentation · v1.6.1
flashbrowse Reference
CLI commands, compressed action tree internals, adaptive settle engine, all 18 MCP tools, and the Node.js / TypeScript wrapper (@nhrbuilds/flashbrowse).
Introduction#
flashbrowse is a single-binary headless browser controller and accessibility-tree compression engine written in Rust and purpose-built for LLM agents.
Unlike general-purpose browser automation suites, flashbrowse speaks browser protocols directly (CDP over POSIX pipes or WebSockets today, with Firefox BiDi integration underway), blocks images/fonts/trackers during agent navigation, waits for deterministic DOM + AXTree stability, and compresses the accessibility tree into numbered [N] action targets.
- Zero Python, Node.js, or JVM runtime required for the native binary.
- Built-in MCP stdio server exposing 18 browser tools for Claude Code, Cursor, Codex, and custom harnesses.
- Official Node.js / TypeScript wrapper (@nhrbuilds/flashbrowse) for programmatic automation and MCP client reuse.
flashbrowse-bidi crate.Installation#
Install the prebuilt native binary, install via npm for Node.js/TypeScript projects, or compile directly with Cargo.
curl -fsSL https://raw.githubusercontent.com/nhrbuilds/flashbrowse/main/install.sh | sh
flashbrowse setup
flashbrowse doctorirm https://raw.githubusercontent.com/nhrbuilds/flashbrowse/main/install.ps1 | iex
flashbrowse setup
flashbrowse doctor# Node.js 22+ or Bun
npm install @nhrbuilds/flashbrowse
npx flashbrowse setup
# Or build from Git with Rust
cargo install --locked --git https://github.com/nhrbuilds/flashbrowse flashbrowse-cliflashbrowse setup is optional. Discovery checks --chrome-path, CHROME_PATH, and CHROME_BINARY before falling back to system Chrome or the managed build.Platform & Runtime Libraries#
Prebuilt native binaries target Linux x86_64/aarch64 (glibc 2.39+), macOS x86_64/arm64, and Windows x86_64. Linux binaries are dynamically linked to glibc (musl is not supported by prebuilt executables).
On minimal Linux containers, both flashbrowse and Chrome require shared libraries (flashbrowse setup downloads Chrome for Testing without installing OS packages).
sudo apt-get update
sudo apt-get install -y libglib2.0-0t64 libnss3 libnspr4 libatk1.0-0t64 \
libatk-bridge2.0-0t64 libatspi2.0-0t64 libdbus-1-3 libexpat1 libgbm1 libx11-6 \
libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 \
libxrandr2 libasound2t64 libudev1 libdrm2 libxrender1 libxau6 libxdmcp6 libxi6 \
libpcre2-8-0 libffi8 libgcc-s1 zlib1g libmount1 libsystemd0 libblkid1 \
fontconfig fonts-liberationsudo pacman -Syu --needed --noconfirm glibc libgcc alsa-lib at-spi2-core dbus glib2 libdrm \
expat libffi mesa nspr nss pcre2 systemd-libs util-linux-libs libx11 libxau \
libxcb libxcomposite libxdamage libxdmcp libxext libxfixes libxi libxkbcommon \
libxrandr libxrender zlib fontconfig ttf-liberation| Platform | Minimum Requirement | Extra System Package |
|---|---|---|
| Linux x64 / arm64 | glibc 2.39+ (Ubuntu 24.04+, Debian 13+, Arch) | Chrome shared libs + fontconfig |
| macOS x64 / arm64 | Standard macOS system libraries | None |
| Windows x64 | Microsoft Visual C++ Redistributable (2015+ x64) | winget install --id Microsoft.VCRedist.2015+.x64 --exact |
Quick Start#
Open a page in a persistent session, inspect its numbered action tree, execute an interaction by action ID, and close the session cleanly.
# 1. Start a persistent session and inspect the compressed action tree
flashbrowse open https://example.com --session-id research
# 2. Click or fill an element by its [N] action ID from the tree
flashbrowse act 1 --session-id research --action click
# 3. Extract clean Markdown from the settled page
flashbrowse dump https://example.com --format markdown
# 4. Close the persistent browser process
flashbrowse close --session-id researchCompressed Action Trees#
Chromium returns accessibility nodes in breadth-first order and wraps plain text in InlineTextBox scaffolding. flashbrowse rebuilds the tree, walks it depth-first in true document order, folds table rows and gridcells into compact lines, and assigns sequential [N] action IDs only to visible interactive elements.
Compression preserves two strict invariants: every piece of visible text survives at least once, and output order matches document order. Two formats are supported: axtree-nested (indented hierarchy, session default) and axtree (flat list).
- Checked, selected, expanded, and slider
value=...states are preserved inline. - Child
<iframe>AXTrees are spliced inline with out-of-process iframe (OOPIF) coordinate translation. - Open
shadowRootsubtrees and React__reactProps$.onClick/cursor:pointerelements are included in document order. - Names longer than 120 characters and extras longer than 80 characters are elided with an ellipsis.
Adaptive Settle Loop#
Naive domcontentloaded + 500ms snapshots frequently return empty shells on modern SPAs (e.g., 65 tokens instead of 1,770 on Hacker News). flashbrowse runs a 5-stage verification loop up to 15 seconds before returning the tree:
- 1. Polls every 100 ms via a single
Runtime.evaluate(readyState, DOM size,innerTextlength). - 2. Enforces adaptive quiet windows: 250 ms for static/large trees, 600 ms after mutations, 1,200 ms for small pages that may hydrate.
- 3. Requires
readyState == "complete"or network idle. - 4. Verifies the AXTree is non-empty when the DOM has visible content (Chromium populates AX nodes ~400 ms after DOM completion).
- 5. Confirms two consecutive AXTree content fingerprints match before assigning action IDs.
browser_open returns an error and invalidates stale action IDs rather than returning a partial tree.Resource Policies#
Measured real-page network shares show images consume 17–42% of bytes and fonts 2–12%, while CSS is only 1–3% yet controls display:none / visibility:hidden visibility in Chromium’s AXTree. Blocking CSS exposes hidden elements to agents; blocking images keeps alt text intact.
Precedence order: --resource-policy > --full-render / --text-only > FLASHBROWSE_RESOURCE_POLICY > agent-default. Conflicting flags fail loudly.
| Policy | JS & CSS | Images & Fonts | Trackers | Use Case |
|---|---|---|---|---|
agent-default (default) | Allowed | Blocked | Blocked | Fastest agent loops with identical AXTree accuracy |
text-only | Allowed (strict) | Blocked | Blocked | Minimal bandwidth text extraction |
full-render | Allowed | Allowed | Blocked | Pages requiring loaded media/webfonts during browsing |
browser_screenshot and browser_pdf automatically lift image/font blocks temporarily, re-request blocked assets, wait for font/image readiness, and restore your resource policy afterward.Stealth Profiles & Honest Limits#
Use --stealth-profile host-native (default) or windows to strip HeadlessChrome and keep User-Agent, navigator.platform, and Client Hints coherent.
Honest engineering boundaries documented in the repository:
- Stealth mitigates naive bot checks, not determined TLS/JA3, Canvas, or Audio fingerprinting.
- MCP
browser_openenforces an allowlist (http,https,data,about:blank);file://stays CLI-only. - No geometry/bounding-box coordinates in the text tree; spatial/canvas tasks require vision or
browser_screenshot. - Markdown extraction is lightweight and does not replace a full Readability parser.
Commands & Global Flags#
Every CLI command shares global flags for Chrome discovery, resource policies, stealth profiles, and structured logging. Diagnostic logs always write to stderr so stdout stays clean for piping and JSON-RPC.
# Scheme is optional: public hosts default to https://, localhost/LAN to http://
flashbrowse open localhost:3000 --resource-policy full-render
flashbrowse open example.com --stealth-profile windows --log-format json| Command | Description |
|---|---|
flashbrowse setup | Download managed Chrome for Testing (~100–126 MB) |
flashbrowse open <url> | Navigate and print compressed action tree (ephemeral or --session-id <id>) |
flashbrowse act <id> --session-id <id> --action <op> | Interact with element [N] (click, fill, select, scroll, press_key, etc.) |
flashbrowse dump <url> --format <fmt> | Dump markdown, axtree, axtree-nested, raw, or fidelity |
flashbrowse bench <url> | Measure open latency and token count |
flashbrowse mcp | Start the MCP stdio JSON-RPC server |
flashbrowse close --session-id <id> | Terminate a persistent browser session |
flashbrowse doctor [--json] | Launch-verify Chrome, cache writability, memory, and orphan processes |
flashbrowse stats [--limit N] [--json] | Aggregate p50/p95 latency and token stats from metrics.jsonl |
flashbrowse update [--check] | Check or self-update binary from GitHub Releases |
Profiles, CDP Attach & Files#
Attach to an already running Chrome instance via --cdp-url or launch with a persistent user profile via --user-data-dir (mutually exclusive). Configure file sandboxes for uploads, downloads, PDFs, and storage state.
# Launch with a saved Chrome profile directory
flashbrowse open app.example.com --user-data-dir ~/.chrome-agent-profile
# Attach to an existing Chrome process (never killed on disconnect)
flashbrowse mcp --cdp-url http://127.0.0.1:9222 \
--file-root ./browser-files \
--storage-state-root ./states
# Upload a file inside a persistent CLI session
flashbrowse act 4 --session-id s1 --action upload --value ./report.pdfClient Setup (Claude, Cursor, Codex)#
flashbrowse supports MCP protocol versions 2025-06-18, 2025-03-26, and 2024-11-05 over stdio. You can point your client directly at the native flashbrowse binary or launch zero-install via npx --yes @nhrbuilds/flashbrowse mcp.
{
"mcpServers": {
"flashbrowse": {
"command": "flashbrowse",
"args": ["mcp", "--file-root", "./browser-files"]
}
}
}{
"mcpServers": {
"flashbrowse": {
"command": "npx",
"args": ["--yes", "@nhrbuilds/flashbrowse", "mcp"]
}
}
}All 18 MCP Tools#
Every MCP tool call shares a 120-second execution deadline with panic and cancellation recovery that preserves unaffected browser contexts. After browser_open or browser_act, call browser_screenshot on the same session - no secondary browser MCP is needed.
| Tool | Key Parameters | Purpose |
|---|---|---|
browser_open | url, resource_policy?, text_only? | Navigate, settle, and return compressed numbered action tree |
browser_act | action, action_id?, target_action_id?, value?, amount?, dialog_action?, prompt_text? | Perform click, double_click, right_click, drag_and_drop, fill, hover, press_key, scroll, or select |
browser_fill_form | fields: [{ action_id, value }] | Batch-fill multiple fields from one tree and return refreshed tree |
browser_navigate | action: back|forward|reload, ignore_cache? | Navigate session history or hard-reload |
browser_wait_for | text?, selector?, url?, network_idle_ms?, timeout_ms? | Wait for condition (including open shadowRoots) and refresh tree |
browser_extract_markdown | - | Extract readable content and child iframes as clean Markdown |
browser_evaluate | expression | Run JS via Runtime.evaluate (returnByValue) |
browser_screenshot | action_id?, prepare_lazy_content?, timeout_ms? | Capture viewport/element-clipped PNG after lifting image/font blocks |
browser_pdf | name, paper_width?, paper_height?, margin_*?, prefer_css_page_size?, timeout_ms? | Print page to PDF under --file-root/pdfs/ with webfont/image recovery |
browser_tabs | action: list|select|close, target_id? | List, switch, or close tabs and tracked popups |
browser_contexts | action: list|create|select|close, name? | Run isolated incognito-like BrowserContexts inside one Chrome process |
browser_storage_state | action: import|export, name | Save or restore cookies and localStorage JSON under --storage-state-root |
browser_emulate | viewport?, timezone?, locale?, geolocation?, permissions?, reset? | Override device metrics, timezone, locale, geo, or permissions |
browser_upload | action_id, files: string[] | Upload files confined to --file-root to an input[type=file] |
browser_downloads | action: list|wait, guid?, timeout_ms? | Track or await downloads under --file-root/downloads/ |
browser_console | action: list|clear, level? | Inspect or clear console logs and uncaught exceptions |
browser_network | action: list|body|clear|set_headers, failed_only?, request_id?, headers? | Inspect requests (200-entry buffer, 64 KiB bodies) or inject extra headers |
browser_route | action: add|list|clear, url_pattern?, status?, content_type?, body?, abort? | Mock or abort matching network requests with wildcard glob patterns |
TypeScript & JavaScript Wrapper#
The official @nhrbuilds/flashbrowse package (github.com/nhrbuilds/flashbrowse-js) wraps the native flashbrowse executable with ESM and CommonJS entry points, TypeScript declarations, AbortSignal cancellation, structured FlashbrowseError diagnostics, and a persistent startMcpClient() manager.
Requires Node.js 22+ or Bun. Native binaries are installed automatically via optional platform packages for linux-x64-gnu, linux-arm64-gnu, darwin-arm64, darwin-x64, and win32-x64.
import { Flashbrowse, FlashbrowseError } from "@nhrbuilds/flashbrowse";
const browser = new Flashbrowse({
resourcePolicy: "agent-default",
stealthProfile: "host-native",
});
try {
const tree = await browser.open("https://example.com", {
sessionId: "example-session",
signal: AbortSignal.timeout(30_000),
});
console.log(tree);
} catch (error) {
if (error instanceof FlashbrowseError) {
console.error(error.message, error.exitCode, error.stderr);
}
} finally {
await browser.close({ sessionId: "example-session" });
}import { Flashbrowse } from "@nhrbuilds/flashbrowse";
const browser = new Flashbrowse();
const mcp = await browser.startMcpClient();
try {
await mcp.callTool("browser_open", { url: "https://example.com" });
const pdf = await mcp.callTool("browser_pdf", {
name: "monthly-report",
paper_width: 8.27,
paper_height: 11.69,
prepare_lazy_content: true,
timeout_ms: 8_000,
});
console.log(pdf);
} finally {
await mcp.close();
}Executable Resolution & Updates#
Flashbrowse resolves the underlying native binary in strict precedence order:
- 1. Explicit
binaryPathoption passed tonew Flashbrowse({ binaryPath }). - 2.
FLASHBROWSE_BINenvironment variable. - 3. Matching optional platform package (
@nhrbuilds/flashbrowse-<os>-<arch>). - 4. Standalone
flashbrowseexecutable onPATH.
@nhrbuilds/flashbrowse pins a verified native binary checksum per npm release (e.g. 1.2.1 pins v1.6.1), update via npm update @nhrbuilds/flashbrowse rather than flashbrowse update.Observability & Update Channels#
Every CLI invocation and MCP tool call appends a JSON line to ~/.cache/flashbrowse/metrics.jsonl recording op, target, ms, tokens, actions, and ok. Use flashbrowse stats --json to inspect rolling latency percentiles and token budgets.
Control flashbrowse update release channels with FLASHBROWSE_UPDATE_CHANNEL: stable (default), beta, nightly, or off.
flashbrowse stats --limit 500 --json
FLASHBROWSE_UPDATE_CHANNEL=stable flashbrowse update --checkWorkspace Crates#
flashbrowse is organized as a focused 5-crate Rust workspace where dependencies flow strictly downward (cli/mcp -> core -> cdp).
| Crate | Responsibility |
|---|---|
flashbrowse-cdp | Chrome discovery/launch, typed CDP domains, POSIX pipe & WebSocket transport |
flashbrowse-bidi | Firefox discovery & launch groundwork (non-production) |
flashbrowse-core | Session lifecycle, settle engine, AXTree compressor, stealth, policies, metrics |
flashbrowse-mcp | Bounded JSON-RPC framing, panic/timeout recovery, 18 MCP tool handlers |
flashbrowse-cli | CLI argument parsing, subcommands, and persistent session files |