mcp-chrome-cdp
# mcp-chrome-cdp
MCP server that gives AI agents full control over Chrome through the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/). Direct WebSocket connection to Chrome — no Puppeteer, no Playwright, no overhead.
**54 tools** across 12 categories: navigation, screenshots, JavaScript execution, DOM queries, input simulation, network monitoring, console capture, cookie/storage management, device emulation, performance metrics, accessibility, and browser control.
## Quick Start
### 1. Start Chrome with remote debugging
```bash
# macOS
open -a "Google Chrome" --args --remote-debugging-port=9222
# Linux
google-chrome --remote-debugging-port=9222
# Windows
start chrome --remote-debugging-port=9222
```
### 2. Install
```bash
git clone https://github.com/YosephFr/mcp-chrome-cdp.git
cd mcp-chrome-cdp
npm install
```
### 3. Add to Claude Code
Create or edit `~/.mcp.json`:
```json
{
"mcpServers": {
"chrome-cdp": {
"command": "node",
"args": ["/absolute/path/to/mcp-chrome-cdp/index.js"]
}
}
}
```
Restart Claude Code. Verify with `/mcp` — you should see `chrome-cdp` connected.
### 4. Configuration
The server connects to `127.0.0.1:9222` by default. Override with environment variables:
```json
{
"mcpServers": {
"chrome-cdp": {
"command": "node",
"args": ["/absolute/path/to/mcp-chrome-cdp/index.js"],
"env": {
"CDP_HOST": "127.0.0.1",
"CDP_PORT": "9222"
}
}
}
}
```
## Tools
### Tabs
| Tool | Description |
|------|-------------|
| `chrome_list_tabs` | List all open tabs and targets |
| `chrome_new_tab` | Open a new tab with optional URL |
| `chrome_close_tab` | Close a tab by ID |
| `chrome_activate_tab` | Bring a tab to the foreground |
### Navigation
| Tool | Description |
|------|-------------|
| `chrome_navigate` | Navigate to a URL (waits for page load) |
| `chrome_reload` | Reload the page, optionally bypassing cache |
| `chrome_go_back` | Navigate back in history |
| `chrome_go_forward` | Navigate forward in history |
| `chrome_get_url` | Get the current URL |
| `chrome_wait` | Wait for a selector to appear or a fixed delay |
### Screenshots & PDF
| Tool | Description |
|------|-------------|
| `chrome_screenshot` | Capture PNG/JPEG/WebP screenshot (viewport, full page, or clipped region) |
| `chrome_pdf` | Generate PDF of the current page |
### JavaScript & DOM
| Tool | Description |
|------|-------------|
| `chrome_evaluate` | Execute arbitrary JavaScript in the page context |
| `chrome_query_selector` | Find elements by CSS selector, return HTML or attributes |
| `chrome_get_text` | Get visible text content of the page or an element |
| `chrome_get_html` | Get outerHTML or innerHTML of the page or an element |
| `chrome_get_page_info` | Get URL, title, meta tags, forms, links, and page dimensions |
| `chrome_find_elements` | Find interactive elements (buttons, links, inputs) with coordinates |
### Input
| Tool | Description |
|------|-------------|
| `chrome_click` | Click by CSS selector or coordinates (left/right/middle, double-click) |
| `chrome_hover` | Hover over an element |
| `chrome_type` | Type text into a focused element or selector |
| `chrome_key_press` | Press keys or combos (Enter, Tab, Ctrl+A, etc.) |
| `chrome_scroll` | Scroll the page or a specific element |
| `chrome_set_input_value` | Set input values programmatically (React/Vue/Angular compatible) |
| `chrome_drag_drop` | Drag from one point to another |
| `chrome_touch` | Dispatch touch events for mobile emulation |
### Network Monitoring
| Tool | Description |
|------|-------------|
| `chrome_network_enable` | Start capturing network requests and responses |
| `chrome_network_disable` | Stop network monitoring |
| `chrome_network_get_log` | Get captured traffic, filter by URL, limit results |
| `chrome_network_get_response_body` | Get the response body for a specific request |
| `chrome_set_extra_headers` | Set custom HTTP headers on all requests |
| `chrome_emulate_network` | Simulate slow 3G, offline mode, custom latency |
### Console
| Tool | Description |
|------|-------------|
| `chrome_console_enable` | Start capturing console messages |
| `chrome_console_get_log` | Get captured messages, filter by level |
| `chrome_console_clear` | Clear the console |
### Cookies & Storage
| Tool | Description |
|------|-------------|
| `chrome_get_cookies` | Get cookies for current page or specific URLs |
| `chrome_set_cookie` | Set a cookie with full options |
| `chrome_delete_cookies` | Delete specific cookies or clear all |
| `chrome_local_storage` | Get, set, remove, clear, or list localStorage keys |
| `chrome_clear_storage` | Clear all site data for an origin (cookies, localStorage, cache, indexedDB) |
### Device Emulation
| Tool | Description |
|------|-------------|
| `chrome_emulate_device` | Set viewport size, device scale factor, mobile mode |
| `chrome_reset_device` | Reset to real device metrics |
| `chrome_set_user_agent` | Override the User-Agent string |
| `chrome_set_geolocation` | Override GPS coordinates |
| `chrome_set_timezone` | Override timezone |
| `chrome_emulate_media` | Set media type (print/screen) and features (dark mode, etc.) |
### Performance & Accessibility
| Tool | Description |
|------|-------------|
| `chrome_performance_metrics` | Get JS heap size, DOM nodes, layout counts, script duration |
| `chrome_accessibility_tree` | Get the full accessibility tree (roles, names, values) |
### Security & Advanced
| Tool | Description |
|------|-------------|
| `chrome_handle_dialog` | Accept or dismiss alert/confirm/prompt dialogs |
| `chrome_inject_script` | Inject JS that runs before page scripts on every navigation |
| `chrome_set_bypass_csp` | Bypass Content Security Policy |
| `chrome_ignore_certificate_errors` | Ignore SSL/TLS certificate errors |
### Browser
| Tool | Description |
|------|-------------|
| `chrome_browser_info` | Get browser version, protocol version, V8 version |
| `chrome_set_window_bounds` | Resize, move, minimize, maximize, or fullscreen the window |
## Architecture
```
Claude Code <--> MCP (stdio) <--> Chrome CDP (WebSocket)
index.js ws://127.0.0.1:9222
```
- Single persistent WebSocket connection per tab (auto-reconnects on tab switch)
- Network and console events are captured in-memory and served on demand
- No browser process management — connects to an already-running Chrome instance
- Zero dependencies beyond the MCP SDK and `ws`
## Requirements
- Node.js >= 18
- Chrome, Chromium, or Edge running with `--remote-debugging-port=9222`
- Claude Code (or any MCP-compatible client)
## License
MIT
TDQS
Scored across 54 tools
Most tools have clear distinct actions, but there is a significant overlap cluster for content extraction (chrome_get_text, chrome_get_html, chrome_query_selector, chrome_get_page_info, chrome_find_elements, chrome_accessibility_tree) where an agent could easily pick the wrong one. Input/interaction tools (click, touch, drag_drop) and storage tools (local_storage, clear_storage, cookies) also have partially overlapping boundaries, though descriptions mitigate this.
All tools share a consistent chrome_ prefix and snake_case naming, which is highly predictable. Minor deviations exist where some names are noun-only (chrome_pdf, chrome_screenshot, chrome_wait) or use non-verb forms (chrome_new_tab, chrome_go_back), but overall the pattern is readable and stable.
54 tools is well above the 25+ threshold and feels heavy for a browser automation surface, with several niche capabilities (timezone, geolocation, bypass_csp, ignore_certificate_errors) that could be consolidated. While a CDP server legitimately spans many domains, the sheer count increases selection burden.
Coverage is broad: navigation, tabs, input, screenshots/PDF, network and console monitoring, cookies/storage, emulation, performance, and accessibility. Minor gaps exist around request interception/mocking (only monitoring and header overrides), iframe/frame switching, and file upload/download, but agents can work around most of these.