Skip to main content
Glama
Mukller

OpenCode in Chrome

by Mukller

OpenCode in Chrome

Let your local opencode agent see and control the browser — tabs, clicks, JS, screenshots.

GitHub stars License: MIT Version

Anton Petnitsky · github.com/Mukller · LinkedIn


An alternative to Claude-in-Chrome for opencode: a Chrome extension + a local bridge with an MCP interface. The agent gets full control over your live browser — with logged-in sessions, no --remote-debugging-port, and no clouds. Everything goes through localhost.

┌──────────────────┐   WebSocket    ┌─────────────────┐    stdio/MCP    ┌──────────┐
│ Chrome extension │◄──────────────►│  bridge (Node)  │◄───────────────►│ opencode │
│  chrome.debugger │  127.0.0.1     │  ws + mcp       │                 │          │
└──────────────────┘                └─────────────────┘                 └──────────┘

The key trick: the extension itself starts a CDP session via chrome.debugger — so no browser launch flags are needed, and all profiles and cookies work as usual.

Features

MCP tool

What it does

chrome_tabs_list

list of open tabs

chrome_tab_open / _navigate / _close

open / navigate / close a tab

chrome_tab_wait_load

wait for the page to load

chrome_eval

run JavaScript on the page, get the result

chrome_click

click a CSS selector

chrome_fill

fill in a field (React-friendly, via native setter)

chrome_press_key

send a key to the focused element

chrome_read

title + URL + visible page text

chrome_screenshot

PNG screenshot of the tab (returned as an image block)

chrome_console

latest console.log / page exceptions

Related MCP server: @nimbus21.ai/chrome-devtools-mcp

Installation

1. Bridge

git clone https://github.com/Mukller/opencode-chrome.git
cd opencode-chrome
npm install
node bridge/bridge.mjs

On first start, the bridge prints a token and saves it to ~/.opencode-chrome/token.

2. Extension

  1. Open chrome://extensions → enable Developer mode

  2. Load unpacked extension → select the extension/ folder

  3. Click the extension icon → Settings → paste the token from step 1 → Save & reconnect

  4. The icon badge should turn green ON

3. Connect to opencode

In ~/.config/opencode/opencode.json (or in the project one):

{
  "mcp": {
    "chrome": {
      "type": "local",
      "command": ["node", "<путь до репо>/bridge/bridge.mjs"],
      "enabled": true
    }
  }
}

Restart opencode — the chrome_* tools will appear for the agent.

Bridge environment variables: OPENCODE_CHROME_PORT (default 8766), OPENCODE_CHROME_TOKEN (fixed token instead of a file).

Security

  • The WS server listens only on 127.0.0.1, foreign connections are rejected.

  • The handshake requires a token; an invalid token = the connection is closed.

  • The extension only executes commands from the connected bridge; everything is visible in the yellow "debugging started" banner during active operations.

Known limitations

  • While a CDP session is active on a tab, Chrome shows the infobar "An extension started debugging this browser" — that's the price for access without devtools flags.

  • The extension's service worker sleeps when Chrome is idle; the bridge just waits for reconnection (auto-reconnect).

Tests

npm test        # E2E: фейковое расширение + MCP-клиент против реального моста

License

MIT © Anton Petnitsky

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers