Skip to main content
Glama
1password-browser-mcp

1password-browser-mcp

README.md
![1password-browser-mcp: an MCP agent filling a sign-in form with a login from 1Password](docs/media/cover.svg)

# 1password-browser-mcp

**A browser MCP server that signs in with 1Password.** It drives your own Chrome or Brave profile
(cookies, sessions, extensions) and fills logins and one-time codes read from 1Password through its
SDK and a service account, without the credential ever reaching the model, and without the warnings
or refusals other browser MCPs add around sign-in. On top of that it offers
the usual browsing tools for an MCP client (Claude Code, Claude Desktop, Cursor, ...): navigate,
snapshot with element refs, click, type, screenshots, console, network, tabs, dialogs, uploads, JS eval.

Runs on macOS and Linux (Chrome, Chromium, Brave, Edge; headless or with a display). Requires Node 20+.
Only the macOS focus hand-back is platform-specific. See [Linux](#linux) for details.

## How it works

Chromium 136+ refuses `--remote-debugging-port` on the default profile directory, so the server
does not touch your running browser. Instead, in the default **mirror** mode it:

1. copies the identity-bearing parts of your profile (cookies, local/session storage,
   IndexedDB under a size cap, extensions and their state, saved logins, preferences) into
   `~/.browser-mcp/profiles/<browser>/` (first run ~10 s for a 2 GB profile, incremental after),
2. launches a second instance of the real browser binary on that copy with the DevTools port open,
3. connects over CDP with `playwright-core`.

Caches, service-worker caches and huge IndexedDB origins are skipped. Chromium encrypts cookies with
a key in the macOS Keychain (on Linux: the GNOME Keyring / KWallet entry, or a fixed key when no
keyring is in use) that is shared by binary, so the copied sessions decrypt and work. Sync is
disabled in the mirrored instance so nothing it does is pushed back to your account.

The browser outlives the server: a restarted server simply re-attaches, so logins persist across
client sessions. `browser_close` with `kill=true` quits it.

### Windows and focus

On macOS the mirrored instance is launched in the background (`open -g -n`) and, because Chromium
activates itself when its first window appears, the server hands focus back to whatever app you were
using. On Linux the binary is spawned directly and the window manager decides where the new window
goes. Every page the tools open afterwards is a **tab in that one window**; nothing raises the
window unless you ask for it (`browser_tabs select focus=true`).

All driven tabs are kept in one **highlighted tab group** (default title "Claude", colour purple;
`BROWSER_MCP_TAB_GROUP_TITLE`, `BROWSER_MCP_TAB_GROUP_COLOR`, or `BROWSER_MCP_TAB_GROUP=false`).
The DevTools protocol has no tab-group API, so the server evaluates `chrome.tabGroups` calls inside
an extension service worker. It uses any installed extension that declares the `tabGroups`
permission (Claude in Chrome, ChatGPT, ...) or the bundled `extension/` helper. The helper is passed
with `--load-extension`, which current Chrome and Brave ignore; if no suitable extension is in your
profile, load the helper once in your daily browser (`chrome://extensions`, Developer mode, Load
unpacked, pick `extension/`) and the mirror inherits it. `browser_status` reports which extension
does the grouping.

In `auto` mode the server picks a browser that is **not running right now** (with Brave open it
drives Chrome, and vice versa; "running" is read from the profile's `SingletonLock`). A second
instance of your daily browser works too (`BROWSER_MCP_BROWSER=brave`), but on macOS it shares the
bundle id with the one you are using, and macOS then routes links clicked in other apps to whichever
instance it last registered, which is often the mirrored one.

Other modes: `attach` connects to any browser you started yourself with
`--remote-debugging-port=9333 --user-data-dir=<non-default dir>`; `direct` launches on the real
profile dir (works only on browsers that still allow it, and only when that browser is not running).

## Several agents at once

Every MCP client starts its own server process; this is how they share or split the browser:

- **shared** (default): all servers attach to one browser instance. Each session owns only the tabs
  it opened: `browser_tabs` lists and indexes just those, `browser_snapshot` and friends act on the
  session's active tab, and the session's tabs live in their own tab group ("Claude", "Claude 2", ...
  or `BROWSER_MCP_SESSION_NAME`, each with its own colour). `browser_tabs all=true` shows every tab
  in the browser, and selecting one of another session's tabs adopts it. When a server exits its tabs
  are closed (`BROWSER_MCP_KEEP_TABS=true` keeps them). A launch lock makes sure servers starting at
  the same moment bring up a single browser.
- **isolated** (`BROWSER_MCP_SESSIONS=isolated`): each server launches its own browser on its own
  profile copy (`~/.browser-mcp/profiles/<browser>-<session>`) and its own port (first free one above
  `BROWSER_MCP_PORT`). Cookies and extensions are the same, but tabs, windows and extension state are
  separate, so agents cannot see or disturb each other. On exit the browser is quit and the copy
  removed unless `BROWSER_MCP_ISOLATED_KEEP=true`.

A registry in `~/.browser-mcp/sessions/` numbers live sessions; `browser_status` lists the others.

## 1Password

The server reads items through the official [1Password SDK](https://developer.1password.com/docs/sdks/)
with a [service account](https://developer.1password.com/docs/service-accounts/) token in
`OP_SERVICE_ACCOUNT_TOKEN`. That is headless by construction: no desktop app, no browser extension, no
CLI, no Touch ID or unlock prompt, no extra tabs. A fill takes about a second; the first call of a
server process spends another second or two authenticating.

- `onepassword_fill` detects the username, password and one-time-code fields on the active tab, picks
  the Login item whose website matches the page (or the one named with `item=<title or id>`), and types
  the values. `submit=true` presses Enter and waits for the navigation. `dryRun=true` reports the item
  and fields without filling. Pass `usernameRef` / `passwordRef` / `otpRef` from a snapshot when
  detection picks the wrong field. For multi-step forms call it again on the next step.
- `onepassword_otp` fills the current TOTP code of the matching item.
- `onepassword_items` lists matching items (title, vault, id, websites); `onepassword_status` reports
  whether the token works and which vaults it can read.

Credential values are never returned to the caller; results only say which fields were filled.
Extension pages (wallet unlock screens, `chrome-extension://...`) and browser UI pages have no site to
match, so name the item there; field detection falls back to Playwright locators because such pages
often block page scripts (MetaMask's LavaMoat). Password and Crypto Wallet items are searched as well
as Logins.

### Service account

A service account can only read the **shared vaults** you grant it, never your Personal or Private
vault, so put the logins the agent may use into a dedicated vault and grant `read_items` only. `BROWSER_MCP_OP_VAULTS` narrows the server further to a comma-separated allowlist of
vault titles or ids. The token is a long-lived secret: 1Password prints it once, so keep it in your
keychain or in 1Password itself, not in a config file. Service accounts also have hourly and daily
request limits.

Create one from a CLI that is signed in through the app (one Touch ID prompt):

```bash
op service-account create browser-mcp --account my.1password.com --vault "<vault>:read_items"
```

Then put the token in the server's environment, e.g. in the MCP client config
(`"env": { "OP_SERVICE_ACCOUNT_TOKEN": "ops_..." }`) or, on macOS, from the login keychain:

```bash
security add-generic-password -a "$USER" -s browser-mcp-op-service-account -w "ops_..."
export OP_SERVICE_ACCOUNT_TOKEN="$(security find-generic-password -a "$USER" -s browser-mcp-op-service-account -w)"
```

Without a token the browser tools work as usual and the `onepassword_*` tools return a clear error.

## Skills

`skills/wallet-test/SKILL.md` is a Claude Code skill for wallet / dapp QA: it unlocks a dedicated
**test** wallet extension (MetaMask or Rabby) from a 1Password item whose title starts with `TEST`,
then drives a dapp through connect, sign and approve prompts on a testnet, answering the wallet's
notification tabs as they appear. Copy the folder to `~/.claude/skills/wallet-test/` and invoke it
with `/wallet-test "TEST MetaMask" https://your-dapp.example`. The file also describes the one-time
test-wallet setup; keep real wallets in a profile the server never mirrors.

## Install

```bash
git clone https://github.com/marekkirejczyk/1password-browser-mcp.git
cd 1password-browser-mcp && npm install && npm run build
```

Claude Code:

```bash
claude mcp add --scope user browser -e BROWSER_MCP_BROWSER=chrome -- node /absolute/path/to/1password-browser-mcp/dist/index.js
```

Claude Desktop / any JSON config:

```json
{
  "mcpServers": {
    "browser": {
      "command": "node",
      "args": ["/absolute/path/to/1password-browser-mcp/dist/index.js"],
      "env": { "BROWSER_MCP_BROWSER": "chrome" }
    }
  }
}
```

Diagnostics: `node dist/index.js doctor` (add `--launch` to also sync, launch and connect).
Manual tool calls: `node scripts/mcp-client.mjs '[["browser_status",{}],["browser_navigate",{"url":"https://example.com"}]]'`.
End-to-end check of every tool against a live server: `BROWSER_MCP_HEADLESS=true node scripts/smoke.mjs`
(needs network access to example.com and the-internet.herokuapp.com; `--keep` leaves the browser running).

## Linux

Tested on Linux with Google Chrome (headless, and headful under `xvfb-run`). What differs from macOS:

- **Detection.** Binaries are looked up on `PATH` (`google-chrome`, `google-chrome-stable`,
  `chromium`, `chromium-browser`, `brave-browser`, `brave`, `microsoft-edge`, ...). Profiles are read
  from `$XDG_CONFIG_HOME` (default `~/.config`): `google-chrome`, `chromium`,
  `BraveSoftware/Brave-Browser`, `microsoft-edge`; Snap (`~/snap/chromium/common/chromium`) and
  Flatpak (`~/.var/app/<id>/config/...`) locations are used when they exist. Override with
  `BROWSER_MCP_EXECUTABLE` / `BROWSER_MCP_USER_DATA_DIR`.
- **No display.** Without `DISPLAY` or `WAYLAND_DISPLAY` the launch fails fast with a clear message;
  set `BROWSER_MCP_HEADLESS=true` (`--headless=new`, extensions still load) or run the server under
  `xvfb-run`. 1Password fills need no window.
- **Root / containers.** Chromium refuses to start as root and its sandbox usually cannot be set up
  in containers, so the server adds `--no-sandbox` when it runs as root or detects a container
  (`/.dockerenv`, `/run/.containerenv`, cgroup names), plus `--disable-dev-shm-usage` in containers.
  Passing `--no-sandbox` yourself in `BROWSER_MCP_ARGS` is still fine (it is not duplicated).
- **Pid lookup** for a browser the server re-attaches to uses `lsof`, then `/proc/net/tcp`, then
  `ss`, so none of them has to be installed.
- **Cookie encryption.** Chrome/Brave on Linux pick the password store from the desktop session
  (`gnome-libsecret`, `kwallet`, or `basic`). The mirrored instance inherits the server's environment;
  if it is started from a context without `DBUS_SESSION_BUS_ADDRESS` it may fall back to `basic` and
  fail to decrypt the copied cookies. Pass `BROWSER_MCP_ARGS=--password-store=gnome-libsecret`
  (or `kwallet5`) to match your daily browser.
- **Snap Chromium** cannot read hidden directories in your home, including `~/.browser-mcp`. Point
  `BROWSER_MCP_MIRROR_DIR` at a visible folder (e.g. `~/browser-mcp-profiles`) or use a non-Snap build.

## Tests and continuous integration

`npm test` builds the server and runs the end-to-end test in `test/`: it starts a headless Chrome on an
empty temporary profile, attaches **two** server sessions to it, and signs each into its own local
login fixture in parallel with credentials read from 1Password through the SDK. The fixtures check the
submitted values against the vault, so the test proves the right secrets reached the right tab without
ever printing them. It is safe to run repeatedly: stale browsers and temp profiles from an interrupted
run are reaped at the start, and everything is removed at the end. About 8 s per run.

It needs a service account token with read access to one vault of test logins. The vault and item
names are deliberately not in the repository; on the CI machine they live in the runner's `.env`
next to the token:

| variable | default | meaning |
|---|---|---|
| `OP_SERVICE_ACCOUNT_TOKEN` | login keychain item `browser-mcp-op-service-account` (macOS) | the token; the keychain fallback keeps it out of shells and CI config |
| `BROWSER_MCP_TEST_VAULT` | required | vault holding the test logins; nothing else is read |
| `BROWSER_MCP_TEST_ITEMS` | required | two Login item titles in that vault, comma-separated, one per tab |
| `BROWSER_MCP_BROWSER` / `BROWSER_MCP_EXECUTABLE` | `chrome` | browser to launch for the test |
| `E2E_VERBOSE` | | print every tool call and timing |

[`.github/workflows/e2e.yml`](.github/workflows/e2e.yml) runs the same command on a **self-hosted macOS
runner** (labels `self-hosted, macOS, browser-mcp`), so the token never leaves that machine: GitHub
stores no secret, the workflow passes none, and the job only runs for code from this repository (fork
pull requests are skipped, which matters because the repository is public). Node comes from
`actions/setup-node`; the machine only needs Chrome. To set up the runner on a Mac that stays logged in,
run [`scripts/setup-runner.sh`](scripts/setup-runner.sh) there once: it registers the machine with the
repository, installs the runner as a LaunchAgent in that user's session (which gives jobs a display),
and puts the token in the login keychain, or, when run over SSH where the keychain is locked, in the
runner's private `.env` file, which the runner exports to jobs. Both places count as runner-local; the
keychain is preferable, and the script prints how to move the token there later. The test's vault and
item names always go into that `.env` (pass `BROWSER_MCP_TEST_VAULT` and `BROWSER_MCP_TEST_ITEMS` to
the script, or answer its prompts).

## Configuration (environment or `--key=value`)

| variable | default | meaning |
|---|---|---|
| `BROWSER_MCP_BROWSER` | `auto` | `brave`, `chrome`, `chromium`, `edge`; auto prefers an installed browser with a profile that is not currently running |
| `BROWSER_MCP_EXECUTABLE` | detected | browser binary |
| `BROWSER_MCP_USER_DATA_DIR` | browser default | source profile root |
| `BROWSER_MCP_PROFILE` | `Default` | profile folder (`Profile 1`, ...) |
| `BROWSER_MCP_MODE` | `mirror` | `mirror`, `direct`, `attach` |
| `BROWSER_MCP_PORT` | `9333` | DevTools port |
| `BROWSER_MCP_CDP_URL` | `http://127.0.0.1:<port>` | endpoint to attach to |
| `BROWSER_MCP_MIRROR_DIR` | `~/.browser-mcp/profiles` | where mirrored profiles live |
| `BROWSER_MCP_MIRROR_SYNC` | `always` | `always` (every launch), `once`, `never` |
| `BROWSER_MCP_MIRROR_INDEXEDDB_MAX_MB` | `100` | skip IndexedDB origins larger than this (extensions always copied) |
| `BROWSER_MCP_MIRROR_HISTORY` | `true` | copy History too |
| `BROWSER_MCP_DISABLE_SYNC` | `true` | pass `--disable-sync` to the mirrored instance |
| `BROWSER_MCP_HEADLESS` | `false` | `--headless=new` |
| `BROWSER_MCP_ARGS` | | extra browser flags (on Linux `--no-sandbox` is added automatically as root / in containers) |
| `OP_SERVICE_ACCOUNT_TOKEN` | none | 1Password service account token (the SDK's own variable); without it the `onepassword_*` tools are unavailable. See [Service account](#service-account) |
| `BROWSER_MCP_OP_VAULTS` | every vault the token can read | comma-separated vault titles or ids the server may read |
| `BROWSER_MCP_SESSIONS` | `shared` | `shared` (one browser, per-session tabs) or `isolated` (one browser per server) |
| `BROWSER_MCP_SESSION_NAME` | number from the registry | label used in the tab-group title and the isolated profile copy |
| `BROWSER_MCP_KEEP_TABS` | `false` | shared: leave this session's tabs open when the server exits |
| `BROWSER_MCP_ISOLATED_KEEP` | `false` | isolated: keep the browser and profile copy after the server exits |
| `BROWSER_MCP_TAB_GROUP` | `true` | keep this session's tabs in one tab group |
| `BROWSER_MCP_TAB_GROUP_TITLE` / `BROWSER_MCP_TAB_GROUP_COLOR` | `Claude` / one colour per session | group label and colour (grey, blue, red, yellow, green, pink, purple, cyan, orange) |
| `BROWSER_MCP_SNAPSHOT_MAX_CHARS` | `20000` | snapshot truncation |
| `BROWSER_MCP_SNAPSHOT_AFTER_ACTIONS` | `false` | return a snapshot after click/type/etc. by default |
| `BROWSER_MCP_ACTION_TIMEOUT_MS` | `15000` | Playwright action timeout |
| `BROWSER_MCP_LOG_FILE` | `~/.browser-mcp/browser-mcp.log` | server log; browser stderr goes to `browser-mcp.browser.log` |

## Caveats

- On macOS, when the mirrored instance is the same app as your daily browser, the system may route
  links opened from other apps to it. Prefer the other browser (the `auto` default) or quit the mirror with
  `browser_close kill=true` when done.
- The mirror is a point-in-time copy. Logins you perform in your regular browser after the last
  sync are picked up on the next launch of the mirrored instance (`MIRROR_SYNC=always`).
- The copied profile contains your session cookies and extension state; it sits in
  `~/.browser-mcp` with mode 0700. Delete that folder to purge it.
- Copying LevelDB stores while the source browser runs can occasionally produce an inconsistent
  copy of one extension's state. Relaunching re-syncs.
- Extension pages (wallet unlock screens such as Rabby or MetaMask, `chrome-extension://...`) and
  browser UI pages have no site to match, so pass `item=<title>` to `onepassword_fill` there.

TDQS

B3.2/5.0

Scored across 27 tools

Disambiguation4/5

Most tools target distinct browser actions, and the browser_ vs onepassword_ prefixes make the domain split clear. There is some overlap among reading tools (snapshot, find, get_text) and between type/fill_form, but descriptions generally guide selection.

Naming Consistency5/5

All tools use consistent snake_case with predictable browser_ and onepassword_ prefixes followed by clear action/resource names. Multi-action tools like browser_tabs and browser_history are still readable and consistent.

Tool Count3/5

At 27 tools the surface is heavy, though browser automation naturally requires many granular actions. A few operations could potentially be consolidated, but most tools earn their place, making this borderline rather than clearly excessive.

Completeness4/5

The server covers a broad browser automation lifecycle: navigation, inspection, interaction, dialogs, uploads, JS evaluation, console/network, and 1Password fill/OTP/items/status. Minor gaps like drag-and-drop, download handling, or credential save/update prevent a perfect completeness score.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues