| name | chrome-cdp |
| description | Interact with local Chrome browser session (only on explicit user approval after being asked to inspect, debug, or interact with a page open in Chrome) |
Chrome CDP
Lightweight Chrome DevTools Protocol CLI. Connects via WebSocket — no Puppeteer, works with 100+ tabs, instant connection.
Prerequisites
- Chrome (or Chromium, Brave, Edge, Vivaldi) with remote debugging enabled:
chrome://inspect/#remote-debugging → toggle switch
- Bun (or Node.js 22+)
- If your browser's
DevToolsActivePort is in a non-standard location, set CDP_PORT_FILE to its full path
Core workflow
scripts/cdp.mjs list
scripts/cdp.mjs snap <target>
scripts/cdp.mjs shot <target> [file]
scripts/cdp.mjs eval <target> <expr>
<target> is a unique targetId prefix from list (e.g. 6BE827FA). Ambiguous prefixes are rejected.
Other commands
scripts/cdp.mjs html <target> [selector]
scripts/cdp.mjs nav <target> <url>
scripts/cdp.mjs net <target>
scripts/cdp.mjs click <target> <selector>
scripts/cdp.mjs clickxy <target> <x> <y>
scripts/cdp.mjs type <target> <text>
scripts/cdp.mjs loadall <target> <selector> [ms]
scripts/cdp.mjs evalraw <target> <method> [json]
scripts/cdp.mjs open [url]
scripts/cdp.mjs stop [target]
Tips
shot output is native resolution (CSS px × DPR). clickxy takes CSS pixels: divide screenshot coords by DPR.
- Prefer
snap over html for understanding page structure — much smaller output.
- Use
type (not eval) for cross-origin iframes — click/clickxy to focus first, then type.
- Avoid index-based DOM selection across multiple
eval calls when the DOM can change between them. Use stable selectors or collect all data in one eval.
- Chrome shows an "Allow debugging" modal once per tab. A daemon keeps the session alive; auto-exits after 20 min idle.
Credits
Based on pasky/chrome-cdp-skill by Petr Baudiš. MIT License.