# chromium-cdp-mcp [Model Context Protocol](https://modelcontextprotocol.io/) server that lets an AI assistant drive **any Chromium-based browser** via the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/). No Puppeteer, no Playwright — a thin layer of native WebSocket directly to the browser's `--remote-debugging-port`. ## What it is A standalone MCP server (TypeScript). Once an MCP-aware client (Claude Desktop, Claude Code, Cursor, Windsurf, Cline, Continue.dev, Zed, Codex CLI, Goose, …) loads it, the AI can: - navigate, click, fill, scroll, type, select options, take screenshots - run arbitrary JavaScript and **receive the real return value** - handle JS dialogs (`alert` / `confirm` / `prompt` / `beforeunload`) - click inside **cross-origin iframes** (Cloudflare Turnstile, reCAPTCHA, embed widgets) - manage tabs, override the viewport, send raw CDP commands The server is browser-agnostic: every tool takes a `port` argument and connects to whatever Chromium-based browser is listening on that port. ## What it is NOT - Not a profile / fingerprint manager. For antidetect profile creation, proxies, cookies, and batched profile orchestration use a separate MCP such as [`undetectable-local-api-mcp-ts`](https://www.npmjs.com/package/undetectable-local-api-mcp-ts). - Not a browser launcher. You start the browser yourself (or via the antidetect software); this server attaches. ## Install ### From npm ```bash # in your MCP client config — auto-fetches and runs npx -y chromium-cdp-mcp ``` ### From source ```bash git clone https://github.com//chromium-cdp-mcp cd chromium-cdp-mcp npm install npm run build node dist/server.js # or `npm start` ``` Requires **Node.js ≥ 22** (native `WebSocket`). ## MCP client config Same shape for every client. Example (`claude_desktop_config.json` etc.): ```json { "mcpServers": { "chromium-cdp": { "command": "npx", "args": ["-y", "chromium-cdp-mcp"] } } } ``` For a local checkout: ```json { "mcpServers": { "chromium-cdp": { "command": "node", "args": ["/absolute/path/to/MCP-CDP/dist/server.js"] } } } ``` ## Launch a browser with CDP enabled The server connects to an **already-running** Chromium instance via its remote debugging port. Start one of these first: ### Chrome / Chromium ```bash # Linux / macOS google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-cdp # Windows (PowerShell or cmd) "C:\Program Files\Google\Chrome\Application\chrome.exe" ^ --remote-debugging-port=9222 ^ --user-data-dir="%TEMP%\chrome-cdp" ``` ### Microsoft Edge ```bash "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" ^ --remote-debugging-port=9222 ^ --user-data-dir="%TEMP%\edge-cdp" ``` ### Brave / Opera / Vivaldi / Yandex Browser Same `--remote-debugging-port=PORT` flag — every Chromium fork supports it. ### Puppeteer / Playwright launchers ```ts // Puppeteer const browser = await puppeteer.launch({ args: ["--remote-debugging-port=9222"], }); // Playwright (chromium) const browser = await chromium.launch({ args: ["--remote-debugging-port=9222"], }); ``` ### Use a fresh profile `--user-data-dir` points to a clean profile directory. Without it, Chrome refuses to enable remote debugging on your default profile (a 122+ security restriction). ### Verify the port is live ```bash curl http://127.0.0.1:9222/json/version ``` If you see JSON with `webSocketDebuggerUrl`, you're ready. ## Connection block Every tool accepts the same connection fields: | Field | Type | Description | | -------------- | -------- | ---------------------------------------------------------------------------- | | `port` | number | The browser's `--remote-debugging-port`. **Required.** | | `host` | string | Default `127.0.0.1`. | | `target_id` | string | Explicit page targetId from `list_tabs`. Skips auto-pick. | | `url_contains` | string | Pick the first page whose URL contains this substring. | | `tab_index` | number | Pick page by index in `Target.getTargets` order. | Auto-pick (when none of `target_id` / `url_contains` / `tab_index` is given): the first attached page, falling back to the first page in the target list. ## Tools ### Connection / tabs | Tool | What it does | | ----------- | --------------------------------------------------------------------- | | `connect` | Probe `/json/version` + `/json/list`. Diagnostic. | | `list_tabs` | `Target.getTargets`. Returns `{targetId, type, url, title, attached}`.| | `new_tab` | Open a new tab. Optional `url`. Returns the new targetId. | | `close_tab` | Close the tab specified by `target_id`. | ### Navigation | Tool | What it does | | ---------- | ---------------------------------------------------------------------------- | | `navigate` | `Page.navigate` + best-effort wait for load. Returns final URL. | | `back` | `history.back()`. | | `forward` | `history.forward()`. | | `reload` | `Page.reload`, optional `ignore_cache`. | ### JavaScript | Tool | What it does | | --------------- | ------------------------------------------------------------------------------------------------------- | | `evaluate` | `Runtime.evaluate` with `awaitPromise=true`, `returnByValue=true`. **Returns the actual value.** | | `get_page_html` | `document.documentElement.outerHTML`. | | `get_url` | `location.href`. | ### DOM interactions | Tool | What it does | | -------------------------- | ----------------------------------------------------------------------------------------------- | | `click` | Real mouse press+release at the element's center. CSS or XPath selector. | | `click_at` | Real mouse press+release at raw viewport `(x, y)`. | | `click_iframe` | Real click inside any iframe (cross-origin friendly). `dx` / `dy` offsets, default center. | | `click_and_accept_dialog` | Click AND auto-handle any `alert` / `confirm` / `prompt` dialog the click triggers. | | `handle_dialog` | Handle a currently-open JS dialog. `accept`, optional `prompt_text`. | | `fill` | Focus + `Input.insertText`. Clears existing value unless `append=true`. Supports unicode. | | `select_option` | Set `