| name | browser-bridge-cli |
| description | Control Chrome/Edge browser via CLI. Execute JS, query DOM, manage tabs, take screenshots, send CDP commands through a browser extension bridge. Use when user wants to interact with browser pages, automate browser tasks, scrape web content, or control browser tabs. |
Browser Bridge CLI
Control an already-open Chrome/Edge browser through a paired extension.
Architecture
CLI --HTTP+token--> Bridge Server (:52853) --WebSocket--> Extension (service worker) --chrome.debugger/tabs--> Browser
Prerequisites
- Node.js >= 20 or Bun >= 1.0
- Browser extension installed from the Chrome Web Store or loaded from this repository's
extension/ directory
- Bridge server running and extension paired
Setup (one-time)
npx browser-bridge-cli server start
npx browser-bridge-cli server gen-pair
Usage
npx browser-bridge-cli server start [--host 0.0.0.0] [--port 9000] [--token xxx]
npx browser-bridge-cli server stop
npx browser-bridge-cli server status
npx browser-bridge-cli server gen-pair
npx browser-bridge-cli info
npx browser-bridge-cli tabs
npx browser-bridge-cli eval "document.title" -t <tab-id>
npx browser-bridge-cli query "h1" -t <tab-id>
npx browser-bridge-cli eval-file script.js -t <tab-id>
npx browser-bridge-cli new-tab "https://example.com"
npx browser-bridge-cli navigate "https://example.com" -t <tab-id>
npx browser-bridge-cli screenshot -o page.png -t <tab-id>
npx browser-bridge-cli screenshot -f -o full.png -t <tab-id>
npx browser-bridge-cli screenshot --long --max-height 12000 -o long.png -t <tab-id>
npx browser-bridge-cli screenshot --long --hide-sticky -o long.png -t <tab-id>
npx browser-bridge-cli pdf -o page.pdf -t <tab-id>
npx browser-bridge-cli network -l 10
npx browser-bridge-cli cookies -d example.com
npx browser-bridge-cli cdp "Input.dispatchMouseEvent" '{"type":"mousePressed","x":100,"y":200,"button":"left","clickCount":1}' -t <tab-id>
npx browser-bridge-cli close-tab <tab-id>
npx browser-bridge-cli clients
npx browser-bridge-cli switch <clientId>
npx browser-bridge-cli pair
npx browser-bridge-cli unpair
npx browser-bridge-cli config get
npx browser-bridge-cli config set server http://remote:52853
npx browser-bridge-cli config reset
npx browser-bridge-cli server install-service --host 0.0.0.0 --token xxx
npx browser-bridge-cli server install-service --uninstall
CDP Examples
| Task | Command |
|---|
| Click | npx browser-bridge-cli cdp "Input.dispatchMouseEvent" '{"type":"mousePressed","x":100,"y":200,"button":"left","clickCount":1}' |
| Type | npx browser-bridge-cli cdp "Input.insertText" '{"text":"hello"}' |
| Key | npx browser-bridge-cli cdp "Input.dispatchKeyEvent" '{"type":"keyDown","key":"Enter"}' |
| DOM | npx browser-bridge-cli cdp "DOM.getDocument" |
| Mobile | npx browser-bridge-cli cdp "Emulation.setDeviceMetricsOverride" '{"width":375,"height":812,"deviceScaleFactor":3,"mobile":true}' |
Workflow
- Always run
info first to check server and extension status
- Use
tabs to find the target tab ID
- Pass
-t <tab-id> to target a specific tab (omit for active tab)
- Use
-k flag on eval/query/cdp to keep debugger attached for consecutive operations
- Run
detach when done with CDP operations to remove the debugger warning bar
- The
cdp command gives access to ALL Chrome DevTools Protocol methods