Skip to main content
Glama

stealth-browser-mcp

PyPI License: MIT tests macOS Python 3.11+ uv

Stealth browser automation for AI coding agents on macOS — an MCP server (stealth-browser) and a transcript-driven audit CLI (stealth-browser-audit).

Why stealth-browser?

Launching a second browser binary alongside an active one on macOS can corrupt shared IPC rendezvous ports, freezing tab creation and IPC in your main browser. stealth-browser avoids this completely:

  1. CDP First: Attempts to attach to an existing browser session over http://127.0.0.1:9222 (STEALTH_BROWSER_CDP_PORT).

  2. Standalone Stealth Fallback: Falls back to launching a dedicated Patchright stealth Chromium instance (~/.agent-chromium-profile) with native stealth masking and an isolated profile.

  3. Clean Lifecycle & Idle Watchdog: Automatically shuts down the background Patchright Node driver after 5 minutes of inactivity (STEALTH_BROWSER_IDLE_TIMEOUT=300) and guarantees immediate subprocess teardown on SIGTERM, SIGHUP, or stdin EOF.

Quickstart

Review the Trust model for security and filesystem boundaries before exposing the server to untrusted prompts.

Prerequisites:

  • macOS — the server uses osascript for human handoff and macOS-specific browser paths.

  • uv — install with brew install uv or the official installer. uv manages Python and dependencies; no system Python setup is needed.

  • A first-launch browser download (~195 MB network, ~370 MB on disk) via stealth-browser --install-browser.

Install the tool and register it with your agent — no clone and no absolute path required:

uv tool install stealthmcp
stealth-browser --install-browser
stealth-browser --doctor

Upgrade or remove later with uv tool upgrade stealthmcp / uv tool uninstall stealthmcp.

If stealth-browser is not found after install, run uv tool update-shell to add uv's tool directory (~/.local/bin) to your PATH. GUI-launched clients that ignore your shell PATH can use the full shim path printed by uv tool dir (for example ~/.local/bin/stealth-browser).

MCP Configuration

The install above provides a stealth-browser command on your PATH. The cleanest setup uses your client's CLI, which writes the config for you:

claude mcp add -s user stealth-browser -- stealth-browser
opencode mcp add --global stealth-browser -- stealth-browser

Or add the following to your agent's config (~/.gemini/config/mcp_config.json, ~/.config/opencode/opencode.jsonc, ~/.claude.json, or .cursor/mcp.json). No username-specific path needed:

{
	"mcpServers": {
		"stealth-browser": {
			"command": "stealth-browser",
			"args": []
		}
	}
}

Other install methods

  • No install (try it): uvx --from stealthmcp stealth-browser --doctor, or run straight from the source without a checkout: uv run https://raw.githubusercontent.com/levontumanyan/stealth-browser-mcp/main/bin/stealth_browser.py --doctor.

  • pip (in a venv): python3 -m venv .venv && . .venv/bin/activate && pip install stealthmcp, then the same stealth-browser command. Prefer a venv over a global pip install.

  • pipx: pipx install stealthmcp, then the same stealth-browser command.

  • Existing checkout: uv run --script /absolute/path/to/stealth-browser-mcp/bin/stealth-browser keeps working unchanged. Add that checkout's bin/ to your PATH and run stealth-browser --help for a local dev setup.

Related MCP server: cloakbrowser-mcp

Verification

stealth-browser --doctor checks Python, dependency versions, cheat-sheet creation, and browser/CDP availability, then exits non-zero on failure. Add --smoke to actually launch Chromium and open a tab. stealth-browser --version prints the installed version.

Shared Daemon & CLI

By default, stealth-browser runs a lightweight stdlib stdio proxy that auto-starts and shares a single local daemon over a 0600 Unix Domain Socket (scoped per CDP port and profile). Multiple MCP clients and subagents share one browser instance with per-client tab isolation.

  • stealth-browser --daemon-status — print running daemon PID, socket/HTTP endpoints, active clients, and uptime.

  • stealth-browser --daemon-stop — stop the running shared daemon cleanly.

  • stealth-browser --serve [--http [HOST:PORT]] [--daemon-idle-exit SECONDS] — run the shared daemon directly; --http also enables loopback Streamable HTTP (default 127.0.0.1:9223) with mandatory Bearer token auth; --daemon-idle-exit exits after idle seconds with 0 clients (1800 default, 0 disables).

  • stealth-browser --standalone — run an isolated in-process stdio MCP server instead of proxying to the shared daemon.

