Skip to main content
Glama
README.md
# Browser MCP

Browser MCP gives a local agent its own background browser. The agent reads structured page text and acts on element references. It can ask for a normal-size window when a person needs to sign in or complete a visual interaction.

The server is written in TypeScript and speaks MCP over stdio. Each client gets its own browser sessions. The desktop targets are macOS, native Windows and Omarchy (Wayland/Hyprland).

## Status

Version 0.1.0 is the first public release.

| Platform | State |
| --- | --- |
| macOS | Verified with all five engines, including handoff and the desktop host |
| Windows (GitHub Copilot desktop app) | Supported target. Needs verification on a Windows desktop |
| Omarchy (Wayland/Hyprland) | Supported target. Needs verification on an Omarchy desktop |

Please report results from Windows and Omarchy. See [CONTRIBUTING.md](CONTRIBUTING.md).

## Install from source

Install Node.js 22.13 or later, then run:

```sh
git clone https://github.com/kh4rit/browser-mcp.git
cd browser-mcp
npm ci
npm run build
node dist/cli.js install desktop
```

To install it as a command instead, pack the checkout and install the archive. The commands below then start with `browser-mcp` in place of `node dist/cli.js`.

```sh
npm pack
npm install -g ./browser-mcp-local-0.1.0.tgz
browser-mcp install desktop
```

The default `desktop` engine uses Electron’s Chromium runtime. The install command fetches the runtime for the current platform. On Omarchy, start the client in your graphical login session so the handoff window can use the Wayland display. The server sizes the window to the primary work area and lets Hyprland place it. On Windows, use a native Windows Node installation and a local session in the GitHub Copilot desktop app.

| Engine | Runtime |
| --- | --- |
| `desktop` (default) | Managed Chromium in Electron, with a native window around the live document |
| `chrome` | Installed Google Chrome stable |
| `edge` | Installed Microsoft Edge stable |
| `chromium` | Playwright Chromium. Install with `node dist/cli.js install chromium` |
| `webkit` | Playwright’s WebKit build. Install with `node dist/cli.js install webkit`. This targets Safari’s engine and uses a separate browser profile |

For the desktop engine, handoff makes the live document visible in its native window. The other engines keep the original tab running and stream its view to a local human-only window during handoff. That separate window forwards pointer and keyboard input. Its frames stay on the machine and consume zero model image tokens. Use the desktop engine for workflows that depend on native browser or OS dialogs.

