chromex-mcp 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +211 -84
- package/bin/chromex.mjs +2 -0
- package/package.json +3 -2
- package/plugins/chromex/skills/chromex/scripts/chromex.mjs +27 -7
- package/plugins/chromex/skills/chromex/scripts/lib/client.mjs +1 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/audit.mjs +182 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/console.mjs +32 -2
- package/plugins/chromex/skills/chromex/scripts/lib/commands/emulate.mjs +15 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/interact.mjs +15 -5
- package/plugins/chromex/skills/chromex/scripts/lib/commands/keyboard.mjs +123 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/navigate.mjs +26 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/network.mjs +67 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/refs.mjs +11 -4
- package/plugins/chromex/skills/chromex/scripts/lib/commands/screenshot.mjs +32 -5
- package/plugins/chromex/skills/chromex/scripts/lib/commands/stats.mjs +80 -0
- package/plugins/chromex/skills/chromex/scripts/lib/daemon.mjs +134 -16
- package/plugins/chromex/skills/chromex/scripts/lib/launcher.mjs +8 -0
- package/plugins/chromex/skills/chromex/scripts/mcp-server.mjs +85 -17
package/README.md
CHANGED
|
@@ -1,50 +1,87 @@
|
|
|
1
1
|
# Chromex
|
|
2
2
|
|
|
3
|
-
Zero-dependency Chrome DevTools Protocol
|
|
4
|
-
|
|
5
|
-
Built as a [Claude Code](https://claude.ai/code) plugin but works standalone with any AI agent or from the terminal.
|
|
3
|
+
Zero-dependency Chrome DevTools Protocol toolkit for AI agents. 56 typed MCP tools + CLI. Connects directly to Chrome, Brave, Edge, or Chromium via WebSocket. No Puppeteer, no bloat.
|
|
6
4
|
|
|
7
5
|
## Features
|
|
8
6
|
|
|
9
|
-
- **
|
|
7
|
+
- **56 MCP tools** -- typed JSON Schema, annotations (`readOnlyHint`, `destructiveHint`), inline screenshots (base64)
|
|
10
8
|
- **Zero dependencies** -- uses only Node.js 22+ built-in modules (WebSocket, fs, net, crypto)
|
|
11
9
|
- **Ref-based selection** -- `snap --refs` assigns `@e1`, `@e2`... to interactive elements, then `click @e5` or `fill @e3 "value"`. No fragile CSS selectors
|
|
10
|
+
- **Incremental snapshots** -- second snapshot returns only changed nodes (diff), reducing output from thousands of lines to just what changed
|
|
11
|
+
- **Auto-snapshot** -- interactive commands (click, fill, nav, etc.) automatically append an incremental snapshot with refs, so the agent sees the page state in a single round-trip
|
|
12
|
+
- **Scroll detection** -- snapshots report scrollable containers with remaining distance (`[scroll: page: down:1200px | sidebar: up:300px]`)
|
|
12
13
|
- **Per-tab persistent daemons** -- each tab gets a background process connected via Unix socket. Chrome's "Allow debugging" modal fires once, not on every command
|
|
13
14
|
- **Security hardened** -- domain filtering (allow/blocklist), CDP method blocklist, token-authenticated sockets, full audit log
|
|
14
15
|
- **Multi-browser** -- auto-detects Brave, Chrome, Chrome Canary, Chromium, Edge, Vivaldi (macOS + Linux)
|
|
15
16
|
- **Network control** -- throttle to 3G/offline, intercept & mock requests, record HAR files
|
|
16
17
|
- **Form filling** -- fill inputs, select dropdowns, toggle checkboxes, upload files, batch fill entire forms. Works with React/Vue/Angular
|
|
17
18
|
- **Browser launcher** -- launch browser with remote debugging pre-enabled (skips the "Allow debugging" modal entirely)
|
|
19
|
+
- **CLI included** -- same commands available from the terminal for scripts and CI/CD
|
|
18
20
|
|
|
19
21
|
## Requirements
|
|
20
22
|
|
|
21
23
|
- Node.js 22+ (for built-in WebSocket)
|
|
22
24
|
- Any Chromium-based browser
|
|
23
25
|
|
|
24
|
-
##
|
|
25
|
-
|
|
26
|
-
### As a Claude Code plugin
|
|
26
|
+
## Installation
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
# Add
|
|
30
|
-
|
|
29
|
+
# Add to Claude Code (global -- all projects)
|
|
30
|
+
claude mcp add chromex -s user npx chromex-mcp@latest
|
|
31
|
+
|
|
32
|
+
# Or project-only
|
|
33
|
+
claude mcp add chromex npx chromex-mcp@latest
|
|
34
|
+
```
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
### Auto-Approve (recommended)
|
|
37
|
+
|
|
38
|
+
Add to `~/.claude/settings.json`:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"permissions": {
|
|
43
|
+
"allow": ["mcp__chromex"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This approves all 56 MCP tools at once. For granular control, approve individual tools:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"permissions": {
|
|
53
|
+
"allow": [
|
|
54
|
+
"mcp__chromex__chromex_list",
|
|
55
|
+
"mcp__chromex__chromex_snapshot",
|
|
56
|
+
"mcp__chromex__chromex_screenshot",
|
|
57
|
+
"mcp__chromex__chromex_perf"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
34
61
|
```
|
|
35
62
|
|
|
36
|
-
###
|
|
63
|
+
### Global install (optional)
|
|
37
64
|
|
|
38
65
|
```bash
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
npm install -g chromex-mcp
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This installs three binaries:
|
|
42
70
|
|
|
43
|
-
|
|
44
|
-
|
|
71
|
+
| Binary | Purpose |
|
|
72
|
+
|--------|---------|
|
|
73
|
+
| `chromex` | CLI -- the main command for terminal usage |
|
|
74
|
+
| `chromex-cli` | Alias for `chromex` |
|
|
75
|
+
| `chromex-mcp` | MCP server (stdio JSON-RPC) -- used by `claude mcp add`, not run directly |
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
chromex list # List open tabs
|
|
79
|
+
chromex launch --url https://example.com # Launch browser
|
|
80
|
+
chromex snap 6BE8 --refs # Snapshot with refs
|
|
81
|
+
chromex click 6BE8 @e3 # Click by ref
|
|
45
82
|
```
|
|
46
83
|
|
|
47
|
-
|
|
84
|
+
## Connect to Your Browser
|
|
48
85
|
|
|
49
86
|
**Option A: Launch a new browser** (recommended -- no setup needed)
|
|
50
87
|
|
|
@@ -56,8 +93,6 @@ This starts Chrome/Brave/Edge with remote debugging pre-enabled. No manual confi
|
|
|
56
93
|
|
|
57
94
|
**Option B: Connect to an already-running browser**
|
|
58
95
|
|
|
59
|
-
You **must** enable remote debugging first:
|
|
60
|
-
|
|
61
96
|
1. Open your browser (Chrome, Brave, Edge, etc.)
|
|
62
97
|
2. Navigate to `chrome://inspect/#remote-debugging`
|
|
63
98
|
3. **Toggle the switch ON** to enable remote debugging
|
|
@@ -67,11 +102,7 @@ You **must** enable remote debugging first:
|
|
|
67
102
|
|
|
68
103
|
> **Note:** With Option B, Chrome will show an "Allow debugging" dialog the first time you access each tab. Click "Allow" once per tab -- the daemon keeps the session alive after that.
|
|
69
104
|
|
|
70
|
-
|
|
71
|
-
chromex list
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Your first commands
|
|
105
|
+
## Quick Start
|
|
75
106
|
|
|
76
107
|
```bash
|
|
77
108
|
# List open tabs
|
|
@@ -110,6 +141,10 @@ chromex close <target> # Close tab
|
|
|
110
141
|
chromex focus <target> # Activate/focus tab
|
|
111
142
|
chromex launch # Launch browser with debugging
|
|
112
143
|
chromex launch --incognito --browser brave # Launch Brave in incognito
|
|
144
|
+
chromex launch --headless --url https://example.com # Headless mode for CI/CD
|
|
145
|
+
chromex launch --proxy socks5://localhost:1080 # Launch with proxy
|
|
146
|
+
chromex launch --insecure # Ignore certificate errors
|
|
147
|
+
chromex launch --chrome-arg --disable-web-security # Pass custom Chrome flag
|
|
113
148
|
chromex launch --profile testing --url https://... # Isolated profile + URL
|
|
114
149
|
chromex incognito https://example.com # Isolated context (no relaunch)
|
|
115
150
|
chromex stop # Stop all daemons
|
|
@@ -118,14 +153,21 @@ chromex stop # Stop all daemons
|
|
|
118
153
|
### Inspect
|
|
119
154
|
|
|
120
155
|
```bash
|
|
121
|
-
chromex snap <target> # Accessibility tree (
|
|
156
|
+
chromex snap <target> # Accessibility tree snapshot (compact)
|
|
122
157
|
chromex snap <target> --refs # With interactive refs (@e1, @e2...)
|
|
158
|
+
chromex snap <target> --depth=3 # Limit tree depth
|
|
159
|
+
chromex snap <target> --full # Force full snapshot (skip diff)
|
|
123
160
|
chromex html <target> "#main" # Element HTML by selector
|
|
124
161
|
chromex shot <target> /tmp/page.png # Viewport screenshot
|
|
125
162
|
chromex shot <target> /tmp/full.png --full # Full page screenshot
|
|
126
|
-
chromex
|
|
163
|
+
chromex shot <target> --format=jpeg --quality=80 # JPEG/WebP with quality control
|
|
164
|
+
chromex shot <target> @e5 # Screenshot of specific element by ref
|
|
165
|
+
chromex net <target> # List network requests (CDP tracked)
|
|
166
|
+
chromex net <target> <requestId> # Request detail: headers, timing, body
|
|
127
167
|
chromex perf <target> # Core Web Vitals + memory + DOM stats
|
|
128
168
|
chromex console <target> 5000 # Capture console.log/error for 5s
|
|
169
|
+
chromex console <target> list # Show stored messages since daemon start
|
|
170
|
+
chromex console <target> detail <id> # Message detail with stack trace
|
|
129
171
|
chromex domsnapshot <target> # Structured DOM with bounding rects
|
|
130
172
|
chromex domsnapshot <target> --styles # Include computed styles
|
|
131
173
|
chromex highlight <target> "h1" # Highlight element with overlay
|
|
@@ -145,14 +187,20 @@ chromex evalraw <target> "Page.getLayoutMetrics" # Layout info
|
|
|
145
187
|
|
|
146
188
|
```bash
|
|
147
189
|
chromex nav <target> "https://example.com" # Navigate + wait for load
|
|
190
|
+
chromex nav <target> back # Go back in history
|
|
191
|
+
chromex nav <target> forward # Go forward in history
|
|
192
|
+
chromex nav <target> reload # Reload page
|
|
193
|
+
chromex nav <target> reload-hard # Reload ignoring cache
|
|
148
194
|
chromex waitfor <target> ".results" 10000 # Wait for CSS selector (10s)
|
|
149
195
|
chromex wait <target> networkidle # Wait for network idle
|
|
150
196
|
chromex wait <target> load # Wait for page load
|
|
151
197
|
chromex wait <target> domready # Wait for DOMContentLoaded
|
|
152
198
|
chromex wait <target> fcp # Wait for First Contentful Paint
|
|
153
199
|
chromex scroll <target> down 500 # Scroll down 500px
|
|
154
|
-
chromex scroll <target>
|
|
200
|
+
chromex scroll <target> up 300 # Scroll up 300px
|
|
155
201
|
chromex scroll <target> top # Scroll to top
|
|
202
|
+
chromex scroll <target> bottom # Scroll to bottom
|
|
203
|
+
chromex scroll <target> to "#footer" # Scroll to element
|
|
156
204
|
```
|
|
157
205
|
|
|
158
206
|
### Interact
|
|
@@ -160,7 +208,12 @@ chromex scroll <target> top # Scroll to top
|
|
|
160
208
|
```bash
|
|
161
209
|
chromex click <target> "button.submit" # Click by CSS selector
|
|
162
210
|
chromex click <target> @e5 # Click by ref (from snap --refs)
|
|
211
|
+
chromex click <target> @e5 --dbl # Double-click
|
|
163
212
|
chromex clickxy <target> 100 200 # Click at CSS pixel coords
|
|
213
|
+
chromex clickxy <target> 100 200 --dbl # Double-click at coords
|
|
214
|
+
chromex key <target> Enter # Press key
|
|
215
|
+
chromex key <target> "Control+A" # Key combination
|
|
216
|
+
chromex key <target> "Control+Shift+R" # Multi-modifier combo
|
|
164
217
|
chromex type <target> "hello world" # Type text (works cross-origin)
|
|
165
218
|
chromex hover <target> @e12 # Hover element by ref
|
|
166
219
|
chromex drag <target> "#source" "#dest" # Drag & drop by selector
|
|
@@ -207,6 +260,7 @@ chromex pdf <target> /tmp/page.pdf # Export as PDF
|
|
|
207
260
|
```bash
|
|
208
261
|
chromex throttle <target> 3g # Throttle to 3G
|
|
209
262
|
chromex throttle <target> slow-3g # Throttle to slow 3G
|
|
263
|
+
chromex throttle <target> 4g # Throttle to 4G
|
|
210
264
|
chromex throttle <target> offline # Go offline
|
|
211
265
|
chromex throttle <target> custom 200 1000 500 # Custom: latency, down, up (kbps)
|
|
212
266
|
chromex throttle <target> reset # Remove throttling
|
|
@@ -224,10 +278,16 @@ chromex har <target> stop /tmp/trace.har # Save HAR file
|
|
|
224
278
|
|
|
225
279
|
```bash
|
|
226
280
|
chromex emulate <target> iphone-14 # 390x844 @3x mobile
|
|
281
|
+
chromex emulate <target> iphone-15-pro # 393x852 @3x mobile
|
|
227
282
|
chromex emulate <target> ipad-pro # 1024x1366 @2x tablet
|
|
228
283
|
chromex emulate <target> pixel-7 # 412x915 @2.625x mobile
|
|
284
|
+
chromex emulate <target> galaxy-s23 # 360x780 @3x mobile
|
|
285
|
+
chromex emulate <target> macbook-air # 1440x900 @2x laptop
|
|
286
|
+
chromex emulate <target> desktop-1080p # 1920x1080 @1x
|
|
229
287
|
chromex emulate <target> desktop-4k # 3840x2160 @1x
|
|
230
288
|
chromex emulate <target> reset # Reset to default
|
|
289
|
+
chromex resize <target> 1280 720 # Custom viewport dimensions
|
|
290
|
+
chromex resize <target> 1440 900 2 # Custom with DPR (retina)
|
|
231
291
|
chromex geo <target> -23.55 -46.63 # Set geolocation (Sao Paulo)
|
|
232
292
|
chromex geo <target> reset # Clear geolocation
|
|
233
293
|
chromex timezone <target> "America/Sao_Paulo" # Set timezone
|
|
@@ -236,8 +296,6 @@ chromex cpu <target> 4 # CPU 4x slower
|
|
|
236
296
|
chromex cpu <target> reset # Reset CPU speed
|
|
237
297
|
```
|
|
238
298
|
|
|
239
|
-
Available devices: `iphone-14`, `iphone-15-pro`, `ipad-pro`, `pixel-7`, `galaxy-s23`, `macbook-air`, `desktop-1080p`, `desktop-4k`.
|
|
240
|
-
|
|
241
299
|
### Advanced
|
|
242
300
|
|
|
243
301
|
```bash
|
|
@@ -257,6 +315,18 @@ chromex webauthn <target> creds # List stored credentials
|
|
|
257
315
|
chromex webauthn <target> disable # Remove authenticator
|
|
258
316
|
```
|
|
259
317
|
|
|
318
|
+
### Audit & Analytics
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
chromex audit <target> # Full Lighthouse audit (all categories)
|
|
322
|
+
chromex audit <target> performance,seo # Specific categories
|
|
323
|
+
chromex audit <target> accessibility desktop # Accessibility on desktop
|
|
324
|
+
chromex stats <target> # Session analytics (command counts, timing)
|
|
325
|
+
chromex stats <target> --full # Full action timeline
|
|
326
|
+
chromex stats <target> --reset # Reset counters
|
|
327
|
+
chromex stats <target> --export=/tmp/stats.json # Export as JSON
|
|
328
|
+
```
|
|
329
|
+
|
|
260
330
|
## Ref-Based Selection
|
|
261
331
|
|
|
262
332
|
The killer feature for AI agents. Instead of fragile CSS selectors, use numbered refs:
|
|
@@ -278,73 +348,127 @@ chromex click <target> @e3
|
|
|
278
348
|
chromex click <target> @e4
|
|
279
349
|
```
|
|
280
350
|
|
|
281
|
-
Refs are assigned to all interactive elements (buttons, links, inputs, checkboxes, radios, dropdowns, tabs, switches). They persist until the next `snap --refs` call.
|
|
351
|
+
Refs are assigned to all interactive elements (buttons, links, inputs, checkboxes, radios, dropdowns, tabs, switches, sliders, search boxes). They persist until the next `snap --refs` call.
|
|
282
352
|
|
|
283
353
|
Supported ref commands: `click @eN`, `fill @eN "value"`, `hover @eN`.
|
|
284
354
|
|
|
285
|
-
##
|
|
355
|
+
## Snapshot Optimizations
|
|
356
|
+
|
|
357
|
+
Chromex snapshots are designed to minimize token usage for AI agents.
|
|
358
|
+
|
|
359
|
+
### Incremental Diff
|
|
360
|
+
|
|
361
|
+
The first snapshot returns the full accessibility tree. Subsequent snapshots return only nodes that changed:
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
[incremental: 2 changed, 45 unchanged]
|
|
365
|
+
*[textbox] Email = "user@example.com"
|
|
366
|
+
*[button] Submit
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
- Changed/new nodes are marked with `*`
|
|
370
|
+
- Unchanged subtrees are collapsed entirely
|
|
371
|
+
- Use `--full` to force a full snapshot (skips diff)
|
|
372
|
+
- Navigation (`nav`) resets the diff baseline automatically
|
|
286
373
|
|
|
287
|
-
|
|
374
|
+
### Depth Limiting
|
|
288
375
|
|
|
289
|
-
|
|
376
|
+
Limit tree depth for large pages:
|
|
290
377
|
|
|
291
378
|
```bash
|
|
292
|
-
#
|
|
293
|
-
|
|
379
|
+
chromex snap <target> --depth=3 # Only 3 levels deep
|
|
380
|
+
```
|
|
294
381
|
|
|
295
|
-
|
|
296
|
-
|
|
382
|
+
Nodes at the depth limit render as leaves (children are not expanded).
|
|
383
|
+
|
|
384
|
+
### Scroll Detection
|
|
385
|
+
|
|
386
|
+
Snapshots automatically detect scrollable containers and report remaining scroll distance:
|
|
387
|
+
|
|
388
|
+
```
|
|
389
|
+
[scroll: page: down:1200px | sidebar: up:300px, down:800px]
|
|
297
390
|
```
|
|
298
391
|
|
|
299
|
-
###
|
|
392
|
+
### Visibility Filtering
|
|
300
393
|
|
|
301
|
-
|
|
394
|
+
- Ignored/hidden accessibility nodes are automatically omitted
|
|
395
|
+
- Disabled interactive elements are shown but not assigned refs (can't be interacted with)
|
|
396
|
+
- Generic wrapper nodes (`div`, `span` with no semantic role) are collapsed -- their children inherit the parent's depth
|
|
397
|
+
- Names longer than 200 characters are truncated with `...`
|
|
302
398
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
399
|
+
## Auto-Snapshot
|
|
400
|
+
|
|
401
|
+
Interactive commands automatically append an incremental snapshot with refs after execution. This lets the AI agent see the updated page state without a separate `snap` call:
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
chromex click <target> @e3
|
|
405
|
+
# Output:
|
|
406
|
+
# Clicked @e3 [button] "Submit"
|
|
407
|
+
#
|
|
408
|
+
# [incremental: 5 changed, 40 unchanged]
|
|
409
|
+
# @e1 [heading] Thank you!
|
|
410
|
+
# @e2 [link] Back to home
|
|
411
|
+
# ...
|
|
309
412
|
```
|
|
310
413
|
|
|
311
|
-
|
|
414
|
+
Commands that trigger auto-snapshot: `click`, `clickxy`, `type`, `key`, `fill`, `clear`, `select`, `check`, `form`, `nav`, `dialog`, `loadall`, `drag`, `touch`, `upload`.
|
|
312
415
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
"mcp__chromex__chromex_screenshot",
|
|
320
|
-
"mcp__chromex__chromex_perf"
|
|
321
|
-
]
|
|
322
|
-
}
|
|
323
|
-
}
|
|
416
|
+
Suppress with `--no-snap` for scripts doing rapid sequential actions:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
chromex fill <target> @e1 "user@test.com" --no-snap
|
|
420
|
+
chromex fill <target> @e2 "secret123" --no-snap
|
|
421
|
+
chromex click <target> @e3 # Only this one triggers snapshot
|
|
324
422
|
```
|
|
325
423
|
|
|
326
|
-
|
|
424
|
+
## MCP vs CLI
|
|
425
|
+
|
|
426
|
+
Both interfaces call the same core, same daemons, same commands. The difference is how they integrate with Claude Code.
|
|
327
427
|
|
|
328
|
-
| | CLI (
|
|
428
|
+
| | CLI (`chromex-cli`) | MCP Server (`chromex-mcp`) |
|
|
329
429
|
|---|---|---|
|
|
330
|
-
|
|
|
430
|
+
| Token overhead | Zero schema cost | ~500 tokens per tool used (deferred loading) |
|
|
431
|
+
| Auto-approve | Glob pattern in settings | `"mcp__chromex"` -- one line |
|
|
331
432
|
| Permissions | All-or-nothing | Per-tool granularity |
|
|
332
433
|
| Parameters | Positional string args | Typed JSON Schema |
|
|
333
|
-
|
|
|
334
|
-
|
|
|
335
|
-
|
|
434
|
+
| Screenshots | File path (needs `Read` to view) | Inline image (base64, no extra call) |
|
|
435
|
+
| Best for | Terminal, scripts, CI/CD, token-sensitive sessions | Plug-and-play automation, users who want zero-config |
|
|
436
|
+
|
|
437
|
+
### Switching Between MCP and CLI
|
|
438
|
+
|
|
439
|
+
You can enable and disable the MCP server at any time. The CLI always works regardless.
|
|
440
|
+
|
|
441
|
+
**Disable MCP** (saves ~3-5k tokens per session):
|
|
336
442
|
|
|
337
|
-
|
|
443
|
+
```bash
|
|
444
|
+
claude mcp remove chromex
|
|
445
|
+
```
|
|
338
446
|
|
|
339
|
-
|
|
447
|
+
The CLI (`chromex-cli`) continues working normally -- same commands, same daemons, no change.
|
|
448
|
+
|
|
449
|
+
**Re-enable MCP:**
|
|
340
450
|
|
|
341
451
|
```bash
|
|
342
|
-
|
|
343
|
-
chromex-
|
|
344
|
-
|
|
452
|
+
# Global (all projects)
|
|
453
|
+
claude mcp add chromex -s user npx chromex-mcp@latest
|
|
454
|
+
|
|
455
|
+
# Project-only
|
|
456
|
+
claude mcp add chromex npx chromex-mcp@latest
|
|
345
457
|
```
|
|
346
458
|
|
|
347
|
-
|
|
459
|
+
**When to disable MCP:**
|
|
460
|
+
- Token-sensitive sessions where every token counts
|
|
461
|
+
- You only need occasional commands (`list`, `snap`, `shot`)
|
|
462
|
+
- You're already comfortable with the CLI syntax
|
|
463
|
+
- You're using chromex from terminal/scripts, not from Claude Code
|
|
464
|
+
|
|
465
|
+
**When to keep MCP enabled:**
|
|
466
|
+
- Automating multi-step browser workflows (snap -> click -> fill -> snap)
|
|
467
|
+
- You want per-tool auto-approve without glob patterns
|
|
468
|
+
- You want inline screenshots without a separate `Read` call
|
|
469
|
+
- First time using chromex (discovery via tool schema)
|
|
470
|
+
|
|
471
|
+
### CLI Auto-Approve
|
|
348
472
|
|
|
349
473
|
If you prefer the CLI interface, add this to `~/.claude/settings.json`:
|
|
350
474
|
|
|
@@ -352,14 +476,12 @@ If you prefer the CLI interface, add this to `~/.claude/settings.json`:
|
|
|
352
476
|
{
|
|
353
477
|
"permissions": {
|
|
354
478
|
"allow": [
|
|
355
|
-
"Bash(
|
|
479
|
+
"Bash(chromex-cli *)"
|
|
356
480
|
]
|
|
357
481
|
}
|
|
358
482
|
}
|
|
359
483
|
```
|
|
360
484
|
|
|
361
|
-
> **Warning:** This approves all chromex commands without distinction. The security config (`~/.chromex/config.json`) still applies -- domain filtering, CDP blocklist, and audit log remain active.
|
|
362
|
-
|
|
363
485
|
## Security
|
|
364
486
|
|
|
365
487
|
Config at `~/.chromex/config.json` (auto-created on first run):
|
|
@@ -376,11 +498,26 @@ Config at `~/.chromex/config.json` (auto-created on first run):
|
|
|
376
498
|
|
|
377
499
|
- **Domain filtering**: block sensitive sites or restrict to a whitelist
|
|
378
500
|
- **CDP blocklist**: dangerous methods blocked by default in `evalraw`
|
|
379
|
-
- **Socket auth**: 32-byte random token per session
|
|
501
|
+
- **Socket auth**: 32-byte random token per session (mode 0600)
|
|
380
502
|
- **Audit log**: every command logged with timestamp and status
|
|
381
503
|
|
|
382
504
|
See [docs/security.md](docs/security.md) for full details.
|
|
383
505
|
|
|
506
|
+
## How It Works
|
|
507
|
+
|
|
508
|
+
1. **Browser detection** -- scans ~30 paths for `DevToolsActivePort` (or use `CDP_PORT_FILE` env var)
|
|
509
|
+
2. **Daemon spawn** -- first command to a tab spawns a background Node.js process connected via CDP WebSocket
|
|
510
|
+
3. **Session persistence** -- daemon holds the session open; Chrome's "Allow" modal fires once per daemon
|
|
511
|
+
4. **Unix sockets** -- CLI/MCP communicates with daemon via authenticated Unix sockets
|
|
512
|
+
5. **Auto-exit** -- daemons shut down after 20 minutes of inactivity (configurable)
|
|
513
|
+
|
|
514
|
+
```
|
|
515
|
+
CLI Client ──Unix Socket + Auth──> Per-Tab Daemon ──CDP WebSocket──> Chrome
|
|
516
|
+
MCP Server ──Unix Socket + Auth──> (same) ──CDP WebSocket──> Chrome
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
See [docs/architecture.md](docs/architecture.md) for the full deep dive.
|
|
520
|
+
|
|
384
521
|
## Documentation
|
|
385
522
|
|
|
386
523
|
| Guide | Description |
|
|
@@ -396,16 +533,6 @@ See [docs/security.md](docs/security.md) for full details.
|
|
|
396
533
|
| [Advanced](docs/advanced.md) | Script injection, code coverage, tracing, heap snapshots, WebAuthn |
|
|
397
534
|
| [Architecture](docs/architecture.md) | How it works: daemon model, connection modes, file layout |
|
|
398
535
|
|
|
399
|
-
## How It Works
|
|
400
|
-
|
|
401
|
-
1. **Browser detection** -- scans ~30 paths for `DevToolsActivePort` (or use `CDP_PORT_FILE` env var)
|
|
402
|
-
2. **Daemon spawn** -- first command to a tab spawns a background Node.js process connected via CDP WebSocket
|
|
403
|
-
3. **Session persistence** -- daemon holds the session open; Chrome's "Allow" modal fires once per daemon
|
|
404
|
-
4. **Unix sockets** -- CLI communicates with daemon via authenticated Unix sockets
|
|
405
|
-
5. **Auto-exit** -- daemons shut down after 20 minutes of inactivity (configurable)
|
|
406
|
-
|
|
407
|
-
See [docs/architecture.md](docs/architecture.md) for the full deep dive.
|
|
408
|
-
|
|
409
536
|
## License
|
|
410
537
|
|
|
411
538
|
MIT
|
package/bin/chromex.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chromex-mcp",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Zero-dependency Chrome DevTools Protocol MCP server for AI agents.
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Zero-dependency Chrome DevTools Protocol MCP server for AI agents. 56 typed tools, per-tab daemons, security hardened.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
+
"chromex": "./bin/chromex.mjs",
|
|
7
8
|
"chromex-mcp": "./bin/chromex-mcp.mjs",
|
|
8
9
|
"chromex-cli": "./bin/chromex-cli.mjs"
|
|
9
10
|
},
|
|
@@ -27,7 +27,7 @@ const NEEDS_TARGET = new Set([
|
|
|
27
27
|
'intercept', 'har', 'coverage',
|
|
28
28
|
// Tier 3
|
|
29
29
|
'trace', 'heap', 'webauthn', 'drag', 'touch', 'domsnapshot', 'highlight',
|
|
30
|
-
'hover',
|
|
30
|
+
'hover', 'key', 'resize', 'audit', 'stats',
|
|
31
31
|
]);
|
|
32
32
|
|
|
33
33
|
const USAGE = `chromex - Chrome DevTools Protocol CLI for AI agents
|
|
@@ -44,15 +44,25 @@ Usage: chromex <command> [args]
|
|
|
44
44
|
--browser chrome|brave|edge Choose browser
|
|
45
45
|
--profile NAME Use named profile
|
|
46
46
|
--url URL Open URL on launch
|
|
47
|
+
--headless Launch in headless mode (no UI)
|
|
48
|
+
--proxy PROXY Proxy server (e.g. socks5://localhost:1080)
|
|
49
|
+
--insecure Ignore certificate errors
|
|
50
|
+
--chrome-arg FLAG Pass custom Chrome flag (e.g. --chrome-arg --disable-web-security)
|
|
47
51
|
incognito [url] Create isolated browser context (no relaunch)
|
|
48
52
|
|
|
49
53
|
INSPECT
|
|
50
54
|
snap <target> Accessibility tree snapshot (compact)
|
|
51
55
|
html <target> [selector] Get HTML (full page or CSS selector)
|
|
52
|
-
shot <target> [file] [
|
|
53
|
-
|
|
56
|
+
shot <target> [file] [options] Screenshot (viewport, full page, or element)
|
|
57
|
+
--full Full page capture
|
|
58
|
+
--format=jpeg|webp|png Image format (default: png)
|
|
59
|
+
--quality=N Compression quality 0-100 (JPEG/WebP)
|
|
60
|
+
@eN Capture specific element by ref
|
|
61
|
+
net <target> [requestId] Network requests list, or detail by request ID
|
|
54
62
|
perf <target> Core Web Vitals + performance metrics
|
|
55
63
|
console <target> [duration_ms] Capture console output (default 5000ms)
|
|
64
|
+
console <target> list Show stored messages since daemon start
|
|
65
|
+
console <target> detail <id> Message detail with stack trace
|
|
56
66
|
domsnapshot <target> [--styles] Structured DOM snapshot with bounding rects
|
|
57
67
|
highlight <target> <sel|clear> Highlight element with overlay
|
|
58
68
|
|
|
@@ -61,14 +71,15 @@ Usage: chromex <command> [args]
|
|
|
61
71
|
evalraw <target> <method> [json] Raw CDP command (some methods blocked)
|
|
62
72
|
|
|
63
73
|
NAVIGATE
|
|
64
|
-
nav <target> <url>
|
|
74
|
+
nav <target> <url|action> Navigate: URL, back, forward, reload, reload-hard
|
|
65
75
|
waitfor <target> <selector> [ms] Wait for CSS selector to appear
|
|
66
76
|
wait <target> <event> [ms] Wait for: networkidle, load, domready, fcp
|
|
67
77
|
scroll <target> <dir> [amount] Scroll: up, down, top, bottom, to <selector>
|
|
68
78
|
|
|
69
79
|
INTERACT
|
|
70
|
-
click <target> <selector>
|
|
71
|
-
clickxy <target> <x> <y>
|
|
80
|
+
click <target> <selector> [--dbl] Click element (supports double-click)
|
|
81
|
+
clickxy <target> <x> <y> [--dbl] Click at coordinates (supports double-click)
|
|
82
|
+
key <target> <combo> Press key: Enter, Tab, Escape, Control+A, Meta+C
|
|
72
83
|
type <target> <text> Type text at current focus
|
|
73
84
|
drag <target> <from> <to> Drag & drop (selectors or x1,y1 x2,y2)
|
|
74
85
|
touch <target> <gesture> [args] Touch: tap, swipe, pinch, longpress
|
|
@@ -99,6 +110,7 @@ Usage: chromex <command> [args]
|
|
|
99
110
|
timezone <target> <tz|reset> Set timezone (e.g. America/Sao_Paulo)
|
|
100
111
|
locale <target> <locale|reset> Set locale (e.g. pt-BR)
|
|
101
112
|
cpu <target> <rate|reset> CPU throttle (1=normal, 4=4x slower, 6=mobile)
|
|
113
|
+
resize <target> <w> <h> [dpr] Resize viewport to custom dimensions
|
|
102
114
|
|
|
103
115
|
ADVANCED
|
|
104
116
|
inject <target> <script|flags> Inject JS on every page load (--file, --remove, --list)
|
|
@@ -108,6 +120,13 @@ Usage: chromex <command> [args]
|
|
|
108
120
|
heap <target> snapshot [file] Heap snapshot for memory analysis
|
|
109
121
|
webauthn <target> enable|creds|dis Virtual authenticator for passkey testing
|
|
110
122
|
|
|
123
|
+
AUDIT
|
|
124
|
+
audit <target> [categories] [device] Lighthouse audit (performance, accessibility, SEO)
|
|
125
|
+
categories: performance,accessibility,seo,best-practices
|
|
126
|
+
device: mobile (default) or desktop
|
|
127
|
+
stats <target> [--full] [--reset] Session analytics (command counts, timing, errors)
|
|
128
|
+
--export=/path/to/stats.json Export as JSON
|
|
129
|
+
|
|
111
130
|
DAEMON
|
|
112
131
|
stop [target] Stop daemon(s)
|
|
113
132
|
|
|
@@ -166,7 +185,8 @@ async function main() {
|
|
|
166
185
|
|
|
167
186
|
// Launch
|
|
168
187
|
if (cmd === 'launch') {
|
|
169
|
-
const options = parseFlags(args, ['incognito'], ['browser', 'profile', 'url']);
|
|
188
|
+
const options = parseFlags(args, ['incognito', 'headless', 'insecure'], ['browser', 'profile', 'url', 'proxy', 'chrome-arg']);
|
|
189
|
+
if (options['chrome-arg']) { options.chromeArgs = [options['chrome-arg']]; delete options['chrome-arg']; }
|
|
170
190
|
const result = await launchBrowser(options);
|
|
171
191
|
console.log(result);
|
|
172
192
|
return;
|