Available MCP Tools

  • status: Check connection status and list all open tabs with indices and stable ids.

  • navigate: Navigate the active tab or open a new tab (new_tab=True).

  • get_content / extract: Extract visible text or structured fields from body or any CSS/XPath selector.

  • click / type / press_key / scroll: Interact with page elements.

  • screenshot: Capture a viewport screenshot for multimodal agent inspection.

  • evaluate_js: Execute JavaScript in the active page context.

  • switch_tab / new_tab / close_tab: Full multi-tab management (closing the last tab automatically closes the browser).

  • close_browser: Completely close the browser window, terminate the browser process, and release all resources.

  • wait_for_human: Pause for interactive login/2FA/CAPTCHA with a macOS notification naming the tab (the browser never takes focus); pin follow-up calls to the tab's browser-derived id.

Headed in the background by default — the window exists but never steals focus (launched via open -g); use wait_for_human() for interactive login/2FA/CAPTCHA.

Tool Gating (--minimal / --disable-<section>)

Default exposes all 28 tools. To reduce schema context cost or restrict powerful tools per session (including over the shared daemon):

  • stealth-browser --list-sections — print all sections (core, debug, network, lifecycle), tool counts, and membership.

  • stealth-browser --minimal (or STEALTH_BROWSER_MINIMAL=1) — expose only the 16 core tools (status and wait_for_human are always protected in every mode).

  • stealth-browser --disable-debug / --disable-network / --disable-lifecycle (or STEALTH_BROWSER_DISABLE_SECTIONS=debug,lifecycle) — disable specific sections per session.

Trust model

  • Transport & auth: Default mode proxies stdio to a same-user 0600 Unix Domain Socket inside a 0700 runtime directory (STEALTH_BROWSER_RUNTIME_DIR, default ~/.cache/stealth-browser). Optional --serve --http [HOST:PORT] binds loopback only, enforces a Host allowlist for DNS rebinding protection, and requires a 0600 Bearer token (STEALTH_BROWSER_TOKEN_FILE, default ~/.config/stealth-browser/daemon.token). --standalone runs isolated in-process stdio with no socket or HTTP listener.

  • Security principal: Every connected agent is the security principal and can perform any action the user can perform in the attached browser (including all open tabs when attaching over CDP 127.0.0.1:9222). The shared daemon shares browser state across connected sessions and guards destructive lifecycle calls (close_browser, restart_browser, set_headless) against sibling sessions unless force=True is passed.

  • Filesystem boundaries: fetch(save_path=...) and screenshot(save_path=...) write to any path writable by the OS user — treat paths originating from web content or untrusted prompts as untrusted. Browser downloads land in STEALTH_BROWSER_DOWNLOADS_DIR (~/Downloads), the profile lives in STEALTH_BROWSER_PROFILE_DIR (~/.agent-chromium-profile), and the optional Apple Passwords CRX extension is fetched from Google's CRX endpoint and verified before loading into the profile.

  • Network & credentials: In-browser fetch sends credentials: 'include' with the current origin's cookies and evaluate_js reads arbitrary page state. Stealth masking reduces automation fingerprinting; it is not anonymity and does not isolate credentials.

  • Operator config & recovery: STEALTH_BROWSER_* environment variables and MCP client configs are trusted host input; store secrets in macOS Keychain rather than configs or prompts. Recover from wedged or unwanted state via close_browser(force=True), restart_browser(force=True), stealth-browser --daemon-stop, or terminating the detached Chromium process; closing the last open tab with close_tab also closes the browser.

  • Explicit non-claims: No guarantee against bot detection; no proxy or anonymity features; detection depends on site policy, IP reputation, and browser build.

Audit

  • stealth-browser-audit [--since 14d] [--session <sid-prefix>] [--diff <baseline.json>] [--no-cache] — mine local AGY and OpenCode transcripts for stealth-browser usage, error rates, latency, and workarounds; produces a prioritized improvement plan or before/after scorecard. Installed alongside stealth-browser by stealthmcp and also runnable directly from a checkout via bin/stealth-browser-audit.

Development

git clone https://github.com/levontumanyan/stealth-browser-mcp.git
cd stealth-browser-mcp
uv sync
uv run pytest tests/ -x