For Chrome and Edge, install the browser from its vendor. Playwright publishes builds for specific OS versions. The Omarchy target uses Chromium-based browsers; availability of additional engine binaries depends on upstream build support. [Playwright browser documentation](https://playwright.dev/docs/browsers)

## Connect a client

Run the config command from the built checkout. It prints an entry containing the absolute Node and server paths for this installation, including the correct JSON escaping on Windows. Merge the entry with existing servers. Keep the checkout at that location while the client uses it.

| Client | Command | Where the output goes |
| --- | --- | --- |
| Claude Code CLI | `node dist/cli.js config claude` | Project `.mcp.json` |
| Codex CLI | `node dist/cli.js config codex` | User `~/.codex/config.toml` |
| GitHub Copilot desktop app on Windows (primary) | `node dist/cli.js config copilot` | User `%USERPROFILE%\.copilot\mcp-config.json`. Open a **local** agent session and check Customize → MCP or Installed |
| GitHub Copilot CLI on macOS or Omarchy | `node dist/cli.js config copilot` | User `~/.copilot/mcp-config.json` |

Restart or refresh the client after adding the entry. The entry is named `browser-mcp`; some model providers reserve the bare name `browser` and reject requests from a server that uses it. Ask the client to use the `browser-mcp` server to open a public page, find a heading and follow a link. [Claude Code MCP setup](https://code.claude.com/docs/en/mcp) · [Codex MCP setup](https://developers.openai.com/codex/mcp/) · [GitHub Copilot app MCP support](https://docs.github.com/en/copilot/how-tos/github-copilot-app/customize-github-copilot-app) · [Copilot CLI setup](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers)

### Clients without desktop access

For a client that can reach localhost but cannot launch graphical applications, start the browser host from a terminal in your signed-in desktop session. Leave it running while clients use it.

```sh
node dist/cli.js host
```

Generate the client configuration with `node dist/cli.js config codex --host` (or substitute `claude` or `copilot`). The configured client starts a small stdio connector. Browser processes and handoff windows run under the desktop host. Closing a connector releases that client's sessions. Ctrl+C stops the host and checkpoints named profiles.

The host listens only on IPv4 loopback. Host and connector authenticate each other with a TLS pre-shared key in the OS user's browser-mcp data directory, under `host/connection.key`. Use the same OS account and data directory for both. The default port is 43971. To select a different port, append it to both `host` and `config … --host`. The host starts browsers on demand.

## Tools

| Tool | Purpose |
| --- | --- |
| `browser_open` | Start a background session, optionally with an engine, a named profile or data copied from another session |
| `browser_list` | List sessions, pages (including popups) and who has control |
| `browser_navigate` | Go to an HTTP(S) URL and read the page |
| `browser_read` | Read the page as compact text, search it, or scan ahead through lazy content |
| `browser_act` | Click, fill, select, check, uncheck, hover or press a key on an element reference |
| `browser_scroll` | Reveal more of the document or a nested scroll container |
| `browser_handoff` | Show the live page to the user in a normal-size window until they choose **Done** |
| `browser_copy_cookies` | Copy cookies for chosen sites between two sessions |
| `browser_save` | Checkpoint a named profile now |
| `browser_close` | Close a session and save its profile |

An agent that also has a web fetch tool or another browser may not choose this server by itself. To direct it, add a line such as this to the agent's instructions:

```text
Use the browser-mcp server for web pages that need interaction or sign-in. Read with browser_read and a query instead of taking screenshots. Call browser_handoff when a sign-in or a visual control needs me.
```

## Working with pages

1. Call `browser_open` with a URL and optional engine. The response includes the session ID, page ID and an observation revision. The default virtual viewport is 1440 × 2400 CSS pixels. Set `width` and the initial `height` at open to select a different layout. Full observations grow the viewport up to 8192 pixels high.
2. Use `browser_read` with a search term or element reference to narrow the result. For virtualized content, pass a query and `scanSteps` to search ahead by up to that many viewport heights. A scan reports the number of steps, scroll extent and reason it stopped. Include a ref and revision to scan a nested container. Continue a long response using its offset and revision. General observations omit editable field values. A scoped read can show an ordinary field value when its purpose is identifiable. `browser_scroll` advances a document or nested container to expose lazy or virtualized content. Read and act on a virtualized row before scrolling it away.
3. Pass the page ID, reference and observed revision to `browser_act`. Actions include click, fill, select, check, uncheck, hover and keypress. Refresh the observation after a stale reference. `browser_list` discovers popups.
4. Call `browser_handoff` for sign-in or visual controls. The agent’s page operations stop while the user has control. After the user selects **Done**, check `browser_list` and read the page again. Handoff requires a graphical desktop available to the server process.
5. Call `browser_close` when finished. Disconnecting the MCP client also closes its sessions.

For example, if the open result identifies session `s1`, page `p1`, revision `3` and a button with reference `[e4]`, the click arguments are:

```json
{"session":"s1","page":"p1","revision":3,"ref":"e4","action":"click"}
```

On the 500-order unit fixture, a bounded initial read followed by the submit result used 1,850 tokens of tool-response text. Returning the entire page both times used 11,062. The post-submit change alone used 29 tokens. These measurements use the `o200k_base` tokenizer and exclude client prompts and tool definitions.

The agent interface returns text. Images, canvas drawings, protected media and custom controls can lack accessible content. Human handoff is available for these cases. An oversized viewport and incremental scrolling expose more content, subject to what the site renders.

## Saved sessions and copying cookies

Open with `"profile": "daily"` to persist cookies (including session cookies), local storage and supported IndexedDB data. Open the same name later to restore the checkpoint. A profile admits a single writer across clients. Profiles checkpoint after opening, navigation, successful actions, completed handoff, explicit `browser_save` and graceful close. Data created after the last checkpoint can be lost on a forced termination.

```json
{"source":"s1","destination":"s2","sites":["https://app.example.com"]}
```

Pass these fields to `browser_copy_cookies` to merge matching cookies into a second open session. The result reports counts. Site selection respects cookie domain, secure transport and partition scope; include the partition’s top-level site when needed. Matching cookie keys replace previous values. Some sites bind sign-ins to a device, engine or other storage.

To seed a fresh session with both cookies and selected origins’ local storage and IndexedDB, pass `copyFrom` to `browser_open`:

```json
{"engine":"desktop","copyFrom":{"session":"s1","sites":["https://app.example.com"],"includeStorage":true}}
```

Session IDs are local to one server connection. To move between MCP clients, close a named profile and reopen it from the other client. The server only manages sessions that it created.

Profile checkpoints contain authentication secrets. They live in the OS user data directory (`~/Library/Application Support/browser-mcp` on macOS, `%LOCALAPPDATA%\browser-mcp` on Windows, and `$XDG_DATA_HOME/browser-mcp` or `~/.local/share/browser-mcp` on Linux). Keep this directory private to your OS account. `BROWSER_MCP_DATA_DIR` overrides the location. Explicit transfer returns counts; cookie values stay inside the browser service.

## Troubleshooting

| Symptom | What to do |
| --- | --- |
| The server reports that it cannot reach the desktop session | The client runs in a sandbox without access to your graphical login. Run `node dist/cli.js check-desktop` to confirm, then use the desktop host described under "Clients without desktop access" |
| The handoff window does not appear | Start the client, or the desktop host, from your graphical login session. On Omarchy the process needs `WAYLAND_DISPLAY` |
| `browser_close` is refused | The user has control. Choose **Done** or close the handoff window first |
| An action reports a stale reference | The page changed. Read it again and use the new revision |
| An engine fails to start | Install it: `install desktop`, `install chromium` or `install webkit`. Install Chrome or Edge from the vendor |
| A named profile is busy | Another client has it open. A profile admits one writer at a time |

## Development

```sh
npm ci
npm test
npm pack --dry-run
```

The default tests exercise the MCP protocol, profile locking, semantic observations, stale references and handoff ownership without launching browsers. `npm run test:native` is a separate desktop acceptance suite. It opens a local fixture and briefly activates a window to test focus and sign-in. It runs suites sequentially and stops at the first failure. Install the desktop runtime and Playwright Chromium before selecting this suite.

Run `node dist/cli.js check-desktop` to check desktop visibility without starting a browser. The native suite runs this check first. On macOS, the server checks for a visible login session before launching a browser from a known Codex Seatbelt sandbox. When that check fails, it returns a diagnostic before starting the application. After a fatal native startup error the server pauses further launches for that MCP process.

On macOS, run `./test/Verify\ on\ macOS.command` from the project directory in Terminal, or double-click the file in Finder. It tests the desktop runtime, installed Chrome and Edge, and Playwright Chromium and WebKit. It also exercises human handoff with Chrome and WebKit. The run saves a private log under `test-results/`. Install all five runtimes before running this matrix.

For a custom native run, `BROWSER_MCP_TEST_ENGINES` and `BROWSER_MCP_TEST_ENGINE_HANDOFF` accept comma-separated engine names for the browser and human-window tests. `BROWSER_MCP_TEST_ENGINE` selects the additional engine for the stdio session test, which always covers the desktop adapter. The Windows GitHub Copilot GUI and Omarchy compositor require verification on their respective desktops.

Licensed under MIT. Dependency and browser distribution notices are listed in [NOTICE.md](NOTICE.md).

TDQS

B3.4/5.0

Scored across 10 tools

Disambiguation4/5

Most tools have clearly distinct roles: session lifecycle, navigation, reading, acting, scrolling, handoff, cookie copying, and checkpointing. There is minor overlap between browser_read and browser_scroll for revealing content, and between browser_save and the automatic checkpointing on browser_close, but descriptions clarify the boundaries.

Naming Consistency5/5

All tools use the same browser_ prefix with snake_case verbs, producing a predictable and consistent naming pattern throughout the set.

Tool Count5/5

Ten tools is well-scoped for a browser automation server. Each tool covers a meaningful lifecycle or interaction capability without obvious redundancy.

Completeness4/5

The surface covers session management, navigation, reading, acting, scrolling, handoff, cookie transfer, and profile checkpointing/close. Minor gaps remain around explicit tab/page switching, screenshots or visual inspection, and waiting/synchronization helpers, but core browser workflows are covered.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues