attach-cdp-mcp
Attaches to an already-running Brave browser over the DevTools Protocol and exposes the user's real tabs, allowing an agent to list tabs, evaluate JavaScript, navigate, click, screenshot, print to PDF, and send raw CDP commands through the same CLI and MCP bridge used for other Chromium-family browsers.
Attaches to an already-running Chrome instance (including Chromium and Chrome Beta/Dev/Canary) over the DevTools Protocol and works with the user's real, logged-in tabs. Provides tools to list tabs, evaluate JavaScript, navigate, click elements, wait for conditions, capture screenshots, print to PDF, send raw CDP commands, and close tabs. As an MCP bridge it points chrome-devtools-mcp at the existing browser (found via DevToolsActivePort) instead of launching a fresh, logged-out profile, and falls back to a private profile only if no browser is found.
Attaches to an already-running Vivaldi browser over the DevTools Protocol and exposes the user's real, logged-in tabs, allowing an agent to list tabs, evaluate JavaScript, navigate, click, screenshot, print to PDF, and send raw CDP commands through the same CLI and MCP bridge used for other Chromium-family browsers.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
attach-cdp
Drive the Chrome you are already logged into — from your terminal, or from an AI agent.
Most browser automation starts a new browser: empty profile, no cookies, no sessions, so the first thing it hits is a login wall. attach-cdp does the opposite. It finds the Chromium browser that is already running on your machine, connects to it over the DevTools Protocol, and works with your real tabs.
It ships as two things:
| A dependency-free CLI: list tabs, evaluate JavaScript, navigate, click, screenshot, print to PDF, send raw CDP commands |
| An MCP bridge that points |
$ attach-cdp list
#0 Inbox (12) - you@example.com - Gmail
https://mail.google.com/mail/u/0/#inbox
#1 Pull requests · Dr-SherBaz/attach-cdp
https://github.com/Dr-SherBaz/attach-cdp/pulls
$ attach-cdp eval "#0" "document.title"
Inbox (12) - you@example.com - GmailWhy this exists
Since Chrome 136, a browser started with the default user-data directory refuses to serve the HTTP discovery endpoints (/json/version, /json/list). They answer 404 — but the WebSocket debugger endpoint still works, and Chrome still writes the endpoint into DevToolsActivePort inside the profile.
That single detail breaks most "connect to my running browser" recipes, and it is the reason an agent ends up with a second, logged-out window. attach-cdp reads that file directly and never asks the HTTP endpoints for permission:
<user-data-dir>/DevToolsActivePort
9222
/devtools/browser/f1b4c93d-...
│
└──> ws://127.0.0.1:9222/devtools/browser/f1b4c93d-...No dependencies. No bundled protocol typings. Just Node's built-in WebSocket.
Related MCP server: Browser Controller
Requirements
Node.js 22 or newer (uses the global
WebSocket; nowspackage)A Chromium-family browser with remote debugging enabled: Chrome, Chromium, Chrome Beta/Dev/Canary, Brave, Vivaldi or Edge
For the MCP bridge only:
npx(ships with Node) and network access to fetchchrome-devtools-mcp
Enable remote debugging in your browser
Quit the browser completely first — launching it again while it is running ignores new flags.
# Windows
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222# macOS
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222
# Linux
google-chrome --remote-debugging-port=9222Chrome 144+ also lets you turn this on from chrome://inspect/#remote-debugging without restarting, if your build offers the toggle.
Keep the debug port on
127.0.0.1. Anyone who can reach it can drive your logged-in browser.
Install
npm install -g attach-cdp
# or run without installing
npx attach-cdp doctorFrom source, if you want to hack on it:
git clone https://github.com/Dr-SherBaz/attach-cdp.git
cd attach-cdp
npm link # puts attach-cdp and attach-cdp-mcp on your PATHWithout npm link, run the entry points directly:
node bin/attach-cdp.mjs doctor
node bin/attach-cdp-mcp.mjsQuick start
attach-cdp doctor # is there a browser, can we talk to it?
attach-cdp list # what tabs are open?
attach-cdp text "#0" | head # visible text of a tab
attach-cdp eval "#0" "document.title"
attach-cdp shot "#0" page.png --full
attach-cdp close iana.org # close a tab by URL fragmentdoctor is the command to run when anything looks wrong. It shows the endpoint it found, where it found it, the browser version, and every open tab.
Commands
Command | Description |
| Diagnose discovery, connection and tab access |
| List open tabs ( |
| Print the visible text of a tab |
| Evaluate JavaScript ( |
| Send a raw CDP command ( |
| Navigate and wait for the document |
| Open a new tab |
| Screenshot ( |
| Print to PDF ( |
| Click the first element matching a CSS selector |
| Poll until an expression is truthy ( |
| Close a tab |
| Start the MCP bridge (see below) |
Selecting a tab
Selector | Meaning |
| Index from |
| Exact target id |
| Case-insensitive substring of the URL |
| Case-insensitive substring of the title |
URL matches win over title matches; among equals, the first tab in browser order wins.
Global options
Option | Meaning |
| Browser WebSocket endpoint (or |
| Query |
| Machine-readable output |
| Per-operation timeout (default 30000) |
| Drop the "attached via …" note on stderr |
| Help, version |
Endpoint precedence: --ws → --port → DevToolsActivePort scan.
On Windows PowerShell, JSON arguments lose their quotes on the way to a native executable. Use
--params-file params.jsoninstead of inlining JSON.
MCP bridge for AI agents
The bridge exists to answer one question: how do I let an agent use my logged-in browser?
attach-cdp mcp # or: attach-cdp-mcpIt resolves the endpoint, then execs chrome-devtools-mcp --wsEndpoint <url>. If no browser is found it falls back to launching a private profile (override with ATTACH_CDP_FALLBACK_PROFILE, disable with --no-fallback / buildBridgeCommand({ fallback: false })).
OpenCode
~/.config/opencode/opencode.json:
{
"mcp": {
"servers": {
"chrome-devtools": {
"type": "local",
"command": ["npx", "-y", "attach-cdp", "mcp"]
}
}
}
}Claude Code
claude mcp add chrome-devtools -- npx -y attach-cdp mcpClaude Desktop / Cursor / Zed
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "attach-cdp", "mcp"]
}
}
}Restart the client after changing MCP configuration: the server reads the endpoint once, at startup.
Programmatic API
import { resolveEndpoint, Connection, listTargets, attach, evaluate } from "attach-cdp";
const endpoint = await resolveEndpoint(); // uses DevToolsActivePort
const conn = await Connection.open(endpoint.wsEndpoint);
const tabs = await listTargets(conn);
const session = await attach(conn, tabs[0].targetId);
console.log(await evaluate(conn, session, "document.title"));
conn.close();Everything is exported from src/index.js: connection handling, target listing, evaluate, screenshots, PDF, navigation, clicking, polling and endpoint discovery.
Security notes
Attaching means exactly what it sounds like: full control of a browser profile that is signed in to your accounts.
Leave the debug port bound to
127.0.0.1. Never publish it, never forward it to another machine.Any local process can use an open debug port — enable it for the session, not permanently.
An agent wired to this bridge can read anything those tabs can read. Treat the MCP client with the same trust you give the browser.
Prefer a dedicated browser profile when automating something sensitive, and use
--user-data-dirfor that profile.This project never sends your data anywhere. It talks to
127.0.0.1and nothing else — the only network fetch in the codebase is/json/versionon a local port, plusnpxfetchingchrome-devtools-mcp.
Troubleshooting
Symptom | Cause | Fix |
| Chrome 136+ hides HTTP discovery for the default profile | Ignore it: |
| Browser not started with the flag | Quit the browser fully, relaunch with |
| No | Run |
Flag ignored, port still closed | Browser was already running when you relaunched it | Quit every window (and any background process) first |
| Stale | Restart the browser |
MCP tools see | Client launched its own browser | Point the client at |
Tab selector matches nothing | Duplicate tabs | Use |
Set ATTACH_CDP_DEBUG=1 to print stack traces.
Development
npm test # unit tests + live integration tests (skipped when no browser)
npm run check # syntax check the entry points
CDP_WS_ENDPOINT=... npm test # force the integration tests against a known endpointLayout:
src/endpoint.js discovery: profiles, DevToolsActivePort, ports
src/cdp.js protocol client and page helpers
src/match.js tab selection
src/cli.js argument parsing and command dispatch
src/mcp-bridge.js chrome-devtools-mcp launcher
bin/ the two entry points
test/ node:test suitesLicense
MIT © Muhammad Sher Baz Ali
This server cannot be deployed
Maintenance
Related MCP Connectors
Browser MCP for logged-in tasks. Uses your Chrome — credentials stay local. Zero-token replay.
Let AI agents use your real, signed-in Chrome: tabs, clicks, forms, screenshots and video.
Connect AI agents to your own Chrome with scoped access, approvals, and verified task results.
Live browser debugging for AI assistants — DOM, console, network via MCP.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables CLI coding agents to interact with your live browser tabs via MCP, using your real sessions and cookies without a sandbox.MIT
- AlicenseNot gradedqualityAmaintenanceGives MCP-compatible AI agents direct control of your real browser with existing sessions, logins, and cookies. Supports multiple agents concurrently with tab targeting.6 npm9MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to control your existing Chrome browser via MCP, using your logged-in sessions for automation on authenticated sites. Provides high-level browser tools plus raw CDP and Chrome API access.MIT
- AlicenseNot gradedqualityAmaintenanceEnables any MCP-compatible AI agent to drive your own Chrome browser with your existing login state, filling forms, clicking elements, fetching data, and handling captchas without API keys or re-authentication.446 npm567MIT