mcp-cdp
A safe-by-default MCP server that drives Electron or Chrome/Chromium apps over the Chrome DevTools Protocol, letting an agent inspect a live page's DOM, console and network instead of screenshots.
Discover targets —
list_targetslists debuggable pages, webviews and Electron windows (id, type, title, URL) on the DevTools endpoint.Read the DOM —
dom_snapshotreturns the rendered HTML of the whole document or a selector's subtree;query_domreturns outer HTML of elements matching a CSS selector (capped).Diagnose failures —
console_logssurfaces recent console output and uncaught exceptions;network_requestslists recent requests (method, URL, status, MIME, failures) with headers never captured and sensitive query values redacted.See the rendering —
screenshotcaptures a PNG of the viewport for visual layout/image checks.Act on the page (mode-gated, not registered in this read-only schema) — with
CDP_MODE=read-write:click,type_text,press_key,navigate(human-confirmed); withadmin+CDP_ALLOW_EVAL:evaluateJavaScript, also human-confirmed and refused on protected targets.Stay safe by default — read-only mode by default, target allowlists and protected targets (sign-in pages, browser internals), dry-run, interactive confirmation with page-identity pinning, loopback-only endpoints, and an optional laya-guard AI risk check on eval.
Allows driving an Electron app over the Chrome DevTools Protocol, providing tools to inspect the DOM, read console logs and network requests, take screenshots, and perform actions such as clicking, typing, pressing keys, and navigating.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-cdp What's on the page right now, and are there any console errors or failed network requests?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-cdp
A safe-by-default Model Context Protocol server that drives an Electron or Chrome/Chromium app over the Chrome DevTools Protocol (CDP) — instead of pixel-level GUI automation. Point it at the app's --remote-debugging-port and an agent gets the DOM, console, network requests, real input (click / type / navigate), and — gated — JavaScript evaluation.
Why this beats computer-use for a desktop/web app:
The DOM, not a screenshot. The agent reads exact rendered HTML and can query any element — far more information, and it sees things that aren't on screen.
Console + network. When a test fails, the uncaught exception or the failed request is right there — no guessing from an image.
No collisions. Each agent attaches to its own debugging port, so parallel agents (e.g. one per git worktree) never fight over one desktop.
Cross-OS. CDP works identically on macOS, Linux and Windows — the same flow runs on a headless VPS.
Part of the dockndevai MCP server suite — one governance model across all of them.
What it gives an agent
Starts read-only (see Safe by default); higher-capability tools are only registered when you raise the mode.
Tool | For | Needs mode |
| list pages / webviews / Electron windows (id, type, title, url) | read-only |
| rendered HTML of the page or a selector's subtree | read-only |
| outer HTML of every element matching a CSS selector | read-only |
| recent console output + uncaught exceptions | read-only |
| recent requests (method, url, status, mime; headers never captured) | read-only |
| a PNG of the viewport | read-only |
| click the first element matching a selector | read-write |
| type into the page (focus a selector first) | read-write |
| Enter / Tab / Escape / Backspace / Delete / Arrows | read-write |
| navigate a target to a URL (confirmed) | read-write |
| run a JavaScript expression in the page | admin + |
Related MCP server: chrome-devtools-mcp
Install
npx -y @dockndevai/mcp-cdpExpose a debugging port
Start your app (or a worktree's dev build) with an explicit port — one per agent:
Electron app:
your-app --remote-debugging-port=9222, or in main-process codeapp.commandLine.appendSwitch('remote-debugging-port', '9222')beforeapp.whenReady().Plain Chrome/Chromium:
chrome --headless=new --remote-debugging-port=9222 --user-data-dir=/tmp/p1 <url>.
Check it's up: curl http://127.0.0.1:9222/json/version.
Configure
{
"mcpServers": {
"cdp": {
"command": "npx",
"args": ["-y", "@dockndevai/mcp-cdp"],
"env": {
"CDP_PORT": "9222",
"CDP_MODE": "read-only"
}
}
}
}See docs/CLIENTS.md for Claude Code / Cursor / Codex / VS Code / Windsurf, and .env.example for every variable.
Safe by default
Enforced by src/security.ts. The browser process is the real boundary — this keeps an agent inside the targets and actions you intend:
CDP_MODE—read-only(default) →read-write→admin. Tools above the mode aren't registered, so in read-only the agent cannot click, type or navigate at all.CDP_TARGET_ALLOWLIST— confine interactions to targets whose URL matches your patterns (empty = all). Reads (inspection) are always allowed.CDP_PROTECTED_TARGETS— targets that can be inspected but never interacted with. Defaults protect sign-in pages (accounts.google.com,login.microsoftonline.com, …) and browser internals (chrome://,devtools://, extensions).CDP_ALLOW_EVAL—evaluateis arbitrary code execution in the renderer: admin mode plus this flag, refused on protected targets, with a human confirmation.CDP_DRY_RUN— interactions log their intent and return without dispatching.Interactive confirmation —
evaluateandnavigateprompt a human via MCP elicitation before running. The prompt shows the tool, the exact arguments (the full expression / destination URL) and a fingerprint; the target page's identity (CDP target id + URL) is pinned across the prompt and the action is refused if the page was replaced or navigated meanwhile; a prompt nobody answers is a refusal.CDP_REQUIRE_HUMAN_APPROVAL(defaultfalse) — whentrue,evaluateandnavigateare refused if the client cannot elicit (instead of falling back to the mode /CDP_ALLOW_EVALgates alone).Secrets — request/response headers are never captured (cookies/auth), and sensitive URL query values are redacted.
Loopback only — the endpoint must be
127.0.0.1unlessCDP_ALLOW_REMOTE=true.
Optional AI risk guard. Set CDP_GUARD_MODE=monitor|enforce to have the evaluate tool consult a local laya-guard daemon (pipx install laya-guard && laya-guard) that classifies the JS expression allow/confirm/block before it runs. It runs after the eval gate and can only tighten, never grant; fails closed.
There is a bundled skill, cdp-safe-operations, that teaches an agent how to expose a port, read the DOM/console/network instead of screenshots, the safety rules, and the "why did this fail?" workflow. See also SECURITY.md.
Developing
npm install
npm run build
# list the tools:
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | CDP_PORT=9222 node dist/index.js
npm testLicence
MIT
Available Tools
6 toolsconsole_logsConsole logsARead-onlyIdempotent
Return recent console output and uncaught exceptions captured from the target since it was first inspected. The fastest way to see why something failed — errors that never appear on screen.
Inputs: target_id (required), limit.
dom_snapshotDOM snapshotARead-onlyIdempotent
Return the rendered HTML of a target — the whole document, or just the subtree of the first element matching a CSS selector. This is the DOM the agent should read instead of a screenshot: it carries far more information and is exact.
Inputs: target_id (required), selector.
list_targetsList targetsARead-onlyIdempotent
List the debuggable targets on the DevTools endpoint — pages, webviews and Electron windows — with their id, type, title and URL. Start here to find the target id every other tool needs.
Inputs: no named parameters.
network_requestsNetwork requestsARead-onlyIdempotent
Return recent network requests captured from the target — method, URL, status, MIME type, failures. Headers are never captured and sensitive URL query values are redacted.
Inputs: target_id (required), limit, url_filter.
query_domQuery DOMARead-onlyIdempotent
Return the outer HTML of every element matching a CSS selector (capped). Use to locate the exact elements to click or type into, and to confirm what is actually on the page.
Inputs: selector (required), target_id (required), limit.
screenshotScreenshotARead-onlyIdempotent
Capture a PNG screenshot of the target's viewport. Prefer dom_snapshot for reading content; use this for visual layout, rendering and image checks.
Inputs: target_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool maps to a distinct concern: visual rendering, target discovery, full DOM reading, element querying, console output, and network activity. The only possible confusion is between dom_snapshot and query_dom, but their descriptions clearly separate whole-document/subtree reading from selector-based element lookup.
Names are snake_case and readable, but the pattern is mixed: some are verb_noun (list_targets, query_dom), some are noun_noun (console_logs, network_requests, dom_snapshot), and screenshot is a bare verb. Not chaotic, but not a consistent convention.
Six tools is a well-scoped size for a CDP inspection server. Each tool covers a meaningful slice of browser debugging without redundancy or bloat.
The core read-only inspection workflow is well covered: discover targets, read DOM, query elements, capture screenshots, and inspect console/network failures. Minor gaps exist—JS evaluation and navigation are not exposed—but they are not obvious dead ends for the apparent observational purpose.
Maintenance
Related MCP Connectors
Launch, inspect, control, and share isolated cloud browsers for your agents.
Give AI agents a real cloud Chrome: open sessions, navigate, read pages, click, type and screenshot.
Cloud browser, web extraction, screenshots, and remote CDP tools for AI agents.
Hosted browser for agents: open pages, search the web, extract data, read PDFs and take screenshots.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI-powered automation, debugging, and observability of Electron applications through Chrome DevTools Protocol integration, providing real-time UI interaction and inspection capabilities.27MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to control and inspect a live Chrome browser for reliable automation, in-depth debugging, and performance analysis.Apache 2.0
- AlicenseBqualityBmaintenanceEnables agents to inspect localhost web applications through Chrome DevTools Protocol by listing Chrome targets, attaching to a page, capturing and querying network, console, navigation, and WebSocket events, and managing ephemeral sessions.81MIT
- AlicenseNot gradedqualityBmaintenanceEnables agents to observe and act on live browser pages through screenshots, bounded actions, responsive captures, console and network inspection, tab operations, and session management over local stdio or authenticated HTTP.Apache 2.0