# browser-bridge Let any **MCP client** β€” Claude Code, Claude Desktop, Codex, or anything that speaks the Model Context Protocol β€” drive **your real Chrome**: your tabs, your logged-in sessions, your cookies, through a Chrome extension + a native messaging host. No second browser, no CDP debug port, no `--remote-debugging` flag. Because it operates the browser you're already signed into, an agent can do things that a fresh headless browser can't: read a page behind your auth, click through an app you're logged into, pull a token your framework stashed in `localStorage`. That power is also the risk β€” see **Security** below before you install. --- ## πŸ”’ Security first β€” read this browser-bridge drives a **real, authenticated Chrome**. It can read page content, cookies (including `httpOnly`), and web storage, and can run JavaScript in your pages. The guardrails that keep that safe: - **Broad host access, no per-site approval.** The extension holds `` host access, granted at install, and acts on **any** tab with no per-site prompt. Origin gating is *not* a boundary here β€” the controls below are. Only run the bridge in a Chrome you already trust with agent access. - **Kill switch + always-on masking, not per-action prompts.** Any tool can be disabled in the Options page (including `page_eval`, arbitrary JS), and `page_eval` results are always masked. There are no per-action confirmation prompts β€” the per-tool disable and masking are the gate, so keep high-risk tools off unless you need them. - **Read-only credentials.** Cookies and storage can be *read* (always masked β€” JWTs, long hex, long digit runs), never written. There is no `cookie_set` / `storage_set` by design. - **Authenticated bridge.** The localhost TCP socket authenticates each connection with a per-run secret in a `0600` lock file; the native-host manifest pins the extension ID. Full details: **[SECURITY.md](./SECURITY.md)** Β· [threat model](./docs/security/threat-model.md) Β· [trust boundaries](./docs/security/trust-boundaries.md) Β· [per-tool risk matrix](./docs/security/tool-risk-matrix.md). --- ## Quickstart (β‰ˆ60 seconds) **Prereqs:** Google Chrome (or Chromium on Linux). The **prebuilt** path below needs *no Rust and no Node.js*. ### 1. Get the binary + extension Download the archive for your platform from the **[latest release](https://github.com/whg517/browser-bridge/releases/latest)**, then run the bundled installer. `install.sh` auto-detects the prebuilt tarball and installs the shipped binary + extension directly.
macOS (Apple Silicon) / Linux x64 ```sh tar xzf browser-bridge-*-macos-arm64.tar.gz # or -linux-x64 cd browser-bridge-*-macos-arm64 ./install.sh ``` Installs the binary to `~/.browser-bridge/` (macOS) or `~/.local/share/browser-bridge/` (Linux) and writes the native-messaging host manifest with the pinned extension ID already trusted. > **macOS Gatekeeper:** the prebuilt binary is not yet notarized, so a > browser-downloaded archive may be quarantined ("cannot be verified"). Clear it > once after extracting β€” `xattr -dr com.apple.quarantine .` inside the > extracted folder β€” then re-run `./install.sh`.
Windows x64 ```powershell Expand-Archive browser-bridge-*-windows-x64.zip -DestinationPath . cd browser-bridge-*-windows-x64 powershell -ExecutionPolicy Bypass -File .\install.ps1 ``` Installs `browser-bridge.exe` to `%LOCALAPPDATA%\browser-bridge\` and registers the host under your user's Chrome Native Messaging registry key. No admin rights needed. > **SmartScreen:** the prebuilt exe is unsigned, so SmartScreen may warn on first > run β€” choose **More info β†’ Run anyway**.
Build from source (needs Rust + Node.js/npm) ```sh git clone https://github.com/whg517/browser-bridge && cd browser-bridge ./install/install.sh # Linux: --browser chrome|chromium|both ``` `install/install.sh` builds the Rust binary and the extension bundle, then installs both. See [docs/development.md](./docs/development.md) for the full build/test loop.
> Only need the extension (binary already installed)? Grab > `browser-bridge-extension-.zip` from the same release and unzip it β€” the > `manifest.json` sits at the root, so you can **Load unpacked** the extracted > folder directly. (To upload to the Chrome Web Store, use the separate > `…-store.zip` asset instead β€” it strips the manifest `key`, which the store > requires; the plain zip keeps the `key` so unpacked loads get the pinned ID.) ### 2. Add the extension **Recommended β€” from the Chrome Web Store:** install **[Browser Bridge](https://chromewebstore.google.com/detail/browser-bridge/dgccjfjjilfpkbdllclmkiicajndkfcd)** β†’ **Add to Chrome**. No Developer mode, survives restarts, and works on managed Chrome. The installer already trusts the store's extension ID (`dgccjfjjilfpkbdllclmkiicajndkfcd`), so there's nothing to copy or patch.
Developer / advanced β€” load unpacked `chrome://extensions` β†’ enable **Developer mode** β†’ **Load unpacked** β†’ select the **`extension/dist/`** directory (the build output, *not* `extension/`). Loaded this way the extension ID is **pinned** to `mkjjlmjbcljpcfkfadfmhblmmddkdihf` (via the manifest `key`), which the installer also trusts by default β€” so unpacked and store installs both connect.
### 3. Register the MCP server Point your client at the installed binary (run with no args β€” it speaks MCP over stdio). Use an **absolute path**; most clients don't expand `~`. - **Claude Code (CLI):** ```sh claude mcp add browser-bridge -- "$HOME/.browser-bridge/browser-bridge" ``` - **Claude Desktop / generic (`mcpServers` JSON):** copy the `browser-bridge` entry from [`mcp-config.example.json`](./install/mcp-config.example.json). - **Codex (`~/.codex/config.toml`):** ```toml [mcp_servers.browser-bridge] command = "/absolute/path/to/browser-bridge" args = [] ``` ### 4. Restart Chrome & try it Restart Chrome so it loads the native-host manifest, then reconnect your MCP client and ask: **"list my browser tabs."** Tools run on any tab immediately β€” there's no per-site approval step. **First time? Paste this to your AI** to teach it the workflow and safety gates in one shot (source: [docs/agent-prompt.md](./docs/agent-prompt.md)): ```text You're connected to Browser Bridge over MCP: it drives my real, already-open Chrome, so you act as me, inside my logged-in sessions. Everything you do is visible on my screen and uses my real accounts. Work carefully: - Read before acting. To work with a page, call page_snapshot first β€” it lists the interactive elements, each with a ref. Act by ref with page_click / page_fill; don't guess selectors. Re-snapshot after navigation. Read with page_text / page_screenshot; list tabs with tab_list. - Don't do irreversible things β€” submitting forms, closing tabs, sending messages, purchases β€” unless I ask. Prefer the least-powerful tool; use page_eval (arbitrary JS) only as a last resort. There are no per-action confirmation prompts: clicks, page_eval, and tab_close run immediately, so nothing but your own judgement stops a mistake β€” double-check before acting. - page_eval needs a setting I have to turn on. Chrome blocks this extension from running code in the page on every site, so page_eval fails until I enable CDP mode in the Browser Bridge Options page. If you hit that error, don't retry and don't work around it β€” tell me what you were trying to do and that I need to switch CDP mode on, then wait. The other tools are unaffected. - Never exfiltrate secrets. Cookie and storage reads come back masked; don't try to defeat that or forward credentials off-origin. - There's no per-site gate. The extension can act on any tab I have open, with no approval prompt β€” so you carry the responsibility to stay on the tabs and tasks I asked about. Don't wander to other tabs or origins on your own. Then tell me what you can help with, or ask what I'd like to do in the browser. ``` MCP clients that support server instructions get this automatically at connect time, so pasting is only needed for a manual kickstart. > On **WSL**: if your everyday browser is Windows Chrome, install on Windows and > point the WSL client at the `.exe` via `/mnt/c` β€” don't install a Linux host. > If Chrome runs under WSLg, install natively in Linux. See the > [WSL guide](./docs/wsl.md). --- ## What you can do β€” 16 tools Grouped from the single source of truth, [`contracts/tools.json`](./contracts/tools.json): > **Driving an AI agent?** The server hands your MCP client a short kickstart > prompt at connect time (the `initialize` `instructions` field) β€” or paste it > yourself from [the Quickstart above](#4-restart-chrome--try-it) / > [docs/agent-prompt.md](./docs/agent-prompt.md). ### Tabs | Tool | Does | Risk | |------|------|------| | `tab_list` | List open tabs (id, title, url, active) | low | | `tab_focus` | Bring a tab to the foreground | low | | `tab_open` | Open a URL in a new tab (any URL) | medium | | `tab_close` | Close a tab by `tabId` | high | ### Inspect a page | Tool | Does | Risk | |------|------|------| | `page_snapshot` | Accessibility-style tree of interactive elements, each with a stable `ref` | low | | `page_snapshot_precise` | Authoritative a11y tree via `chrome.debugger` (shadow DOM / complex ARIA); refs use a `p` prefix | medium | | `page_text` | Page text β€” passwords & card-like numbers masked (`mode`: `visible` default, or `full` to include hidden/inactive-tab panels) | medium | | `page_links` | Every `` as `{text, href, type}` β€” surfaces `mailto:`/`tel:`/external/internal links (tokens masked, emails/phones kept) | medium | | `page_screenshot` | Visible viewport as a PNG | medium | ### Drive a page | Tool | Does | Risk | |------|------|------| | `page_click` | Click by `ref` or `selector` | high | | `page_fill` | Type into a field (native setter, so React/Vue detect it) | high | | `page_scroll` | Up / down / top / bottom / N pixels | low | | `page_wait_for` | Wait for a selector, text, or navigation | low | ### Run code (highest risk) | Tool | Does | Risk | |------|------|------| | `page_eval` | ⚠ Execute arbitrary JS. **Requires CDP mode** β€” Chrome forbids the extension from evaluating code in the page on every site, so without it the call fails and tells your agent to ask you to switch it on ([ADR-0025](./docs/adr/0025-page-eval-requires-cdp-mode.md)). Return value always masked; disable it entirely in the Options page. Prefer the tools above. | critical | ### Read credentials (read-only, always masked) | Tool | Does | Risk | |------|------|------| | `cookie_get` | Read cookies for the active tab, incl. `httpOnly` (values masked) | high | | `storage_get` | Read the page's `localStorage` / `sessionStorage` (same-origin) | high | *No write tools by design β€” cookie/storage writes are out of scope ([ADR-0010](./docs/adr/0010-cookie-storage-readonly.md)).* ### Non-MCP agents & scripts An agent or shell that doesn't speak MCP can **discover** the tools and **invoke** them without any handshake β€” no wrapper code: ```sh browser-bridge tools --json # discover: capabilities (== MCP tools/list) browser-bridge tools # …or a human-readable summary browser-bridge call tab_list # invoke: runs one tool, raw JSON on stdout browser-bridge call tab_open '{"url":"https://example.com"}' ``` `tools` needs nothing running (it just self-describes). `call` shares the one bridge connection, so it refuses (exit 4) while your MCP client is active. Details + exit codes: [docs/cli.md](./docs/cli.md#call-one-shot-tool-call-for-non-mcp-callers). **Multiple MCP clients can share one browser.** Add browser-bridge to each client's config; they all join one bridge and each agent gets its own tab workspace (its own group, its own scoping). See [ADR-0028](./docs/adr/0028-multi-agent-broker.md) and [docs/operations.md](./docs/operations.md#multi-client-operation-the-broker). --- ## How it works One Rust binary, several modes, joined by a localhost socket. Multiple MCP clients can share one browser β€” a broker multiplexes them, and each agent gets its own tab workspace: ``` MCP client A ──stdio MCP──▢ browser-bridge (thin server) ─┐ MCP client B ──stdio MCP──▢ browser-bridge (thin server) ── localhost TCP β–Ό (NDJSON, per-run secret) browser-bridge --broker ◀── spawned automatically β”‚ β–Ό localhost TCP browser-bridge --native-host ◀── spawned by Chrome β”‚ β”‚ chrome.runtime.connectNative β–Ό Browser Bridge extension (MV3) ──▢ your page ``` - **Thin server (default mode)** β€” launched by your MCP client over stdio. Relays its client's JSON-RPC (MCP protocol `2025-06-18`) to the broker. - **`--broker`** β€” owns the lock file and the single extension connection; grants per-agent identities, multiplexes clients, schedules mutations per tab, and exits on its own after the last client leaves. Spawned automatically; you rarely run it by hand. - **`--native-host`** β€” launched *by Chrome* via the host manifest. A thin bridge translating Chrome's native-messaging frames (4-byte LE length + JSON) to NDJSON on the socket. Why these processes? Chrome spawns the native host; the MCP client spawns the server β€” they aren't parent/child, so they need an IPC. The broker sits in the middle so that service-worker recycling, host restarts, and MCP client restarts never lose the shared session, and so several agents can work in one browser without trampling each other. Deep dive: [docs/architecture.md](./docs/architecture.md) Β· [ADR-0002](./docs/adr/0002-three-process-architecture-localhost-tcp.md). --- ## Compatibility | | Supported | |---|---| | **macOS** | Apple Silicon (arm64) prebuilt. Intel via Rosetta 2 or from source. | | **Linux** | x64 prebuilt; Google Chrome or Chromium. | | **Windows** | x64 prebuilt (native, no admin). | | **Browser** | Chrome / Chromium, Manifest V3 | | **MCP protocol** | `2025-06-18` ([ADR-0007](./docs/adr/0007-mcp-protocol-version-2025-06-18.md)) | | **Internal bridge protocol** | `1` (see [contracts/protocol-version.json](./contracts/protocol-version.json)) | Prebuilt targets come from the tag-driven [release workflow](./.github/workflows/release.yml); see [docs/compatibility.md](./docs/compatibility.md). ## Configuration Environment variables read at launch (source: `src/log.rs`, [docs/cli.md](./docs/cli.md)): | Var | Values | Default | Effect | |-----|--------|---------|--------| | `BB_LOG` | `error` \| `warn` \| `info` \| `debug` | `info` | stderr log / audit threshold. `warn`/`error` silences audit lines. | | `BB_LOG_FORMAT` | `text` \| `json` | `text` | Audit-line format; `json` emits one object per line for machine collection. | | `BB_LOCK_DIR` | absolute dir | per-user data dir | Overrides where the lock file lives. Set the **same** value on both the MCP server and the native host when they run under different user contexts (e.g. Windows automation as SYSTEM vs. Chrome as the desktop user), so both find the bridge. | ## Troubleshooting Run the built-in read-only self-check first: ```sh browser-bridge doctor # or: browser-bridge status ``` It reports whether the server is reachable, the lock-file port/pid, and common misconfigurations. Then check your MCP client's server UI (reconnect via `/mcp` in Claude Code) and the extension's Service Worker console at `chrome://extensions` (look for `[bb]` logs). Full runbook: [docs/cli.md](./docs/cli.md) Β· [docs/operations.md](./docs/operations.md). ## Uninstall Run the same installer with the uninstall flag. It removes exactly what it placed (binary, native-host manifest / registry key, `run.lock`) β€” idempotent, no wildcards, never touches a process or the browser. ```sh ./install.sh --uninstall # macOS / Linux # add --unregister-claude-code to also run `claude mcp remove browser-bridge` powershell -ExecutionPolicy Bypass -File .\install.ps1 -Uninstall # Windows ``` Two things it deliberately leaves to you (and prints reminders for): 1. **The extension** β€” remove it at `chrome://extensions` (unpacked extensions can't be removed by a script). 2. **Your MCP client's server entry** β€” e.g. `claude mcp remove browser-bridge`, or delete the `browser-bridge` entry from Claude Desktop's `mcpServers` / the `[mcp_servers.browser-bridge]` block in `~/.codex/config.toml`. The extension's stored data (settings) lives in Chrome and is cleared when you remove the extension. --- ## Docs map | Doc | What's in it | |-----|--------------| | [docs/requirements.md](./docs/requirements.md) | Goals, user stories, functional/non-functional requirements, scope boundaries | | [docs/architecture.md](./docs/architecture.md) | Components, data flow, protocols, security model, key constraints | | [docs/security/](./docs/security/) | Threat model, trust boundaries, tool risk matrix, incident response | | [docs/cli.md](./docs/cli.md) | `doctor`/`status` self-check, troubleshooting | | [docs/operations.md](./docs/operations.md) | Two binary modes, logging/audit, lock file, reconnection | | [docs/compatibility.md](./docs/compatibility.md) | Version discipline and capability/protocol handshake | | [docs/release.md](./docs/release.md) | Tag-driven releases, prebuilt tarball + checksums, SBOM | | [docs/wsl.md](./docs/wsl.md) | The two modes β€” Windows Chrome interop and WSLg | | [docs/adr/](./docs/adr/) | Architecture Decision Records (ADR) β€” the "why" behind each choice | | [contracts/](./contracts/README.md) | Tool catalog, error codes, capabilities, protocol version (cross-process contract source of truth) |
Testing & project layout Independent suites across two languages, run together with `./tests/run_all.sh`: - **Protocol layer** β€” `tests/e2e.py` drives the real binary (MCP over stdio, `--native-host` framing, mock extension over the TCP bridge). - **DOM layer** β€” `tests/dom_test.ts` injects the real content script into headless Chrome via CDP and exercises every op against a real DOM. - **Smoke** β€” `tests/ext_test.ts` boots real Chrome with `extension/dist/`. - **Real integration** (opt-in) β€” `tests/integration_e2e.ts`; run with `BB_REAL_E2E=1`. Needs Chrome for Testing / Chromium. See [tests/README.md](./tests/README.md). Rough source layout: `src/` (Rust: `main.rs` mode dispatch, `protocol.rs`, `ipc.rs`, `native_host.rs`, `mcp_server.rs`, `tools/`, `session.rs`), `extension/src/` (TypeScript β†’ `dist/` via esbuild), `contracts/` (cross-process contracts), `docs/`.
--- ## Project status **v0.1.0** ([Cargo.toml](./Cargo.toml)) plus phase-two/three tools. Protocol layers (NM framing, MCP JSON-RPC, TCP bridge) are covered by end-to-end tests. The default snapshot is a content-script approximation of the a11y tree; `page_snapshot_precise` is the debugger-based fallback for complex ARIA/shadow DOM. Cookie/storage access is read-only and masked. See [CHANGELOG.md](./CHANGELOG.md). ## Contributing & governance [CONTRIBUTING.md](./CONTRIBUTING.md) (workflow) Β· [GOVERNANCE.md](./GOVERNANCE.md) (how changes get made) Β· [SECURITY.md](./SECURITY.md) (reporting + review bar) Β· [docs/development.md](./docs/development.md) (build/test/release loop). ## License [Apache-2.0](./LICENSE). Copyright the browser-bridge contributors.