Skip to main content
Glama
README.md
# Chrome MCP Bridge

[Download v0.1.0 preview](https://github.com/xiaokillua/chrome-mcp-bridge/releases/tag/v0.1.0) · [Installation guide](docs/INSTALL.md) · [Self-hosting](apps/gateway/README.md) · [简体中文](README.zh-CN.md)

Connect MCP clients to Chrome tabs you control. Use your existing Chrome profile for tasks such as reading a dashboard, filling a test form, taking a screenshot, or inspecting your app’s console and request timing.

Each AI session has its own tabs. Tabs in the same Chrome profile still share cookies and sign-in state.

## Quick start

Use Chrome 125 or later and Node.js 24 LTS. Get the extension ZIP and CLI tarball, install the CLI, and run `chrome-mcp-bridge setup`. Then load the unpacked extension in Chrome and paste the pairing string into its popup.

The [installation guide](docs/INSTALL.md) walks through building or downloading the files, pairing Chrome, configuring Codex or Claude Code, and making your first call.

When upgrading a preview, install the matching CLI tarball, update the unpacked extension in its existing directory and click **Reload** in `chrome://extensions`. Run `chrome-mcp-bridge stop` followed by `chrome-mcp-bridge start`, then reconnect the MCP client to refresh its tools. For a self-hosted connection, rebuild the gateway from the same source version.

## Connection and usage results

The release checks used a fresh CLI installation, an unpacked extension and a temporary Chrome profile. Once paired, `chrome-mcp-bridge doctor` reported `bridge: true`, `chrome: true` and `paused: false`.

| Client or connection | What was verified |
| --- | --- |
| Codex CLI 0.154.0 on macOS · local stdio | The Codex app server discovered 18 tools, opened a tab, filled and submitted a form, then read its confirmation page. The fixture received exactly one POST with the requested text. The test invoked the tools directly through Codex and made zero model requests. |
| Claude Code 2.1.334 on macOS · local stdio | With the generated client configuration and a paired browser, `claude mcp list` reported **Connected**. This check covers the handshake. Browser actions were exercised separately through Codex and the MCP SDK. |
| Self-hosted web connection · HTTPS + OAuth | The MCP test client authorized with the test gateway, opened an allowed site in Chrome and read its page over the paired helper’s WSS connection. |
| ChatGPT web and Claude web | Both have setup instructions. Signing in through each vendor’s live connector UI and running a task in that account remain unverified. |

For a first task, ask your client to open a session, visit `https://example.com` and report its page title. For an existing tab, open a session first and assign the tab in the extension popup. [Installation and pairing](docs/INSTALL.md)

## ChatGPT and Claude on the web

Deploy the [self-hosted gateway](apps/gateway/README.md) to a domain with HTTPS. Connect the local helper with the deployment’s device credential, add its `/mcp` URL to your AI account, then authorize access with OAuth. Add each permitted target site’s exact origin in the Chrome extension. The local helper must run while using a web client.

The gateway uses one owner account and one paired computer. Remote tool results transit the gateway. Keep the server and logs under your control, and share only tabs and sites whose data you intend to send to your AI provider.

## Tool surface

- `session_open`, `session_close` manage browser sessions. After opening a session, reuse its `sessionId`.
- `browser_tabs`, `browser_open`, `browser_navigate`, `browser_close` manage assigned tabs.
- `browser_snapshot`, `browser_screenshot`, `browser_wait` read browser state. Use the latest snapshot to obtain element references. Set `mode: "controls"` to skip page text for click and form tasks. See [token use](docs/TOKEN-USE.md) for the comparison with screenshots.
- `browser_click`, `browser_fill`, `browser_press`, `browser_scroll` interact with the page. `browser_select` chooses a native dropdown option by label, and `browser_set_checked` sets a checkbox to the requested state.
- `debug_console`, `debug_network`, `debug_performance` expose selected [Chrome developer diagnostics](#chrome-developer-tools). Enter passwords and verification codes manually.

If a write returns `outcome_unknown`, inspect the page in Chrome before repeating it. When the local broker receives an uncertain write result from the extension, it ends that session and drops its queued operations. To resume through MCP, open a new session and assign the existing tab to it.

## Scrolling and form submission

Use these calls to reach **Save** or **Next** near the bottom of a long page.

1. Take a `browser_snapshot` with `mode: "controls"`. The default scope gives on-screen controls priority when the list exceeds 100. Use `scope: "viewport"` to see just the controls in view.
2. Call `browser_scroll` with a signed `deltaY` to scroll the document. For a separately scrolling panel, identify it by name or on-screen bounds in `scrollRegions` and pass its `ref` to `browser_scroll`. Check `movedBy` for the actual distance and `atBottom` for the current boundary. If more than eight panels are visible, pass `nextRegionOffset` back as `regionOffset` to list the next group.
3. Take a fresh snapshot and click the target using its latest `elements` ref. If the site adds content asynchronously, wait for the expected text or take another snapshot after it appears. A panel can grow after reaching its current bottom.

To enumerate rendered controls in document order, use `scope: "document"`. If the result includes `nextControlOffset`, pass it as `controlOffset` on the next snapshot with the same scope. Restart from offset zero after scrolling or when the list changes. Each response contains up to 100 controls. Full mode also includes up to 12,000 characters of page text. Scrolling works with native document and panel scrollbars. Canvas views driven by wheel gestures, iframes and shadow roots may require manual interaction.

Use `browser_fill` to enter ordinary values. A successful fill returns `verified: true` after checking the field text in the page. If a field truncates or rejects the input and its value differs, the tool reports `outcome_unknown`. To save a verified edit, click the site's **Save** or **Submit** button and check the saved record. A text wait can also match a confirmation left over from an earlier save. For repeated edits, verify something specific to the latest update, such as the changed display name after reopening the profile.

Call `session_close` when a task finishes. If a local client exits without closing its session, the broker can keep the idle session for about an hour. The 32-session limit is shared across clients.

## Links that open another tab

When a standard `target="_blank"` link opens a new tab, `browser_click` can return its `newTabId` for the same session. The bridge verifies that Chrome opened the link from the assigned source tab. A remote session must also have access to the final destination origin. If the tab was not assigned, Chrome still shows it and the user can assign it from the extension. JavaScript popups and named windows may require manual assignment. After upgrading an unpacked extension, reload it in `chrome://extensions` so Chrome picks up the navigation permission.

## Chrome developer tools

The extension uses the [Chrome debugger API](https://developer.chrome.com/docs/extensions/reference/api/debugger) to expose selected DevTools diagnostics as MCP tools.

| Tool | Output |
| --- | --- |
| `debug_console` | Console messages, levels, timestamps and basic exception messages. Common credential formats are redacted and inspected objects are summarized by type. |
| `debug_network` | Request origin and path, HTTP method, response status, duration and failure flag. The output excludes query strings, fragments, headers and request or response bodies. |
| `debug_performance` | Basic page navigation and paint timings, and the number of recorded resources. |

Use a tab assigned to your AI session and a client with the `debug` capability. Loopback origins are enabled by default. Add any other site under **Remote & developer permissions → Additional developer origins** in the extension, including a port if needed. A remote client also needs the origin under **Remote allowed origins**.

Call `debug_console` or `debug_network` before reproducing an issue. Pass the returned `nextCursor` as `cursor` to that same tool to check for updates. Navigation clears the capture. For example, ask your AI to start recording on the assigned tab, reproduce a failing action, and report any console errors and the affected request’s status and duration. The preview covers these diagnostics only. Use Chrome DevTools for breakpoints, arbitrary JavaScript, full request inspection, or CPU and memory profiles.

## Validation

The v0.1.0 preview passed 66 regression tests and an end-to-end run with Chrome for Testing. The checks use local fixtures, a temporary browser profile and a test certificate.

| Check | Verified coverage |
| --- | --- |
| MCP schema · 7 tests | Tool arguments, write classification, typed form inputs, text waits, snapshot scope and pagination, scroll targets and pixel bounds, and rejection of unsupported tools and restricted URLs |
| Local bridge · 3 tests | Client and tab-session isolation, queued permission changes, persisted revocation, prevention of queued writes after an uncertain result, and macOS launch configuration generation |
| Extension · 45 tests | Form controls, scrolling, snapshot references and diagnostic redaction. Cancelling debugger access releases that tab. Removing developer permission during a pending operation suppresses the diagnostic result. |
| Gateway · 11 tests | OAuth code and PKCE, token refresh and replay rejection, persisted grants, client-scoped revocation, malformed responses, cancellation on disconnect and validation of persisted credentials |
| Chrome end to end | Pair, open independent tabs, fill and click, capture a PNG, pause and resume, reconnect after broker and browser restarts, and call Chrome through HTTPS, OAuth and WSS |
| Scrolling and submission end to end | Read already rendered content below the fold, scroll to reveal an asynchronously rendered profile form, submit it, and verify both the server’s POST payload and the confirmation page |
| Long document · Chrome 159.0.8154.6 | Read 131 controls in two pages of 100 and 31. Scroll 5,168 px to the bottom, find **保存** (Save) in a fresh default snapshot, click it, and verify one POST and the confirmation page. |
| Independent panels · same Chrome run | With a sidebar covering the former wheel position, scroll the document 600 px while both panels stay put. Scroll the main panel to 1,344 px, find **下一页** (Next), click it, and verify one POST and the updated page text. A further scroll at the sidebar’s bottom moves 0 px and leaves the main panel and document in place. |
| Form controls and new tabs end to end | Select a region, set a checkbox twice without toggling it back, wait for the asynchronous save message, and verify the POST. Click a new-tab link and verify tab isolation, including a remote redirect to an origin the session cannot access. |
| Rejected or truncated text end to end | Request `ABCDEF` from two fields. Chrome retains `ABC` in a three-character field and an empty value in a field that rejects input. Both MCP calls report `outcome_unknown`, and the affected sessions expire immediately. |
| Chrome DevTools end to end | Capture a console message, check a real fixture request’s method, status and duration, read navigation timing and resource count, check the paint timing output, and verify that adding and removing a developer origin changes access |
| Packaging and deployment smoke checks | Install the CLI tarball into a fresh prefix and pair the extracted extension. Build the gateway from clean source on Linux arm64, run its 11 tests on Node 24, and verify HTTPS, OAuth, device communication and credential persistence across a container restart. |

The [token comparison](docs/TOKEN-USE.md) records three runs on a simple form and a denser page, with screenshot costs labeled as estimates.

### Reproduce from source

```sh
pnpm install --frozen-lockfile
pnpm build
pnpm typecheck
pnpm exec playwright install chromium
pnpm test
pnpm test:browser
pnpm package:preview
```

To include the Codex tool-call check, run `CHROME_MCP_TEST_CODEX=codex pnpm test:browser` with the Codex CLI on your PATH. To test installed release artifacts, set `CHROME_MCP_TEST_CLI` to the absolute path of the installed CLI script and `CHROME_MCP_TEST_EXTENSION` to the unpacked extension directory.

The repository’s CI workflow runs the build, type check, tests, packaging and Docker build on Ubuntu with Node.js 24. On a fresh Linux machine, use `pnpm exec playwright install --with-deps chromium` to install the browser’s system dependencies.

For development, use `node apps/bridge/dist/cli.js setup` and load `apps/extension/dist` as the unpacked extension. Release artifacts and SHA-256 checksums are written to `release/`. Packaging requires `zip`. The browser test uses `openssl` to create an isolated test certificate.

MIT licensed.