The missing piece in AI coding: your agent can now see your REAL browser.
--- ## What this project solves You ship a fix. Your agent says "done, please verify." You alt-tab to Chrome, navigate to the page, log in, click around, find the bug. Your agent just wrote the code. It could also verify it. It already has your browser open right there. It just can't see it. **Now it can.** Browser Controller gives any MCP-compatible AI agent (Cursor, Claude Desktop, Windsurf, …) direct control of the **browser you already have open** — your real sessions, your logins, your cookies. No headless browser, no fresh profile, no re-authentication. Version 3.0 is a breaking release: 19 tools, one `target` locator, and text results with structured receipts for actions. See [Migrating from 2.x](#migrating-from-2x). ## Key capabilities - **Multiple agents at once.** Cursor can drive tab 10 while Claude drives tab 11 — both through one shared daemon, neither blocking the other. - **Tab targeting, not "the active tab."** Every page action names a `tabId`. Move your mouse, switch tabs, watch YouTube — the agent keeps working on the tab you told it to. It never hijacks the page you're reading. - **Tab ownership without lock calls.** A tab that `browser_navigate` opens for a session belongs to that session until it closes. Another session's call on that tab fails at once with `TAB_LOCKED`. - **Per-tab isolation.** Element refs are per page, and logs and network buffers are per tab. A ref from tab 10 can never click something in tab 20. - **Per-tab concurrency.** Two actions on the _same_ tab serialize (no races); actions on _different_ tabs run in parallel. - **Agent-control shield.** While a tool runs on a tab, you see a translucent blue inner frame and your input on that tab is blocked (mouse, keyboard, wheel). It disappears when the action finishes. - **Visible agent cursor (optional).** Switch on *Show agent cursor* in the side panel's Settings and agent mouse actions draw a pointer that glides to its target first. Off by default. - **Real, trusted input.** Clicks, typing, keys, wheel and drags go through the Chrome DevTools Protocol, so the page sees `isTrusted` events and focus, Tab, Enter and autocomplete behave as they do for a person. There is no synthetic-event fallback: if the debugger cannot attach, input fails with `DEBUGGER_UNAVAILABLE`. The yellow "being debugged" banner shows while the debugger is attached. - **One locator.** `target` takes a ref (`e12`), `text=Sign in`, viewport coordinates (`x,y`), a CSS selector, or an accessible `{ role, name, nth? }` object. Shadow roots and same-origin iframes are searched; cross-origin iframes are listed as not readable. - **Honest results.** A success is compact text. A failure is an `isError` result whose text is `CODE: message`, so the agent acts on the code instead of guessing. - **Batches.** `browser_batch` runs up to 50 tool calls in one round trip and stops at the first failing step (`onError:"continue"` runs the rest and names every failure). - **The page is read after it settled.** An action waits for the page to stop changing before the call returns, and a navigation waits for the page it loaded to draw, so the read that follows sees what the action produced, not the page before it. `browser_wait {until:"stable"}` waits for the same thing on demand. - **A session can be fenced in.** `browser_tabs {action:"session"}` opens the session for reading only (every call that changes something is refused), or isolates it (the agent touches the tabs it opened, and only those). - **Console-style JavaScript.** `browser_evaluate` accepts code as you'd type it in DevTools: top-level `await`, several statements with `return`, DOM nodes come back as readable descriptions. Over CDP, page CSP does not block it. - **Console, network and mocks on demand.** `browser_logs` reads a tab's console (uncaught errors with stacks) and its network requests, with response bodies on request. `browser_mock` answers or blocks one tab's requests, so the page really receives the fake response. - **Frozen tabs don't freeze the agent.** `browser_navigate` replaces a tab that stopped answering, and its result says so with a `note:` line naming the new `tabId`. - **Several browsers.** Every connected Chrome profile is its own connection. `browser_tabs { action: "profiles" }` lists stable IDs, local labels, the default, and whether each profile has open tabs without switching the session. Use the ID to select a profile; `auto` means the earliest-connected default. Set a recognizable local label in the extension's Settings. - **Authenticated local connection.** Token + enrollment secret, so no other local process can silently drive your browser — and after a one-time `npm run setup:pairing` the extension pairs itself. Everything stays on localhost — no cloud, no telemetry. - **Versioned compatibility handshake.** The daemon and extension advertise a protocol version and capabilities before tool traffic is accepted. A peer from before 3.0 is refused with an actionable error instead of producing unexplained timeouts. - **Consoles and appliances.** A hypervisor web client is an ordinary page to the agent, and the guest behind it is reachable through the same tools — the guest is a canvas, so it needs its own rules for reading, clicking and typing. The field guide is [`docs/esxi-vm-console-automation.md`](docs/esxi-vm-console-automation.md). --- ## How it works Three pieces, all on your machine. Nothing leaves localhost. The daemon control plane is hard-bound to `127.0.0.1`; there is no supported remote/n8n listener. ```mermaid flowchart LR subgraph Client["MCP client (Cursor / Claude / Windsurf)"] A["agent"] end subgraph Thin["thin MCP client — mcp-server/dist/index.js"] B["DaemonClient` and `title: …`, and `loading: true` if the page is still loading at 15 s. A network failure fails `NAVIGATION_FAILED`; with nothing to go back or forward to, `NO_HISTORY_ENTRY`. A frozen tab is replaced: the result has a `note:` line with the new `tabId`, and a failure after the replacement names the new tab too. A cancelled call fails `TIMEOUT`.
### `browser_tabs`
- `action`: `list` (default), `close`, `focus` or `session`. `close` and `focus` need `tabId`.
- `tabId`: the tab to close or focus.
- `browser`: `"auto"` (the default profile) or a browser id, selected for the session before the action runs.
- `isolation` (`session` only): `trusted` (the default) or `isolated`.
- `access` (`session` only): `full` (the default) or `read-only`.
`action: "session"` reads the session's own policy, and changes it when `isolation` or `access` is given. The result is `session policy: isolation=…; access=…`.
- **`trusted` (the default).** The agent may act in any tab, including the user's own, with the user's own logged-in sessions. This is what most work needs: an agent that has to use your signed-in session cannot do it any other way.
- **`isolated`.** The agent may only touch the tabs it opened itself. A call that names another tab fails `TAB_NOT_OWNED`, and the tab list shows the session's own tabs only: the user's are counted, not shown. This is the mode the in-app browser has by construction.
- **`read-only`.** The agent may read, navigate and scroll, but every call that changes something (click, type, fill, page code, a dialog, a mock, an emulation) fails `READ_ONLY` until the session is opened for writing again. Navigation stays allowed: opening a page changes no data.
Both settings are per session and last until the session ends.
`list` prints one line per tab: `123 [own] "Title" host/path`. A tab that one of your tabs opens (a `target="_blank"` link, `window.open`) is yours too; Chrome makes it the active tab, and the tab the user was on is made active again (unless the user was looking at the tab that opened it). `[user, focused]` is the user's focused tab. Tabs that another session owns or drives are not listed: they are counted in one line, `+N tabs used by other agents`. Other user tabs are listed as `[other]`, with title and address. With several profiles connected, a first block lists them and marks the selected one. `close` closes a tab you may act on; `focus` activates the tab and brings its window forward. Another session's tab fails `TAB_LOCKED`.
### `browser_snapshot`
- `tabId` (required).
- `target`: the subtree root to read.
- `query`: keeps the elements that hold every word of the query in their role, name or value (whole-word matches first, else substring matches), with their ancestor lines. `save button` finds `button "Save draft"`.
- `maxChars` (8000; 200–50000): the cut. The last line says how much was left out. Refs past the cut are not issued.
One element per line, indented by depth: `role "name" [e12]`, then state such as `value="…"`, `checked`, `disabled`, `expanded`, `selected`, `level=2`, `required`. Passwords are masked, cross-origin iframes show as `iframe "cross-origin https://…" (not readable)`, and open shadow roots and same-origin iframes are read. Refs (`e`) are stable per element while its page lives.
### `browser_text`
- `tabId` (required); `target` (the element); `maxChars` (20000; 100–100000).
The visible text, in reading order, with hidden text left out, including same-origin iframes and open shadow roots. A `target` that is hidden fails `ELEMENT_HIDDEN`. Over the cap the text is cut with a `… truncated` note.
### `browser_screenshot`
- `tabId` (required); `target` (crop to the element's box); `region` (`{x, y, width, height}` in CSS px, crop to a rectangle).
One JPEG whose longest side is at most 1568 px. A tab that is active in its window is captured from the window; a background tab is captured over CDP without being activated. The text line gives the size, for example `1280x800 jpeg, viewport`. On a frozen tab the call fails `TAB_WEDGED` after 8 s instead of hanging (1.5 s when an earlier call already found the tab frozen).
### `browser_inspect_element`
- `tabId`, `target` (required).
- `properties`: up to 100 style names (`"*"` = all, capped).
- `rules` (false): the CSS rules that match the element, highest priority first, with file:line and the declarations they overrode. Uses the debugger.
- `listeners` (false): the event listeners on the element and on its ancestors, with the script URL and line. Uses the debugger.
With no flags the result is the computed styles that differ from browser defaults, which needs no debugger.
### `browser_safety`
- `enabled` (required): turn the optional safety policy on or off for this MCP session.
- `defaultAction` (`ask`): `allow`, `ask` or `block` for submit, delete and upload actions. Unknown point and drag clicks also use this rule.
- `siteRules` (empty by default): exact host rules as `{"example.com": "allow"}`. A site rule overrides the default.
Settings live for the current MCP session and reset when it ends. `ask` uses MCP elicitation; if the client cannot show a confirmation, the action is refused. The classifier checks native submit controls, common submit labels, file inputs, and common delete/remove labels. Custom page actions may not be recognized, so treat this as a useful guard rather than a complete security boundary.
### `browser_click`
- `tabId`, `target` (required; a point `x,y` is allowed).
- `button`: `left` (default), `right` or `middle`. `count`: 1–3. `modifiers`: any of `Alt`, `Control`, `Meta`, `Shift`.
- `expect`: optional `{urlIncludes, textIncludes}` postcondition. The page is checked after the click returns, and then polled for up to 1.5 s, so a page that redraws a moment later still meets it. A mismatch reports `EXPECTATION_FAILED` (an unavailable snapshot reports `EXPECTATION_UNAVAILABLE`); the click already happened, so inspect the page before retrying. Use `browser_wait` for delayed page changes.
- `observe: "diff"`: include added and removed snapshot lines in the structured receipt.
- `hover` (false): move the pointer only. `dragTo`: a second target; the press is at `target`, the release at `dragTo`, with 10 moves between. Any text selection is cleared before the press, and the tab keeps drawing frames while the drag runs, so a drag in a background tab takes about as long as in a visible one. When the page starts an HTML5 drag (`draggable="true"`, a link, an image), Chrome hands it back instead of starting its own, and the rest of the gesture is sent as `dragenter`, `dragover` and `drop` at the same points; the result then has an `html5:` line. `hover` and `dragTo` cannot be combined.
The target is checked first: hidden, disabled or covered elements fail (`ELEMENT_HIDDEN`, `ELEMENT_DISABLED`, `ELEMENT_COVERED`) and nothing is clicked. A target already in full view is not scrolled. After a scroll, or while a CSS animation or transition runs on the target or an element around it, the target is measured again until it holds still (up to 1 s). The click is a trusted mouse event at the element's centre; a press that lands on another element (the target moved) fails `CLICK_MISSED`, and a press the page never got fails `INPUT_BLOCKED`. Within 300 ms after the press the result reports `navigated: ` or `dialog: ""`, so a click that opens an alert never hangs the call. When the click started a page load that has no response yet, the call waits up to 2 s more for it. A response that is a file (`Content-Disposition: attachment`) adds `download: true (file ); Chrome saves it to the Downloads folder, the tab did not navigate` and a `download` field; a slower navigation is reported as `navigated:`. A point outside the viewport gets a warning line.
### `browser_type`
- `tabId` (required); `target`; `text`; `key`; `clear` (false); `submit` (false); optional `expect: {urlIncludes, textIncludes}` and `observe: "diff"`. Give at least one of `text`, `key`, `clear` or `submit`.
With `target`, the element is focused by a trusted click first if it is not focused yet. Controls a click would change (a slider, checkbox, radio, select, button or link) are focused without a click. Without it, `text` and `clear` go to the focused field (`NO_FOCUS` if none is a field); a `key` alone goes to whatever has focus. `clear` selects all and deletes. `text` is inserted in one step. `key` is one key or a combo (`Enter`, `Tab`, `Escape`, `ArrowDown`, `Control+a`, `Shift+Tab`), or several separated by spaces, pressed in order (`ArrowDown ArrowDown Enter`). Every name is checked before anything is sent: an unknown name fails `UNKNOWN_KEY`. A dialog that a key opens ends the sequence, and the result reads `pressed N of M keys`. In a combo the modifiers are held like a person holds them: each one's own keydown first, its keyup last. `Control+a` and `Meta+a` select all in the focused field on every OS. `submit` presses Enter last. A dialog that the input opens is reported in a `dialog:` line, and the call returns at once. The result gives `typed N chars into ` and `value: "…"` (the first 100 characters; a password field shows `••••`, or `""` when it is empty). A read-only field fails `ELEMENT_READONLY` before anything is typed. Text that leaves the value unchanged fails `VALUE_NOT_SET` with the value the field kept (and its `maxlength` when it is full). A click or key the page never got fails `INPUT_BLOCKED`.
### `browser_fill`
- `tabId` (required); `fields` (1–50 entries of `{target, value}`; `value` is a string, a number, a boolean or an array of strings).
- Optional `expect: {urlIncludes, textIncludes}` checks the resulting page; `observe: "diff"` adds a compact snapshot diff to the structured receipt.
Each field is handled by its kind:
- text inputs, text areas and editable regions: a string is typed in (an empty string clears);
- `select`: a string, or an array for a multiple select. Each value matches an option's value exactly, else its label case-insensitively; a miss fails `OPTION_NOT_FOUND` with up to five labels;
- date, time, datetime-local, month, week, colour and range inputs: the whole value as a string (a number for range), set as the picker sets it. A value the browser rejects (a bad date, an off-step range) fails `VALUE_NOT_SET`;
- checkbox or radio, or an element with role `checkbox`, `radio` or `switch`: a boolean (a radio takes `true` only). The element is clicked only when its state differs. An ARIA widget whose `aria-checked` does not change fails `VALUE_NOT_SET`;
- file input: an array of absolute paths (`~/` is expanded). In a file input, a relative path fails `INVALID_ARGUMENT`. Before anything is sent, the server refuses hidden and credential files: the whole call fails `FILE_NOT_ALLOWED`. The check runs on any field value whose item contains a path separator or starts with `~/`, so a select value such as `/en` is looked at too, but a bare word is not. A symlink is resolved before the check. In a file input, a path that is missing or unreadable fails `FILE_NOT_FOUND`, and nothing is filled.
`browser_fill` never submits. Fields are filled in order, and one failing field does not stop the rest. If any field fails, the result is `FILL_FAILED: n of m fields failed`, with one line per failed field: `target: CODE: message`. Success reads `filled N fields`. A read-only text field fails `ELEMENT_READONLY`, and nothing is typed into it. A text field whose value does not read back (a page that rejects input) fails `VALUE_NOT_SET`, shown as `kept "…"`. A click that focuses a field and never reaches the page fails `INPUT_BLOCKED`. A dialog that a field's input opens stops the fill: the fields after it fail `DIALOG_OPEN`.
### `browser_scroll`
- `tabId` (required); `target`; `dy` and `dx` (pixels).
`target` alone brings the element into view, instantly, without a wheel. With `dy` or `dx` the call sends a real wheel (the tab keeps drawing frames until it settles, so a background tab answers as fast as a visible one) at the target's centre (or the page centre), which needs the debugger (`DEBUGGER_UNAVAILABLE` otherwise). The result reports the scrolled position and whether it reached the end. If nothing moved, the call fails `NOT_SCROLLABLE` and says why: already at that edge, or nothing scrollable there.
### `browser_wait`
- `tabId` (required); exactly one of `target`, `url`, `ms` or `until`; `gone` (false; with `target`); `timeout` (10000; 1–50000).
- `target`: waits until it is visible; with `gone: true`, until it is hidden or removed. Polls the page and its same-origin iframes.
- `url`: a substring of the page address, or a glob over the whole URL when it contains `*`.
- `ms`: a plain delay. It must not be longer than `timeout` (`INVALID_ARGUMENT`).
- `until: "stable"`: waits until the page stops changing. The page is fingerprinted every 100 ms; two identical readings mean it settled. A page that never settles (a clock, a live feed) reaches the timeout and fails `TIMEOUT: the page was still changing after … ms`.
Not met in time fails `TIMEOUT`.
### `browser_evaluate`
- `tabId`, `expression` (required); `timeout` (5000; 1000–30000).
The source is one expression, or statements that `return` a value; top-level `await` works. Statements without `return` give `null`. The value comes back as JSON; DOM nodes, functions and cycles come back as readable descriptions, and long results are cut. It runs over CDP, so the page's CSP does not block it. If the debugger cannot attach, it runs in the page's main world through `chrome.scripting` instead, marked `via: scripting`, which a strict CSP can reject. A throw fails `SCRIPT_ERROR`. A source that closes its wrapper early (for example `1)); f(); ((0`) is refused before it runs, with `SCRIPT_ERROR: … nothing was run`. A run past `timeout` fails `TIMEOUT`: the page may still be running it, but the call returns so the tab is free. A script that opens a JavaScript dialog returns at once with a `dialog:` line: the script stays paused until `browser_handle_dialog` answers the dialog. With a dialog already open, the call fails `DIALOG_OPEN` and nothing runs.
### `browser_handle_dialog`
- `tabId`, `accept` (required, boolean); `promptText` (answer for a prompt).
Answers the alert, confirm or prompt open on the tab. Chrome answers only the debugger session that saw the dialog open, so a dialog that opened before the debugger attached fails `NO_DIALOG`, as does a tab with no dialog. A dialog that is not answered within 3 s fails `TIMEOUT`. The dialog's message is cut at 200 characters in the `dialog:` line and in this result.
### `browser_logs`
- `tabId` (required); `kind`: `console` or `network` (omitted = both); `filter` (a substring of the message text, or of the URL for network); `errors` (false: console errors, and failed or 4xx/5xx requests); `limit` (50; 1–200); `clear` (false); `since` (a request id: only the requests after it); `all` (false: requests of earlier pages too); `requestId` (one request in full); `bodies` (false).
Console lines look like `error 12:01:02 message (src:line)`, with a short stack for errors; uncaught errors and unhandled rejections are included. The console covers the current page since it loaded: the page's own console calls and errors. Messages Chrome writes itself (`Failed to load resource`, CSP and deprecation warnings) are not in it; a failed load shows in the network list.
The network list covers the current page: the requests since its last top-level load. Requests of earlier pages in the tab are counted in a line `… N from earlier pages not shown (all: true lists them)`. The agent already has what it read before, so a later call need not send it again: pass the last id it saw as `since` (`since: "r42"`) to get only the requests after it. Network lines look like `r17 GET 200 xhr 1.2kB 120ms https://…`; a failed request shows its error instead of the status. With `requestId`, the result gives one request: headers (redacted), timing and the payload preview. `bodies: true` with a `requestId` adds the response body, if capture was on. Without a `requestId`, `bodies: true` turns on response-body capture for the tab's later document, XHR and fetch responses, and `bodies: false` turns it off. `clear` cannot be combined with `requestId`, and `since` and `all` apply to the network list only.
### `browser_mock`
- `tabId` (required); `rules` (up to 50 entries; omitted = list; `[]` = clear).
Each rule has `match` (a URL glob with `*`, or a substring), and either `block: true` (the request fails as blocked by the client) or an answer built from `status` (200 by default; 100–599), `body` (up to 20,000 characters) and `headers` (a map of strings). `block` cannot be combined with `status`, `body` or `headers`. A request that matches no rule goes on unchanged; the first matching rule answers.
`rules` replaces all of the tab's rules. Rules apply only while the tab's debugger session is attached: when the user closes the banner, the rules are kept and the list says `inactive (debugger detached)`. Listing shows each rule with its hit count. Rules affect this tab only.
### `browser_emulate`
- `tabId` (required). All other fields are optional and apply to this tab only:
- `viewport`: `{width, height, deviceScaleFactor?, mobile?}` (100–10000 px). It never resizes the user's window.
- `network`: `offline`, `slow-3g`, `fast-3g` or `none`.
- `cpuThrottling`: 1 (off) to 20.
- `geolocation`: `{latitude, longitude, accuracy?}`, or `null` to clear. The tab's debugger cannot grant the geolocation permission, so the page reads the emulated position only when the site already has geolocation allowed in Chrome's site settings. The result says when it does not: `geolocation permission: not decided for this site` (the first request waits on Chrome's prompt for the user) or `blocked for this site` (requests fail with `PERMISSION_DENIED`), with a `permission` field.
- `colorScheme`: `light`, `dark` or `none`. `reducedMotion`: `reduce` or `none`.
- `userAgent`: up to 1000 characters.
- `reset`: `true` clears every override.
The debugger session stays attached while an override is active. If Chrome ends the session anyway (the banner was closed, or DevTools opened), the dropped overrides are reported as `lost` on the next call and are not re-applied. `reset: true` clears every override and reports them: `cleared:`, then one line per override, or `no overrides`. It keeps the debugger attached while a mock or a body capture uses the session. Overrides end with the session that set them: when that session disconnects, or the tab closes, they are cleared. If two sessions set overrides on one tab, the last session that set an override wins.
### `browser_memory`
- `tabId` (required); `kind` (`all`, `facts` or `visits`); `cursor` (from the previous page's `next`).
Read-only. Returns up to 50 notes (4,000 characters) about the origin of the tab's current page, this profile's first. Notes from another profile show the origin and month only and are marked `not verified in this profile`. Fails with `MEMORY_DISABLED`, `MEMORY_EXCLUDED`, `MEMORY_SCOPE_UNKNOWN`, `MEMORY_NOT_SUPPORTED` or `MEMORY_UNAVAILABLE`. See [Website memory](#website-memory-off-by-default).
### `browser_site_map`
- `tabId` or `origin` (exactly one; `origin` is a host such as `shop.example` or an origin such as `https://shop.example`); `query` (words to find, up to 100 characters); `cursor` (from the previous answer's `next`).
Read-only. With `query`, returns up to 20 remembered pages (4,000 characters) whose title, path or control names match, ignoring case and Arabic diacritics, each with its controls, a ready `browser_click` locator, when it was last seen and whether its last use worked. Without `query`, returns an outline of up to 10 lines. A named-origin lookup never reads the browser. Fails with `MEMORY_DISABLED`, `MAP_DISABLED`, `MEMORY_EXCLUDED`, `MEMORY_SCOPE_UNKNOWN`, `MEMORY_NOT_SUPPORTED`, `MAP_UNAVAILABLE`, `MEMORY_CORRUPT` or `INVALID_ARGUMENT`. See [Site map](#site-map-off-by-default-per-browser-profile).
### `browser_memory_policy`
- `action` (required: `enable`, `disable`, `exclude`, `include`, `inspect`, `export`, `delete`, or a site map action: `map_enable`, `map_disable`, `map_exclude_path`, `map_include_path`, `map_inspect`, `map_export`, `map_delete`); `tabId` (required for origin actions, rejected for `enable`, `disable`, `map_enable` and `map_disable`, optional for `map_inspect`, `map_export` and `map_delete`); `path` (map actions only: required for `map_exclude_path` and `map_include_path`, optional for `map_delete`, and it needs a `tabId`).
Asks the owner to change memory or site map policy. The owner confirms in the MCP client; the agent cannot supply the confirmation. Fails with `CLIENT_CONFIRMATION_UNAVAILABLE` or `ACTION_NOT_CONFIRMED` and changes nothing. Not allowed inside `browser_batch`.
### `browser_batch`
- `actions` (required; 1–50 entries of `{tool, params}`; `browser_safety` and `browser_batch` cannot be nested); `tabId` (optional default); `maxChars` (optional; cap on the batch's whole text, default 120 000); `onError` (optional; `stop` — the default — or `continue`).
Steps run in order. By default the batch stops at the first failing step. `onError: "continue"` runs the rest of the steps anyway, and the answer then names every failure (`STEP_FAILED: 2 step(s) failed, 3 completed`) with each one under its own step label; the result is still an error, so the agent knows something went wrong. The whole batch has a 50 s budget, and each step gets at most the time left in it. A step still running when the budget ends is cut off, though it may still finish in the page. The cut reads `step i/n : TIMEOUT: batch budget used; k skipped`. A `tabId` on the batch fills every step that omits its own (not `browser_tabs`). Without one, a step that opens a tab (a `browser_navigate` without `tabId`) becomes the default for the steps after it. A `browser_wait` with only `ms` sleeps inside the batch, capped at 10 s.
Every step's result comes back, each under its own step label — the label line, then the step's own text under it — so a batch never drops what an earlier step read. `structuredContent` carries one entry per step: its number, tool, status and a one-line summary, plus the receipt fields of a click/type/fill. The batch's whole text is capped at 120 000 characters (`maxChars` changes it); past the cap the later steps are cut and the cut is said out loud, so the agent knows to read that step again. Reading several fields of one page in a single `browser_evaluate` costs less than a read step each.
A failure reads `step 2/4 browser_click: ELEMENT_HIDDEN: …; 2 skipped`, with the steps that already ran under it as context. The session's own rules apply to the steps too: a read-only session's batch refuses its writing steps, and an isolated session's batch refuses a tab it does not own.
---
## Migrating from 2.x
3.0 removes the tools below; the replacements are listed in [CHANGELOG.md](CHANGELOG.md) with every other change.
| 2.x | 3.0 |
|---|---|
| `browser_find` | `browser_snapshot {query}` |
| `browser_observe`, `browser_act` | `browser_snapshot` + `browser_click` / `browser_type` / `browser_fill` |
| `browser_click_text` | `browser_click {target: "text=…"}` |
| `browser_hover` | `browser_click {hover: true}` |
| `browser_drag` | `browser_click {dragTo}` |
| `browser_press_key` | `browser_type {key}` |
| `browser_select`, `browser_fill_form`, `browser_upload_file` | `browser_fill` |
| `browser_run_action` | `browser_evaluate` |
| `browser_shortcuts` | `browser_batch` |
| `browser_resize_window` | `browser_emulate {viewport}` |
| `browser_list_browsers`, `browser_select_browser` | `browser_tabs {browser}` |
| `browser_console`, `browser_network` | `browser_logs` |
| `browser_intercept` | `browser_mock` (tab-scoped; no global, DNR, log rules or HAR) |
| `browser_gif`, `browser_webmcp_list`, `browser_webmcp_call`, `browser_tools` | removed |
| `ref` / `selector` / `x`,`y` params | `target` |
| `browser_tabs` create / reload / lock / unlock | `browser_navigate` (no tabId / `url: "reload"`); ownership is implicit |
| `browser_handle_dialog {action}` | `{accept, promptText}` |
Progressive mode (`BROWSER_CONTROLLER_PROGRESSIVE`) is removed; all tools are always listed.
---
## Timeouts and retries
Each tool declares its transport timeout next to its definition (`mcp-server/src/tools/`).
| Timeout | Tools |
|---------|-------|
| 5 s | `browser_handle_dialog` |
| 10 s | `browser_tabs`, `browser_click`, `browser_scroll`, `browser_emulate`, `browser_logs`, `browser_mock` |
| 15 s | `browser_snapshot`, `browser_text`, `browser_screenshot`, `browser_type`, `browser_inspect_element` |
| 20 s | `browser_navigate` |
| 30 s | `browser_fill` (a file set can take a while) |
| 35 s | `browser_evaluate` (always longer than its own `timeout`, up to 30 s) |
| 50 s (batch budget) | `browser_batch`: each step gets at most the time left in the budget |
| 55 s | `browser_wait` (its `timeout` is up to 50 s) |
Only the read-only tools are **retried on timeout**: `browser_snapshot`, `browser_text`, `browser_screenshot` and `browser_inspect_element`. Every other tool is never retried, so a click cannot fire twice.
---
## How Others Compare
| | Browser Controller | Playwright MCP | Chrome DevTools MCP |
| --------------------------------------- | ----------------------------- | ---------------- | ------------------------------------- |
| Uses your existing browser | Yes | No, launches new | Partial, needs debug port |
| Sessions and cookies | Already there | Fresh profile | Manual setup |
| Works behind corporate SSO | Yes | No | Depends |
| Multiple agents, multiple tabs | Yes | No | No |
| Tab targeting (won't hijack active tab) | Yes | N/A | No |
| Authenticated local connection | Yes | N/A | No |
| Setup | Build from source + extension | Headless browser | Chrome with `--remote-debugging-port` |
---
## Configuration
| Env var | Default | What it does |
|---------|---------|-------------|
| `WS_PORT` | `7225` | WebSocket port the daemon uses for the extension connection |
| `MCP_AGENT_NAME` | (auto: IDE name) | Override the agent name shown in the popup (same as `--agent`) |
| `BROWSER_CONTROLLER_DAEMON_MODE` | `spawn` | `connect` (or `managed`): the MCP client only connects to a daemon that a supervisor runs; it never starts one. See `deploy/systemd/` |
| `BC_RATE_LIMIT_PER_MIN` | `120` | Calls per minute per session; `0` disables the limit |
| `BC_RECONNECT_WAIT_MS` | `15000` | Within 60 s of the daemon start or of an extension drop, how long a call waits for the extension before `NOT_CONNECTED` (otherwise 5 s); `0` keeps the 5 s wait |
| `BC_MAX_WS_MESSAGE_BYTES` | `1000000` | Largest extension frame; a bigger response fails that call with `RESPONSE_TOO_LARGE` |
### Daemon state files
The daemon keeps everything in `~/.browser-controller/` (Windows: `%USERPROFILE%\.browser-controller\`):
| File | Purpose |
| ----------------- | ------------------------------------------------------------------------------------ |
| `enrollment.json` | One-time pairing secret for the extension (mode `0600`) |
| `token.json` | Auth token the extension must present on every WebSocket connection (mode `0600`) |
| `daemon.sock` | The IPC socket thin clients connect to (AF_UNIX on mac/linux; named pipe on Windows) |
| `daemon.json` | Daemon metadata (pid, port, start time) — used to detect a running daemon |
| `daemon.log` | Daemon stdout/stderr when started by a client or `daemon:start`; past 5 MB it moves to `daemon.log.1` at the next start |
To fully reset: stop your MCP clients, delete the folder, and the next run recreates it with fresh secrets.
### Reliability
- The daemon is **auto-spawned** the first time any client runs and left running detached. A client that loses it reconnects, and starts it again when none is alive (see [Runtime lifecycle](#runtime-lifecycle-authoritative-daemon)).
- Connection drops use exponential backoff (1s → 30s), ping/pong health checks every 10s; a client that misses 3 pongs is evicted.
- Per-session rate limit of 120 calls/min protects the daemon from a runaway agent loop. Each step of a batch counts as one call.
- Per-tool timeouts (see [Timeouts and retries](#timeouts-and-retries)), co-located with each tool's definition so they can't drift from the registry.
- **Idempotent read tools** (snapshot, text, screenshot, inspect_element) are retried on timeout; **every other tool** is never retried, so a click can't fire twice.
- A browser response over the WebSocket message limit fails that one call with `RESPONSE_TOO_LARGE`; the connection stays up.
- If another process already holds port 7225, the daemon refuses to start rather than killing a process it didn't spawn — it reports the conflict so you can resolve it deliberately.
- **A server-side failure carries a correlation id.** Request-scoped client, daemon and bridge logs share a `cid=…` field, so those lines can be followed together. Unrelated background logs need not carry it, and it is not sent to the extension. The scope prefixes (`[Bridge]`, `[browser-controller-daemon]`) and messages are unchanged.
### Protocol compatibility
After transport authentication, the daemon and the extension each send an explicit protocol version and their capabilities. A peer must advertise the `tools-v3` capability before any tool call is routed to it. There is no legacy window: a peer with no explicit protocol version, or without `tools-v3`, is from before 3.0 and is refused with a clear reason. The same check runs on the IPC socket between the MCP client and the daemon. An explicitly different protocol major is refused. Application-version differences are diagnostic only. Update the server, the daemon and the extension together; see [Updating an existing install](#updating-an-existing-install).
Multiple Chrome profiles
Run two daemons on different ports by setting `WS_PORT` per client:
```json
{
"mcpServers": {
"browser-work": {
"command": "node",
"args": ["/path/to/browser-controller/mcp-server/dist/index.js"]
},
"browser-personal": {
"command": "node",
"args": ["/path/to/browser-controller/mcp-server/dist/index.js"],
"env": { "WS_PORT": "9333" }
}
}
}
```
Update the port in each extension popup to match.
---
## Architecture
Everything stays on your machine. The extension connects to the daemon via an authenticated WebSocket on localhost; MCP clients connect to the daemon via a local IPC socket. No cloud, no proxy, nothing leaves your browser.
```
browser-controller/
├── mcp-server/ MCP server (TypeScript)
│ └── src/
│ ├── daemon.ts Single multi-client daemon (owns WS :7225)
│ ├── daemon-config.ts IPC protocol, paths, auth/enrollment tokens
│ ├── index.ts Thin stdio MCP client (spawns daemon, multiplexes)
│ ├── bridge.ts Extension WS server + cross-platform port probe
│ ├── register-tools.ts Tool registration and argument validation
│ ├── native-host.ts Native messaging pairing helper (npm run setup:pairing)
│ ├── core/ Neutral base layer: the type guards, the error-code registry, the
│ │ shared JSON store, the bounded queue engine, the logger
│ ├── protocol/ The wire contract: the protocol version and capabilities, the frames,
│ │ the handshake proofs, the wire tool names
│ └── tools/ The tool definitions (schema, description, timeout), one file per family
├── extension/ Chrome extension (Manifest V3, plain JS, ES modules)
│ ├── background.js Wiring only: inject router, register events, connect
│ ├── lib/ state (buffers/ownership/persistence), connection (WS lifecycle),
│ │ router (dispatch + mutex/ownership + control shield), page-exec,
│ │ page-dom (refs and target resolution), trusted-input (CDP input),
│ │ cdp-session, overlay, tab-concurrency (pure, unit-tested)
│ ├── handlers/ One module per tool family: navigation, interaction, interaction-advanced,
│ │ inspection, evaluate, inspect, screenshot, tabs, emulate, logs, mock, cdp
│ ├── utils/ navigation helpers
│ ├── events.js chrome.* listeners (popup, webRequest, lifecycle)
│ └── popup/ Side panel (Tabs · Agents · Activity · Tasks · Settings)
├── agent-config/ Pre-built configs for Cursor + Claude Code
│ ├── cursor/ Rules and commands
│ ├── skills/ Browser automation skill
│ └── setup.mjs One-command installer
└── tests/ Vitest suites (run npm test)
```
**Stack:** TypeScript (strict) · MCP SDK · WebSocket · Chrome Extension Manifest V3 · Vitest
### Layers
The server is layered, and the boundaries are checked instead of agreed:
- **`core/` is the base layer.** It may depend on the node builtins and on `core/` siblings only — the tools, memory, vault and wire layers all sit above it. It holds the shared mechanics: the type guards, the error-code registry, the atomic-write and owner-only file engine, the bounded queue engine and the logger.
- **`protocol/` is the wire contract.** It owns the protocol version, the capabilities, the frames, the handshake proofs and the tool names, and it may not import the tools, memory or vault layers: the transport can be read without knowing what the tools do.
- **`tools/` sits above the wire.** It may not import `protocol/` or the transport modules, and neither `memory/` nor `vault/` may import `tools/`.
- **`vault/` does not depend on `memory/`.** The credential vault used to reach into the memory layer for a check that had nothing to do with memory; both use the neutral `core/` layer now.
`npm run arch:check` proves those boundaries from the real import graph, and `npm run lint` enforces the same ones as `no-restricted-imports` rules, so a wrong dependency fails the build instead of waiting for a review to notice it.
The architecture decisions are indexed in [`docs/adr/README.md`](docs/adr/README.md), and the remediation that produced this layout is written up in [`docs/audit/14-remediation-report.md`](docs/audit/14-remediation-report.md). Both are written in Arabic. The [emergency exception runbook](docs/emergency-bypass.md) describes the owner-controlled process for an exception to `main` protection.
### Life of a tool call
```mermaid
sequenceDiagram
autonumber
participant C as MCP client
participant W as wrapHandler — register-tools.ts
participant DC as DaemonClient — index.ts
participant DM as daemon — daemon.ts
participant BR as ExtensionBridge — bridge.ts
participant RT as router.js — extension
participant H as handler + safeExec
C->>W: tool call (JSON-RPC over stdio)
W->>DC: host.callTool(name, params)
DC->>DM: { kind: "call", id, tool, params } over the IPC socket
DM->>DM: rate-limit check + AbortController (per-tool timeout)
DM->>BR: bridge.callTool(tool, params, sessionId)
BR->>RT: WS { id, tool, params, sessionId, agentName }
RT->>RT: per-tab mutex + ownership check + control shield
RT->>H: dispatch to the handler for the tool
H->>H: page function via chrome.scripting, or CDP input and evaluate
H-->>C: result returns along the same path (failures as isError results)
```
Every hop is authenticated (IPC socket and WebSocket both require the token) and bounded (per-session rate limit, per-tool timeout). The extension connection also completes the version/capability handshake before tool frames are routed. Only the read-only tools are retried on timeout, so a click can never fire twice. See [Reliability](#reliability) for the full list.
## Development
```bash
git clone https://github.com/compnew2006/browser-controller.git
cd browser-controller
npm install
npm run build
npm test
npm run lint
npm run arch:check
npm run test:coverage
npm audit --omit=dev
```
| Command | What it does |
|---------|---------|
| `npm run build` | Compile TypeScript → `mcp-server/dist/` |
| `npm run dev` | Watch mode |
| `npm test` | Run the full test suite |
| `npm run test:coverage` | Run the suite with coverage over the whole production surface (`mcp-server/src/**/*.ts` and `extension/**/*.js`), with the thresholds pinned at the coverage the tree actually reaches — a ratchet on reality, not a target |
| `npm run lint` | Lint the TypeScript server, extension, and tests with zero warnings allowed; the layering boundaries are enforced here too |
| `npm run arch:check` | Run the architectural fitness functions: the layering boundaries are proved from the real import graph, so a wrong dependency fails the build |
| `npm run release:check -- vX.Y.Z` | Read an annotated local tag and check its versions, version-setting commit, and tagged changelog notes without publishing |
| `npm run typecheck` | Type check without emitting |
| `npm run smoke:ci` | Test an authenticated WebSocket handshake and browser tool roundtrip with a disposable daemon, Chromium profile, extension copy, and synthetic page; the native pairing host is not exercised |
| `npm run smoke:real-chrome` | Against your own Chrome (extension enrolled, after `npm run build`): restarts the daemon, then checks snapshot, click, type, logs, upload and the five drags of [`scripts/pages/drag-and-drop.html`](scripts/pages/drag-and-drop.html). HTML5 drag and drop depends on the operating system, so run it on Windows, macOS and Linux. You can also open that page and drag by hand: it judges each drag itself. |
| `npm audit --omit=dev` | Check the installed production dependency graph for known vulnerabilities |
| `npm run setup:cursor` | Install Cursor rule + command |
| `npm run setup:claude` | Install Claude Code `AGENTS.md` |
| `npm run setup:pairing` | Register the native messaging pairing helper so the extension pairs itself |
| `npm run pairing:status` | Show which browsers the helper is registered with and the extension ID it allows |
| `npm run pairing:uninstall` | Remove the helper registration |
The suite covers the WebSocket bridge (including token-auth rejection and the unified error channel), the tool registry, daemon lifecycle (heartbeat eviction, rate limiting, IPC auth), per-tab concurrency (same-tab serialization + cross-tab parallelism), and extension behavior via a mocked `chrome` API (router dispatch, shield semantics, evaluate round-trip, iframe piercing, dialog rescue). CI runs the suite on the declared minimum and latest Node 22, 24 and 26 releases, plus the architecture check, CodeQL and Scorecard scans.
### Updating an existing install
```bash
git pull
npm install
npm run build
```
Then two manual steps: **reload the extension** in `chrome://extensions` (a running service worker never picks up file changes by itself), and **restart the daemon** — it's long-lived and doesn't reload `dist/` either (kill it, or just restart your MCP client, and the next run respawns it on the new build).
Coming from a version without automatic pairing? Run `npm run setup:pairing` once before reloading the extension (see [Pair the extension with the daemon](#4-pair-the-extension-with-the-daemon)). A secret you pasted earlier keeps working.
The MCP clients, the daemon and the extension must all be 3.0. After you pull the update, stop the old daemon, restart your MCP clients so the 3.0 daemon starts, and reload the extension. A pre-3.0 peer is refused with one of these reasons:
- A 3.0 MCP client meets a running 2.x daemon: `The running Browser Controller daemon is older than 3.0: stop it (npm run daemon:stop, or end the pid in its daemon.lock), then restart your MCP client so the 3.0 daemon starts.`
- A 2.x MCP client meets a 3.0 daemon: `This MCP client is older than 3.0: restart your MCP client so it starts the 3.0 client.`
- A 3.0 extension meets a 2.x daemon: `The Browser Controller daemon is older than 3.0: restart your MCP client so it starts the 3.0 daemon.`
- A 2.x extension meets a 3.0 daemon: `The Browser Controller extension is older than 3.0: reload it at chrome://extensions.`
If the popup reports an incompatible protocol, a missing capability, or repeated handshake timeouts, the server and extension are usually from different checkouts/builds:
1. Run `npm install && npm run build` in the repository used by your MCP configuration.
2. Stop the existing daemon or all MCP clients that own it, then restart the MCP client so a daemon starts from the new `dist/` output.
3. Open `chrome://extensions`, find Browser Controller, and click **Reload** so Chrome replaces the long-lived MV3 service worker.
4. Reopen the popup. If authentication rather than compatibility is failing, check `npm run pairing:status` and the port, or re-enter the enrollment secret; do not paste secrets into issue reports.
Restarting only one side is not sufficient after a protocol-changing update. Application-version differences can be harmless, but an explicit protocol-major mismatch will stay disconnected until the stale daemon or extension is replaced.
---
## FAQ
Does it work with my logged-in sessions?
That's the whole point. The extension runs inside your actual Chrome — same cookies, same sessions, same local storage. No re-authentication needed.
Does it send data anywhere?
No. The MCP clients, the daemon, and the extension all talk over localhost (IPC socket + WebSocket). Nothing leaves your machine. There's no analytics, no telemetry, no cloud component. See [SECURITY.md](SECURITY.md) for the threat model, auth design, and the first-contact window.
Which AI clients work?
Any MCP-compatible client. Cursor, Claude Desktop, Claude Code, Windsurf, Cline, and anything else that speaks the MCP protocol. Several of them can run at once against the same daemon.
Can two agents really work at the same time without breaking each other?
Yes. Each agent connects to the shared daemon, gets its own `sessionId`, and targets a specific `tabId`. Actions on the same tab serialize through a per-tab mutex; actions on different tabs run in parallel. A tab that one session opens with `browser_navigate` is owned by that session: another session's call on it fails at once with `TAB_LOCKED` until the tab closes.
What if the agent acts on the wrong tab?
It can't — not silently. Every page tool requires a `tabId`, and if it's missing you get a clear `tabId is required` error. The agent can never accidentally act on the tab you happen to be looking at. `browser_navigate` without a `tabId` opens a new background tab for the session rather than acting on the active one.
Why are there two secrets (enrollment + token)?
Without them, any local process on your machine could open a WebSocket to port 7225 and drive your authenticated browser sessions (your bank, your email, your company SSO). The enrollment secret pairs the extension with the daemon out-of-band, before any WebSocket exists — delivered by the local pairing helper (`npm run setup:pairing`) or pasted by hand; the auth token, which the extension then fetches with it, authenticates every connection. Both live in `~/.browser-controller/` with mode `0600`.
How is this different from Playwright MCP or browser-use?
They launch a new browser instance from scratch — no state, no cookies, no sessions. You have to replay the full login flow every time. This connects to the browser you already have open with everything already loaded.
---
## Contributing
Bug reports, feature requests, and PRs are welcome at [the issue tracker](https://github.com/compnew2006/browser-controller/issues). Open an issue first for larger changes.
## Security
See [SECURITY.md](SECURITY.md) — localhost-only architecture, token + enrollment design, threat model, and reporting guidance.
## License
[MIT](LICENSE)