bin/stealth_browser.py is the canonical source; bin/stealth-browser is a symlink that preserves the historical path and PEP 723 uv run --script workflow. Dependencies are declared in both the script's PEP 723 block and pyproject.toml, and a test keeps them in sync.

To publish a new version, see RELEASING.md. Only a v* tag publishes; merging PRs does not.

Agent Skills (skills/)

Reusable agent workflows live in skills/, one directory per skill with a SKILL.md:

  • stealth-browser-audit — mine local agent transcripts for stealth-browser usage, errors, latency, and workarounds.

  • stealth-browser-subagent — delegate heavy browser flows to an isolated subagent so DOM output stays out of the parent context.

  • stealth-browser-usage — workflow decisions beyond the served cheat-sheet: shared-daemon etiquette, owned tabs, delegation, and when to reach past snapshot/extract.

Register the directory with your harness instead of copying files (replace <checkout> with this repo's path):

  • OpenCode: add "<checkout>/skills" to the skills array in your opencode.jsonc.

  • Google Antigravity (agy): add { "path": "<checkout>/skills" } to the entries of ~/.gemini/config/skills.json.

Tool signatures and universal rules need no harness registration: the MCP server serves them as instructions and exposes them as the instructions://cheatsheet resource for any client that reads them.

Available Tools

28 tools
batchB

Run sequential actions in one turn. Valid actions: click, fill, type, select, press, wait_for, sleep, evaluate (fields: selector, ref, text, value, key, state, ms, force, expression, main_world, timeout_ms).

Inputs: actions (required), tab. Returns: result

clickA

Click an element by CSS selector, snapshot ref ('e12' or '@e12'), or visible text. Set force=True to bypass pointer-interception overlays.

Inputs: ref, tab, text, force, +2 more. Returns: result

close_browserB

Completely close the browser window, terminate all browser and renderer processes, and release all resources.

Inputs: force, force_kill. Returns: result

close_tabB

Close tab by index, browser-derived id, or name substring (-1 active, -99 last). Accepts 'tab'/'index'.

Inputs: tab, index. Returns: result

console_logsB

List captured browser console messages and page errors (filter by comma-separated level: 'error,warning,log,pageerror'). Attaches CDP console listener on first call.

Inputs: tab, clear, level, limit, +1 more. Returns: result

downloadsA

List tracked browser downloads (and recent DOWNLOADS_DIR files when include_dir=True).

Inputs: limit, include_dir. Returns: result

evaluate_jsB

Evaluate JS in isolated world by default (alias: script=). Set main_world=True for page globals.

Inputs: tab, script, expression, main_world, +2 more. Returns: result

extractB

Extract JSON rows from containers (cards/tables/forms) across DOM/Shadow/iframes. fields: name -> 'text:.sel'|'@attr .sel' ('@value'/'@checked' for inputs)|'html:.sel'|{selector,mode,attr}.

Inputs: fields (required), container_selector (required), tab, limit, +3 more. Returns: result

fetchB

Execute an authenticated in-browser fetch (supports relative, absolute, and blob: URLs). Pass save_path to write binary/PDF responses to disk without entering context.

Inputs: url (required), tab, body, method, +5 more. Returns: result

get_contentB

Extract visible text from a tab. Supports offset (negative for tail, e.g. -3000), filter (regex/substring with context), clean=True (strips nav/hidden/whitespace), or interactive_only=True (calls snapshot).

Inputs: tab, clean, filter, offset, +3 more. Returns: result

keep_aliveC

Keep a tab session alive: trusted CDP mouse/wheel input, modal auto-click, optional click_selector and heartbeat ping_url.

Inputs: tab, enable, ping_url, max_seconds, +2 more. Returns: result

network_requestsC

List captured network responses/failures for a tab. Filter by url_filter, resource_type ('xhr,fetch'), content_type ('json','pdf'), or status_min (e.g. 400).

Inputs: tab, clear, limit, max_length, +4 more. Returns: result

new_tabA

Open a new browser tab and navigate to url (default 'about:blank'). Set block_media=True for high-speed text-only browsing.

Inputs: url, block_media. Returns: result

press_keyC

Press a keyboard key (e.g., 'Enter', 'Tab', 'Escape').

Inputs: key (required), tab. Returns: result

restart_browserC

Restart Chromium cleanly, preserving non-blank tabs unless url overrides tab [0]. headless=None keeps current mode.

Inputs: url, force, headless. Returns: result

screenshotC

Capture a screenshot of the active page, full page, or a specific element (by selector or snapshot ref). Set annotate=True to temporarily overlay snapshot ref labels (e0, e1, ...).

Inputs: ref, tab, annotate, selector, +2 more. Returns: result

scrollC

Scroll up or down by amount pixels.

Inputs: tab, amount, direction. Returns: result

set_animationsB

Freeze CSS animations/transitions via reduced-motion emulation + a kill-stylesheet; sites may serve reduced-motion content variants, and re-enabling fully applies only after restart_browser() because init scripts cannot be removed.

Inputs: tab, enabled, persist. Returns: result

set_headlessA

Switch headed (default) vs headless mode; restarts Chromium on change (switching to headless refuses if non-blank tabs exist unless force=True). Prefer wait_for_human() for login/2FA.

Inputs: force, headless. Returns: result

set_mediaB

Toggle media loading (images, videos, web fonts) on a tab. enable_media=False blocks heavy media for fast text-only browsing.

Inputs: tab, enable_media. Returns: result

snapshotB

List visible interactive elements with refs (e0, e1, ...) across DOM, Shadow DOM, and same-origin iframes. Use filter/viewport_only to narrow; include_hrefs=True to show link URLs.

Inputs: tab, filter, selector, max_length, +5 more. Returns: result

stateC

Inspect in-memory client-side state (framework: 'auto'|'next'|'redux'|'react'|'vue'|'apollo'|'query'; optional selector for React Fiber).

Inputs: tab, selector, framework, max_length. Returns: result

statusA

Check connection status to Stealth Browser and list all open tabs.

Inputs: no named parameters. Returns: result

switch_tabA

Switch tab by index, browser-derived id, or name substring (see status). Accepts 'tab'/'index'.

Inputs: tab, index. Returns: result

typeC

Type text into an input/textarea by CSS selector or snapshot ref ('e3' or '@e3').

Inputs: ref, tab, text, selector, +3 more. Returns: result

wait_forB

Wait for a CSS selector state, visible page text substring, URL substring, or combination. Clamped to 60s cap.

Inputs: tab, text, state, selector, +2 more. Returns: result

wait_for_humanA

Hand off a tab to the human for login/2FA/CAPTCHA without stealing focus: sends an optional macOS notification naming the tab and polls until url_contains, url_not_contains, selector visible, or URL change (switches to headed mode only if the browser currently runs headless).

Inputs: tab, notify, reason, selector, +4 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 28 tools

    Disambiguation4/5

    Most tools target clearly distinct browser operations (navigation, tab lifecycle, input, extraction, diagnostics), and descriptions provide good boundaries. Minor overlaps exist between snapshot/get_content/extract and batch vs individual actions, but those are generally resolvable from the descriptions.

    Naming Consistency4/5

    All names use consistent snake_case and are readable, with no camelCase mixing. There is some variation between verb-first names (navigate, click, get_content) and noun names (snapshot, status, state, downloads, batch), but the convention remains predictable overall.

    Tool Count3/5

    At 28 tools, the surface is heavy for a browser automation server, and several niche controls (set_media, set_animations, keep_alive, state) could be folded into broader configuration or utility tools. Each tool is defensible, but the count is on the high side and increases selection overhead.

    Completeness4/5

    The set covers navigation, tab management, interaction, extraction, waits, screenshots, downloads, network/console diagnostics, JS evaluation, human handoff, and browser mode switching. Minor gaps remain around cookies/storage, file upload, and hover/drag interactions, but core browser automation workflows are well supported.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Stealth browser automation for AI agents, using source-patched Chromium to bypass bot detection systems like Cloudflare, reCAPTCHA, and FingerprintJS.
      28
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Stealth browser automation over raw CDP, driving a real unmodified Chrome with no Playwright or Puppeteer in the stack. Returns numbered element refs from the accessibility tree so a model clicks ref 3 instead of guessing a CSS selector, and can attach to an already-running Chrome to reuse logged-in sessions.
      33
      46 npm
      50
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables local AI agents on macOS to drive the user's own signed-in Chrome through their own isolated tabs, with per-client tokens, blocked site categories, masked secrets and human hand-offs. Agents can open and navigate tabs, read pages, send real clicks and typing, inspect network requests, and hand tabs back to the user, all without touching other tabs or stealing focus.
      72 npm
      1
      MIT