chromex-mcp 1.5.0 → 1.7.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 +472 -471
- package/package.json +4 -3
- package/plugins/chromex/skills/chromex/scripts/chromex.mjs +321 -37
- package/plugins/chromex/skills/chromex/scripts/lib/artifacts.mjs +55 -0
- package/plugins/chromex/skills/chromex/scripts/lib/browser.mjs +9 -7
- package/plugins/chromex/skills/chromex/scripts/lib/commands/app.mjs +558 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/audit.mjs +2 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/doctor.mjs +55 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/download.mjs +3 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/evidence.mjs +284 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/har.mjs +2 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/heap.mjs +2 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/intercept.mjs +131 -37
- package/plugins/chromex/skills/chromex/scripts/lib/commands/locator.mjs +173 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/pdf.mjs +2 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/screenshot.mjs +5 -3
- package/plugins/chromex/skills/chromex/scripts/lib/commands/show.mjs +308 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/snapshot.mjs +39 -3
- package/plugins/chromex/skills/chromex/scripts/lib/commands/state.mjs +86 -0
- package/plugins/chromex/skills/chromex/scripts/lib/commands/stats.mjs +4 -2
- package/plugins/chromex/skills/chromex/scripts/lib/commands/storage.mjs +8 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/tab.mjs +6 -1
- package/plugins/chromex/skills/chromex/scripts/lib/commands/trace.mjs +2 -1
- package/plugins/chromex/skills/chromex/scripts/lib/config.mjs +6 -1
- package/plugins/chromex/skills/chromex/scripts/lib/daemon.mjs +106 -15
- package/plugins/chromex/skills/chromex/scripts/lib/launcher.mjs +14 -7
- package/plugins/chromex/skills/chromex/scripts/lib/sessions.mjs +92 -0
- package/plugins/chromex/skills/chromex/scripts/mcp-server.mjs +231 -8
package/README.md
CHANGED
|
@@ -1,657 +1,658 @@
|
|
|
1
1
|
# Chromex
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
3
|
+
[](https://www.npmjs.com/package/chromex-mcp)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
Chromex is a zero-dependency Chrome DevTools Protocol toolkit for AI agents. It connects directly to Chrome, Brave, Edge, Chromium, and Vivaldi through CDP, exposing a token-efficient CLI and an optional MCP server with 78 typed tools.
|
|
8
|
+
|
|
9
|
+
Use Chromex when an agent needs to inspect pages, take screenshots, navigate, click, fill forms, read console/network activity, emulate devices, throttle network/CPU, export PDFs, or run browser diagnostics without pulling in heavy browser automation runtimes.
|
|
10
|
+
|
|
11
|
+
## Why Chromex
|
|
12
|
+
|
|
13
|
+
- **CLI-first for lower token usage**: terminal commands return compact plain text and avoid MCP tool-schema overhead.
|
|
14
|
+
- **Optional MCP server**: 78 typed tools for Claude Code and other MCP clients when tool discovery, typed parameters, and inline screenshots matter more than token budget.
|
|
15
|
+
- **No runtime dependencies**: Node.js 22+ built-ins only, including native WebSocket support.
|
|
16
|
+
- **Agent-friendly page model**: accessibility snapshots, `@eN` refs, incremental diffs, query filters, auto-snapshots, and contextual hints.
|
|
17
|
+
- **Persistent per-tab daemons**: one CDP session per tab, held open through an authenticated Unix socket.
|
|
18
|
+
- **Security controls**: domain allow/block lists, CDP method blocklist, socket auth, command timeouts, and audit logs.
|
|
19
|
+
- **Local by default**: no hosted service, no telemetry client, no bundled browser download, and session stats stay on your machine.
|
|
20
|
+
|
|
21
|
+
## What You Can Do Today
|
|
22
|
+
|
|
23
|
+
- Inspect and automate real logged-in browser sessions, not only fresh headless test contexts.
|
|
24
|
+
- Use `--raw` and `--json` for stable pipes, CI, MCP wrappers, and agent-to-agent integrations.
|
|
25
|
+
- Create named sessions with isolated browser contexts, reusable targets, and local session dashboards.
|
|
26
|
+
- Read page state through compact accessibility snapshots, filtered snapshots, DOM snapshots, HTML, screenshots, and highlighted elements.
|
|
27
|
+
- Act on UI through refs, CSS selectors, coordinates, keyboard input, forms, uploads, drag and drop, touch gestures, dialogs, and load-more loops.
|
|
28
|
+
- Debug production behavior with console history, network request details, response bodies, HAR export, request blocking, API mocking, throttling, and offline mode.
|
|
29
|
+
- Test browser conditions with device presets, viewport resizing, DPR, geolocation, timezone, locale, CPU throttling, incognito contexts, proxies, and custom Chrome flags.
|
|
30
|
+
- Diagnose performance and quality with Core Web Vitals, transfer size, DOM/memory counters, Lighthouse audits, JS/CSS coverage, Chrome traces, and heap snapshots.
|
|
31
|
+
- Build evidence packs with screenshots, snapshots, HTML, console, network timeline, action timeline, and replay HTML.
|
|
32
|
+
- Validate modern browser flows such as passkey/WebAuthn registration and login, downloads, cookies, portable storage state, PDF export, and isolated profiles.
|
|
33
|
+
- Inspect Application panel state from the terminal: origin quota, storage usage breakdown, Cache Storage entries/bodies, IndexedDB schemas/rows, and Service Worker registrations.
|
|
34
|
+
- Turn `@eN` refs into locators and optional `chromex-test` action code.
|
|
35
|
+
|
|
36
|
+
## Positioning
|
|
37
|
+
|
|
38
|
+
Chromex is a direct CDP layer for coding agents. It sits between raw Chrome DevTools Protocol and heavier browser automation frameworks.
|
|
39
|
+
|
|
40
|
+
| Alternative | Trade-off | Chromex angle |
|
|
41
|
+
|-------------|-----------|---------------|
|
|
42
|
+
| Raw CDP WebSocket | Maximum browser power, but too verbose for agents. | Compact commands, refs, snapshots, and safety defaults. |
|
|
43
|
+
| Heavy browser automation libraries | Excellent automation frameworks, but they add dependencies and framework-level abstractions. | Zero-runtime-dependency CLI/MCP that talks to your existing Chromium browser. |
|
|
44
|
+
| Browser MCP only | Easy tool discovery, but tool schemas and structured responses add token cost. | CLI-first for cheap agent loops, MCP when typed tools are worth the overhead. |
|
|
45
|
+
| Manual DevTools | Great for humans, not scriptable enough for agents. | DevTools-grade inspection exposed as terminal and MCP commands. |
|
|
25
46
|
|
|
26
47
|
## Requirements
|
|
27
48
|
|
|
28
|
-
- Node.js 22
|
|
29
|
-
-
|
|
49
|
+
- Node.js 22 or newer.
|
|
50
|
+
- macOS or Linux.
|
|
51
|
+
- A Chromium-based browser: Chrome, Brave, Edge, Chromium, Chrome Canary, or Vivaldi.
|
|
30
52
|
|
|
31
|
-
##
|
|
53
|
+
## Zero-Dependency Boundary
|
|
32
54
|
|
|
33
|
-
|
|
34
|
-
# Add to Claude Code (global -- all projects)
|
|
35
|
-
claude mcp add chromex -s user npx chromex-mcp@latest
|
|
55
|
+
The core runtime uses only Node.js built-in modules. Chromex does not install heavy browser automation runtimes, Selenium, browser drivers, telemetry SDKs, update checkers, or bundled browsers.
|
|
36
56
|
|
|
37
|
-
|
|
38
|
-
claude mcp add chromex npx chromex-mcp@latest
|
|
39
|
-
```
|
|
57
|
+
The only exception is the optional `audit` command: it shells out to Lighthouse with `npx --yes lighthouse` when you explicitly run an audit. All other CLI and MCP commands run through Chromex's own CDP client.
|
|
40
58
|
|
|
41
|
-
|
|
59
|
+
Development dependencies are used only for tests and token benchmarks.
|
|
42
60
|
|
|
43
|
-
|
|
61
|
+
## Browser Setup
|
|
44
62
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
Chromex needs Chrome DevTools Protocol access to your browser. Choose one of the two connection modes below before using the CLI or MCP server.
|
|
64
|
+
|
|
65
|
+
### Option A: Launch a Browser with Chromex
|
|
66
|
+
|
|
67
|
+
This is the recommended first-time setup. Chromex starts a new browser process with remote debugging already enabled, so there is no manual browser configuration and no "Allow debugging" prompt.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
chromex launch --url https://example.com
|
|
51
71
|
```
|
|
52
72
|
|
|
53
|
-
|
|
73
|
+
Useful launch variants:
|
|
54
74
|
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"mcp__chromex__chromex_screenshot",
|
|
62
|
-
"mcp__chromex__chromex_perf"
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
}
|
|
75
|
+
```bash
|
|
76
|
+
chromex launch --browser brave --url https://example.com
|
|
77
|
+
chromex launch --profile testing --url https://example.com
|
|
78
|
+
chromex launch --incognito --browser chrome
|
|
79
|
+
chromex launch --headless --url https://example.com
|
|
80
|
+
chromex launch --browser-path "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
|
|
66
81
|
```
|
|
67
82
|
|
|
68
|
-
|
|
83
|
+
Named profiles are stored under `~/.chromex/profiles/` and keep test sessions isolated from your daily browser profile.
|
|
84
|
+
|
|
85
|
+
Chrome for Testing also works well with Chromex. Download it manually from Google's official Chrome for Testing channel, then point Chromex at the executable with `--browser-path` or `CHROMEX_BROWSER_PATH`. Chromex does not download or bundle a browser.
|
|
86
|
+
|
|
87
|
+
### Option B: Connect to an Already-Running Browser
|
|
88
|
+
|
|
89
|
+
Use this when you want Chromex to inspect tabs that are already open in your normal browser.
|
|
90
|
+
|
|
91
|
+
1. Open Chrome, Brave, Edge, Chromium, or Vivaldi.
|
|
92
|
+
2. Go to `chrome://inspect/#remote-debugging`.
|
|
93
|
+
3. Enable the remote debugging switch.
|
|
94
|
+
4. Run `chromex list` to verify that tabs are visible.
|
|
69
95
|
|
|
70
96
|
```bash
|
|
71
|
-
|
|
97
|
+
chromex list
|
|
72
98
|
```
|
|
73
99
|
|
|
74
|
-
|
|
100
|
+
Important notes:
|
|
75
101
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
- Without remote debugging enabled, Chromex cannot discover or control your open tabs.
|
|
103
|
+
- The browser setting is usually persistent across restarts.
|
|
104
|
+
- The first command that attaches to a tab may show an "Allow debugging" prompt. Accept it once for that tab; Chromex keeps the daemon session alive after that.
|
|
105
|
+
|
|
106
|
+
If your browser uses a custom profile or a non-standard `DevToolsActivePort` location, set:
|
|
81
107
|
|
|
82
108
|
```bash
|
|
83
|
-
|
|
84
|
-
chromex launch --url https://example.com # Launch browser
|
|
85
|
-
chromex snap 6BE8 --refs # Snapshot with refs
|
|
86
|
-
chromex click 6BE8 @e3 # Click by ref
|
|
109
|
+
export CDP_PORT_FILE=/path/to/DevToolsActivePort
|
|
87
110
|
```
|
|
88
111
|
|
|
89
|
-
|
|
112
|
+
If your Chromium executable is installed in a non-standard location, either pass `--browser-path` to `chromex launch` or set:
|
|
90
113
|
|
|
91
|
-
|
|
114
|
+
```bash
|
|
115
|
+
export CHROMEX_BROWSER_PATH=/path/to/chrome
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Run the local diagnostic command whenever browser discovery or CDP connection fails:
|
|
92
119
|
|
|
93
120
|
```bash
|
|
94
|
-
chromex
|
|
121
|
+
chromex doctor
|
|
95
122
|
```
|
|
96
123
|
|
|
97
|
-
|
|
124
|
+
## Install the CLI
|
|
98
125
|
|
|
99
|
-
|
|
126
|
+
Install the package globally to get the `chromex` command.
|
|
100
127
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
4. Run `chromex list` to verify the connection
|
|
128
|
+
```bash
|
|
129
|
+
# npm
|
|
130
|
+
npm install -g chromex-mcp
|
|
105
131
|
|
|
106
|
-
|
|
132
|
+
# Bun
|
|
133
|
+
bun add -g chromex-mcp
|
|
134
|
+
```
|
|
107
135
|
|
|
108
|
-
|
|
136
|
+
The package installs three binaries:
|
|
109
137
|
|
|
110
|
-
|
|
138
|
+
| Binary | Purpose |
|
|
139
|
+
|--------|---------|
|
|
140
|
+
| `chromex` | Main CLI for terminal, scripts, CI, and token-sensitive agent sessions. |
|
|
141
|
+
| `chromex-cli` | Alias for `chromex`. |
|
|
142
|
+
| `chromex-mcp` | MCP server over stdio JSON-RPC. Usually launched by an MCP client. |
|
|
143
|
+
|
|
144
|
+
## CLI Quick Start
|
|
145
|
+
|
|
146
|
+
The CLI is the recommended interface when token budget matters. It has no MCP schema overhead, works well in scripts, and returns compact plain-text output designed for LLM agents.
|
|
111
147
|
|
|
112
148
|
```bash
|
|
113
|
-
#
|
|
114
|
-
chromex
|
|
115
|
-
# Output: 6BE827FA Example Domain https://example.com
|
|
149
|
+
# 1. Launch or connect to a browser.
|
|
150
|
+
chromex launch --url https://github.com/login
|
|
116
151
|
|
|
117
|
-
#
|
|
118
|
-
chromex
|
|
152
|
+
# 2. List tabs and copy a target prefix.
|
|
153
|
+
chromex list
|
|
154
|
+
# 6BE827FA Sign in to GitHub https://github.com/login
|
|
119
155
|
|
|
120
|
-
#
|
|
156
|
+
# 3. Read the page through the accessibility tree and assign refs.
|
|
121
157
|
chromex snap 6BE8 --refs
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
# @e3 [button] Sign in
|
|
158
|
+
# @e1 [textbox] Username or email address
|
|
159
|
+
# @e2 [textbox] Password
|
|
160
|
+
# @e3 [button] Sign in
|
|
126
161
|
|
|
127
|
-
#
|
|
162
|
+
# 4. Interact by ref instead of fragile CSS selectors.
|
|
128
163
|
chromex fill 6BE8 @e1 "user@example.com"
|
|
129
|
-
chromex fill 6BE8 @e2 "
|
|
164
|
+
chromex fill 6BE8 @e2 "secret"
|
|
130
165
|
chromex click 6BE8 @e3
|
|
131
166
|
|
|
132
|
-
#
|
|
133
|
-
chromex
|
|
167
|
+
# 5. Inspect browser state.
|
|
168
|
+
chromex console 6BE8 list
|
|
169
|
+
chromex net 6BE8
|
|
170
|
+
chromex shot 6BE8
|
|
171
|
+
chromex app 6BE8
|
|
134
172
|
```
|
|
135
173
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
`<target>` is a unique prefix of the targetId shown by `list` (e.g. `6BE827FA`).
|
|
174
|
+
`<target>` is a unique prefix of the tab target ID returned by `chromex list`. If a prefix is ambiguous, Chromex rejects it and asks for more characters.
|
|
139
175
|
|
|
140
|
-
|
|
176
|
+
For repeatable agent workflows, use named sessions instead of carrying target IDs manually:
|
|
141
177
|
|
|
142
178
|
```bash
|
|
143
|
-
chromex
|
|
144
|
-
chromex
|
|
145
|
-
chromex
|
|
146
|
-
chromex
|
|
147
|
-
chromex
|
|
148
|
-
chromex launch --incognito --browser brave # Launch Brave in incognito
|
|
149
|
-
chromex launch --headless --url https://example.com # Headless mode for CI/CD
|
|
150
|
-
chromex launch --proxy socks5://localhost:1080 # Launch with proxy
|
|
151
|
-
chromex launch --insecure # Ignore certificate errors
|
|
152
|
-
chromex launch --chrome-arg --disable-web-security # Pass custom Chrome flag
|
|
153
|
-
chromex launch --profile testing --url https://... # Isolated profile + URL
|
|
154
|
-
chromex incognito https://example.com # Isolated context (no relaunch)
|
|
155
|
-
chromex stop # Stop all daemons
|
|
179
|
+
chromex -s auth open https://github.com/login
|
|
180
|
+
chromex -s auth snap --refs
|
|
181
|
+
chromex -s auth fill @e1 "user@example.com"
|
|
182
|
+
chromex -s auth state save ~/.chromex/storage/auth.json
|
|
183
|
+
chromex sessions
|
|
156
184
|
```
|
|
157
185
|
|
|
158
|
-
|
|
186
|
+
## Token-Efficient Agent Workflow
|
|
159
187
|
|
|
160
|
-
|
|
161
|
-
chromex snap <target> # Accessibility tree snapshot (compact)
|
|
162
|
-
chromex snap <target> --refs # With interactive refs (@e1, @e2...)
|
|
163
|
-
chromex snap <target> --depth=3 # Limit tree depth
|
|
164
|
-
chromex snap <target> --full # Force full snapshot (skip diff)
|
|
165
|
-
chromex snap <target> --query=login # Filter to matching nodes + ancestors (hierarchy preserved)
|
|
166
|
-
chromex html <target> "#main" # Element HTML by selector
|
|
167
|
-
chromex shot <target> /tmp/page.png # Viewport screenshot
|
|
168
|
-
chromex shot <target> /tmp/full.png --full # Full page screenshot
|
|
169
|
-
chromex shot <target> --format=jpeg --quality=80 # JPEG/WebP with quality control
|
|
170
|
-
chromex shot <target> @e5 # Screenshot of specific element by ref
|
|
171
|
-
chromex net <target> # List network requests (CDP tracked)
|
|
172
|
-
chromex net <target> <requestId> # Request detail: headers, timing, body
|
|
173
|
-
chromex perf <target> # Core Web Vitals + memory + DOM stats
|
|
174
|
-
chromex console <target> 5000 # Capture console.log/error for 5s
|
|
175
|
-
chromex console <target> list # Show stored messages since daemon start
|
|
176
|
-
chromex console <target> detail <id> # Message detail with stack trace
|
|
177
|
-
chromex domsnapshot <target> # Structured DOM with bounding rects
|
|
178
|
-
chromex domsnapshot <target> --styles # Include computed styles
|
|
179
|
-
chromex highlight <target> "h1" # Highlight element with overlay
|
|
180
|
-
chromex highlight <target> clear # Remove highlight
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Evaluate
|
|
184
|
-
|
|
185
|
-
```bash
|
|
186
|
-
chromex eval <target> "document.title" # Run JS
|
|
187
|
-
chromex eval <target> "document.querySelectorAll('a').length" # Count links
|
|
188
|
-
chromex evalraw <target> "DOM.getDocument" # Raw CDP command
|
|
189
|
-
chromex evalraw <target> "Page.getLayoutMetrics" # Layout info
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Navigate & Wait
|
|
193
|
-
|
|
194
|
-
```bash
|
|
195
|
-
chromex nav <target> "https://example.com" # Navigate + wait for load
|
|
196
|
-
chromex nav <target> back # Go back in history
|
|
197
|
-
chromex nav <target> forward # Go forward in history
|
|
198
|
-
chromex nav <target> reload # Reload page
|
|
199
|
-
chromex nav <target> reload-hard # Reload ignoring cache
|
|
200
|
-
chromex waitfor <target> ".results" 10000 # Wait for CSS selector (10s)
|
|
201
|
-
chromex wait <target> networkidle # Wait for network idle
|
|
202
|
-
chromex wait <target> load # Wait for page load
|
|
203
|
-
chromex wait <target> domready # Wait for DOMContentLoaded
|
|
204
|
-
chromex wait <target> fcp # Wait for First Contentful Paint
|
|
205
|
-
chromex scroll <target> down 500 # Scroll down 500px
|
|
206
|
-
chromex scroll <target> up 300 # Scroll up 300px
|
|
207
|
-
chromex scroll <target> top # Scroll to top
|
|
208
|
-
chromex scroll <target> bottom # Scroll to bottom
|
|
209
|
-
chromex scroll <target> to "#footer" # Scroll to element
|
|
210
|
-
```
|
|
188
|
+
Chromex is optimized for agents that need to act on browser state without wasting context.
|
|
211
189
|
|
|
212
|
-
|
|
190
|
+
1. Start with `chromex list`.
|
|
191
|
+
2. Prefer `chromex snap <target> --refs` over raw HTML.
|
|
192
|
+
3. Use `@eN` refs for `click`, `fill`, `hover`, and element screenshots.
|
|
193
|
+
4. On large pages, use `--query` before reading a full snapshot.
|
|
194
|
+
5. Let auto-snapshot show post-action state after interactive commands.
|
|
195
|
+
6. Add `--no-snap` only for fast scripted batches where you do not need immediate page state.
|
|
196
|
+
7. Add `--no-hints` when another program parses output strictly.
|
|
197
|
+
8. Use `--raw` for pipes and `--json` when another tool needs the stable envelope.
|
|
198
|
+
9. Save large snapshots with `--filename` when they are better as artifacts than inline text.
|
|
199
|
+
|
|
200
|
+
Examples:
|
|
213
201
|
|
|
214
202
|
```bash
|
|
215
|
-
chromex
|
|
216
|
-
chromex click
|
|
217
|
-
chromex
|
|
218
|
-
chromex
|
|
219
|
-
chromex
|
|
220
|
-
chromex
|
|
221
|
-
chromex
|
|
222
|
-
chromex
|
|
223
|
-
chromex
|
|
224
|
-
chromex hover <target> @e12 # Hover element by ref
|
|
225
|
-
chromex drag <target> "#source" "#dest" # Drag & drop by selector
|
|
226
|
-
chromex drag <target> 100,200 400,500 # Drag & drop by coordinates
|
|
227
|
-
chromex touch <target> tap 200 300 # Touch tap
|
|
228
|
-
chromex touch <target> swipe 200,400 200,100 # Swipe gesture
|
|
229
|
-
chromex touch <target> pinch 200 300 2.0 # Pinch zoom in
|
|
230
|
-
chromex touch <target> longpress 200 300 1000 # Long press (1s)
|
|
231
|
-
chromex dialog <target> accept # Accept alert/confirm
|
|
232
|
-
chromex dialog <target> dismiss # Dismiss dialog
|
|
233
|
-
chromex dialog <target> auto # Auto-accept all dialogs
|
|
234
|
-
chromex loadall <target> ".load-more" 500 # Click until element disappears
|
|
203
|
+
chromex snap 6BE8 --query=login --refs
|
|
204
|
+
chromex click 6BE8 @e4
|
|
205
|
+
chromex wait 6BE8 networkidle
|
|
206
|
+
chromex snap 6BE8 --query=error
|
|
207
|
+
chromex --raw eval 6BE8 "document.title"
|
|
208
|
+
chromex list --json
|
|
209
|
+
chromex snap 6BE8 --filename=~/.chromex/snapshots/login.yml --boxes
|
|
210
|
+
chromex locator 6BE8 @e4 --format=chromex-test
|
|
211
|
+
chromex click 6BE8 @e4 --code=chromex-test
|
|
235
212
|
```
|
|
236
213
|
|
|
237
|
-
|
|
214
|
+
## MCP Server
|
|
238
215
|
|
|
239
|
-
|
|
240
|
-
chromex fill <target> "#email" "user@test.com" # Fill input/textarea
|
|
241
|
-
chromex fill <target> @e1 "user@test.com" # Fill by ref
|
|
242
|
-
chromex clear <target> "#search" # Clear field
|
|
243
|
-
chromex select <target> "#country" "BR" # Select dropdown option
|
|
244
|
-
chromex check <target> "#terms" # Check checkbox
|
|
245
|
-
chromex check <target> "#newsletter" false # Uncheck checkbox
|
|
246
|
-
chromex upload <target> "#avatar" /tmp/photo.png # Upload file
|
|
216
|
+
Use MCP when you want Claude Code or another MCP client to discover typed browser tools directly. MCP is convenient, but it costs more tokens than CLI usage because tool schemas, JSON-RPC framing, and structured tool results add overhead.
|
|
247
217
|
|
|
248
|
-
|
|
249
|
-
chromex form <target> '{"#name":"John","#email":"john@test.com","#terms":true}'
|
|
250
|
-
```
|
|
218
|
+
### Add to Claude Code
|
|
251
219
|
|
|
252
|
-
|
|
220
|
+
Global, available in all projects:
|
|
253
221
|
|
|
254
222
|
```bash
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
chromex
|
|
260
|
-
chromex storage <target> clear # Clear both
|
|
261
|
-
chromex pdf <target> /tmp/page.pdf # Export as PDF
|
|
223
|
+
# npm
|
|
224
|
+
claude mcp add chromex -s user npx chromex-mcp@latest
|
|
225
|
+
|
|
226
|
+
# Bun
|
|
227
|
+
claude mcp add chromex -s user bunx chromex-mcp@latest
|
|
262
228
|
```
|
|
263
229
|
|
|
264
|
-
|
|
230
|
+
Project-only:
|
|
265
231
|
|
|
266
232
|
```bash
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
chromex throttle <target> 4g # Throttle to 4G
|
|
270
|
-
chromex throttle <target> offline # Go offline
|
|
271
|
-
chromex throttle <target> custom 200 1000 500 # Custom: latency, down, up (kbps)
|
|
272
|
-
chromex throttle <target> reset # Remove throttling
|
|
273
|
-
|
|
274
|
-
chromex intercept <target> block "*.analytics.*" # Block matching requests
|
|
275
|
-
chromex intercept <target> mock "/api/user" '{"name":"test"}' # Mock response
|
|
276
|
-
chromex intercept <target> rules # List active rules
|
|
277
|
-
chromex intercept <target> off # Disable interception
|
|
233
|
+
# npm
|
|
234
|
+
claude mcp add chromex npx chromex-mcp@latest
|
|
278
235
|
|
|
279
|
-
|
|
280
|
-
|
|
236
|
+
# Bun
|
|
237
|
+
claude mcp add chromex bunx chromex-mcp@latest
|
|
281
238
|
```
|
|
282
239
|
|
|
283
|
-
|
|
240
|
+
After setup, the MCP client can call tools such as `chromex_list`, `chromex_snapshot`, `chromex_click`, `chromex_fill`, `chromex_screenshot`, `chromex_console`, `chromex_network`, `chromex_app_summary`, `chromex_cache_entries`, `chromex_indexeddb_rows`, `chromex_sessions`, `chromex_show`, `chromex_locator`, `chromex_state`, and `chromex_evidence`.
|
|
284
241
|
|
|
285
|
-
|
|
286
|
-
chromex emulate <target> iphone-14 # 390x844 @3x mobile
|
|
287
|
-
chromex emulate <target> iphone-15-pro # 393x852 @3x mobile
|
|
288
|
-
chromex emulate <target> ipad-pro # 1024x1366 @2x tablet
|
|
289
|
-
chromex emulate <target> pixel-7 # 412x915 @2.625x mobile
|
|
290
|
-
chromex emulate <target> galaxy-s23 # 360x780 @3x mobile
|
|
291
|
-
chromex emulate <target> macbook-air # 1440x900 @2x laptop
|
|
292
|
-
chromex emulate <target> desktop-1080p # 1920x1080 @1x
|
|
293
|
-
chromex emulate <target> desktop-4k # 3840x2160 @1x
|
|
294
|
-
chromex emulate <target> reset # Reset to default
|
|
295
|
-
chromex resize <target> 1280 720 # Custom viewport dimensions
|
|
296
|
-
chromex resize <target> 1440 900 2 # Custom with DPR (retina)
|
|
297
|
-
chromex geo <target> -23.55 -46.63 # Set geolocation (Sao Paulo)
|
|
298
|
-
chromex geo <target> reset # Clear geolocation
|
|
299
|
-
chromex timezone <target> "America/Sao_Paulo" # Set timezone
|
|
300
|
-
chromex locale <target> "pt-BR" # Set locale
|
|
301
|
-
chromex cpu <target> 4 # CPU 4x slower
|
|
302
|
-
chromex cpu <target> reset # Reset CPU speed
|
|
303
|
-
```
|
|
242
|
+
Tools that produce machine-readable data or artifacts also include MCP `structuredContent`, so agents can read paths and metadata without parsing the human text block.
|
|
304
243
|
|
|
305
|
-
###
|
|
244
|
+
### Claude Code Auto-Approve
|
|
306
245
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
chromex coverage <target> stop # Coverage report (JS + CSS %)
|
|
316
|
-
chromex trace <target> start # Start performance trace
|
|
317
|
-
chromex trace <target> stop /tmp/trace.json # Save trace (chrome://tracing)
|
|
318
|
-
chromex heap <target> snapshot /tmp/heap.hs # Heap snapshot (memory analysis)
|
|
319
|
-
chromex webauthn <target> enable # Virtual authenticator (passkeys)
|
|
320
|
-
chromex webauthn <target> creds # List stored credentials
|
|
321
|
-
chromex webauthn <target> disable # Remove authenticator
|
|
246
|
+
To approve all Chromex MCP tools at once, add this to `~/.claude/settings.json`:
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"permissions": {
|
|
251
|
+
"allow": ["mcp__chromex"]
|
|
252
|
+
}
|
|
253
|
+
}
|
|
322
254
|
```
|
|
323
255
|
|
|
324
|
-
|
|
256
|
+
For CLI usage inside Claude Code, approve the shell command instead:
|
|
325
257
|
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
chromex
|
|
331
|
-
chromex
|
|
332
|
-
|
|
333
|
-
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"permissions": {
|
|
261
|
+
"allow": [
|
|
262
|
+
"Bash(chromex *)",
|
|
263
|
+
"Bash(chromex-cli *)"
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
}
|
|
334
267
|
```
|
|
335
268
|
|
|
336
|
-
|
|
269
|
+
Review these permissions before enabling them. Chromex security settings still apply, and every command is audit-logged when `auditLog` is enabled.
|
|
270
|
+
|
|
271
|
+
## CLI vs MCP
|
|
272
|
+
|
|
273
|
+
Both interfaces use the same CDP core and the same per-tab daemons. Choose based on the workflow.
|
|
337
274
|
|
|
338
|
-
|
|
275
|
+
| Use case | Prefer CLI | Prefer MCP |
|
|
276
|
+
|----------|------------|------------|
|
|
277
|
+
| Token-sensitive agent sessions | Yes | No |
|
|
278
|
+
| Terminal scripts and CI | Yes | No |
|
|
279
|
+
| Quick one-off browser inspection | Yes | Optional |
|
|
280
|
+
| Typed tool discovery in Claude Code | No | Yes |
|
|
281
|
+
| Inline screenshots returned to the client | No, screenshots are files | Yes |
|
|
282
|
+
| Granular per-tool permissions | Shell pattern only | Yes |
|
|
283
|
+
| Lowest setup friction for MCP users | Optional | Yes |
|
|
284
|
+
|
|
285
|
+
You can remove MCP at any time and keep using the CLI:
|
|
339
286
|
|
|
340
287
|
```bash
|
|
341
|
-
|
|
342
|
-
chromex snap <target> --refs
|
|
343
|
-
# Output:
|
|
344
|
-
# @e1 [textbox] Username
|
|
345
|
-
# @e2 [textbox] Password
|
|
346
|
-
# @e3 [checkbox] Remember me
|
|
347
|
-
# @e4 [button] Sign in
|
|
348
|
-
# @e5 [link] Forgot password?
|
|
349
|
-
|
|
350
|
-
# 2. Interact using refs
|
|
351
|
-
chromex fill <target> @e1 "admin"
|
|
352
|
-
chromex fill <target> @e2 "secret123"
|
|
353
|
-
chromex click <target> @e3
|
|
354
|
-
chromex click <target> @e4
|
|
288
|
+
claude mcp remove chromex
|
|
355
289
|
```
|
|
356
290
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
Supported ref commands: `click @eN`, `fill @eN "value"`, `hover @eN`.
|
|
291
|
+
## Command Overview
|
|
360
292
|
|
|
361
|
-
|
|
293
|
+
### Pages and Browser
|
|
362
294
|
|
|
363
|
-
|
|
295
|
+
```bash
|
|
296
|
+
chromex list
|
|
297
|
+
chromex open "https://example.com"
|
|
298
|
+
chromex -s auth open "https://example.com/login"
|
|
299
|
+
chromex -s auth snap --refs
|
|
300
|
+
chromex sessions
|
|
301
|
+
chromex show --annotate
|
|
302
|
+
chromex close <target>
|
|
303
|
+
chromex focus <target>
|
|
304
|
+
chromex launch --url https://example.com
|
|
305
|
+
chromex launch --browser brave --incognito
|
|
306
|
+
chromex launch --headless --url https://example.com
|
|
307
|
+
chromex launch --browser-path /path/to/chrome --url https://example.com
|
|
308
|
+
chromex doctor
|
|
309
|
+
chromex incognito https://example.com
|
|
310
|
+
chromex stop
|
|
311
|
+
```
|
|
364
312
|
|
|
365
|
-
###
|
|
313
|
+
### Inspect
|
|
366
314
|
|
|
367
|
-
|
|
315
|
+
```bash
|
|
316
|
+
chromex snap <target> --refs
|
|
317
|
+
chromex snap <target> --query=login
|
|
318
|
+
chromex snap <target> --filename=~/.chromex/snapshots/login.yml --boxes
|
|
319
|
+
chromex html <target> "#main"
|
|
320
|
+
chromex shot <target>
|
|
321
|
+
chromex shot <target> ~/.chromex/screenshots/full.png --full
|
|
322
|
+
chromex shot <target> @e5
|
|
323
|
+
chromex console <target> list
|
|
324
|
+
chromex net <target>
|
|
325
|
+
chromex perf <target>
|
|
326
|
+
chromex domsnapshot <target> --styles
|
|
327
|
+
chromex evidence <target> start checkout-flow
|
|
328
|
+
chromex evidence <target> mark "after login"
|
|
329
|
+
chromex evidence <target> stop
|
|
330
|
+
chromex evidence <target> replay
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Navigate and Wait
|
|
368
334
|
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
335
|
+
```bash
|
|
336
|
+
chromex nav <target> "https://example.com"
|
|
337
|
+
chromex nav <target> back
|
|
338
|
+
chromex nav <target> reload-hard
|
|
339
|
+
chromex waitfor <target> ".results" 10000
|
|
340
|
+
chromex wait <target> networkidle
|
|
341
|
+
chromex scroll <target> bottom
|
|
373
342
|
```
|
|
374
343
|
|
|
375
|
-
|
|
376
|
-
- Unchanged subtrees are collapsed entirely
|
|
377
|
-
- Use `--full` to force a full snapshot (skips diff)
|
|
378
|
-
- Navigation (`nav`) resets the diff baseline automatically
|
|
344
|
+
### Interact
|
|
379
345
|
|
|
380
|
-
|
|
346
|
+
```bash
|
|
347
|
+
chromex click <target> @e5
|
|
348
|
+
chromex clickxy <target> 100 200
|
|
349
|
+
chromex key <target> Enter
|
|
350
|
+
chromex type <target> "hello world"
|
|
351
|
+
chromex hover <target> @e12
|
|
352
|
+
chromex locator <target> @e12 --format=chromex-test
|
|
353
|
+
chromex click <target> @e12 --code=chromex-test
|
|
354
|
+
chromex drag <target> "#source" "#dest"
|
|
355
|
+
chromex dialog <target> accept
|
|
356
|
+
```
|
|
381
357
|
|
|
382
|
-
|
|
358
|
+
### Forms
|
|
383
359
|
|
|
384
360
|
```bash
|
|
385
|
-
chromex
|
|
361
|
+
chromex fill <target> @e1 "user@example.com"
|
|
362
|
+
chromex clear <target> "#search"
|
|
363
|
+
chromex select <target> "#country" "BR"
|
|
364
|
+
chromex check <target> "#terms" true
|
|
365
|
+
chromex upload <target> "#avatar" /tmp/photo.png
|
|
366
|
+
chromex form <target> '{"#name":"John","#email":"john@example.com","#terms":true}'
|
|
386
367
|
```
|
|
387
368
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
### Query Filter
|
|
369
|
+
### Data
|
|
391
370
|
|
|
392
|
-
|
|
371
|
+
```bash
|
|
372
|
+
chromex cookies <target>
|
|
373
|
+
chromex cookies <target> set '{"name":"token","value":"abc"}'
|
|
374
|
+
chromex storage <target> local
|
|
375
|
+
chromex storage <target> session
|
|
376
|
+
chromex storage <target> usage
|
|
377
|
+
chromex state <target> save ~/.chromex/storage/auth.json
|
|
378
|
+
chromex state <target> load ~/.chromex/storage/auth.json
|
|
379
|
+
chromex app <target> summary
|
|
380
|
+
chromex sw <target>
|
|
381
|
+
chromex cache <target> list
|
|
382
|
+
chromex cache <target> entries <cacheId> --query=/api
|
|
383
|
+
chromex idb <target> list
|
|
384
|
+
chromex idb <target> schema <databaseName>
|
|
385
|
+
chromex idb <target> rows <databaseName> <objectStoreName> --limit=20
|
|
386
|
+
chromex pdf <target>
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Network, Emulation, and Diagnostics
|
|
393
390
|
|
|
394
391
|
```bash
|
|
395
|
-
chromex
|
|
396
|
-
chromex
|
|
392
|
+
chromex throttle <target> 3g
|
|
393
|
+
chromex intercept <target> block "*.analytics.*"
|
|
394
|
+
chromex intercept <target> mock "/api/user" --status=200 --content-type=application/json --body='{"ok":true}'
|
|
395
|
+
chromex intercept <target> mock "/api/slow" --delay=750 --status=503 --body='unavailable'
|
|
396
|
+
chromex intercept <target> block "*.tracker.*" --abort=blockedbyclient
|
|
397
|
+
chromex intercept <target> on --remove-header=authorization
|
|
398
|
+
chromex har <target> start
|
|
399
|
+
chromex har <target> stop ~/.chromex/har/trace.har
|
|
400
|
+
chromex emulate <target> iphone-15-pro
|
|
401
|
+
chromex resize <target> 1280 720
|
|
402
|
+
chromex geo <target> -23.55 -46.63
|
|
403
|
+
chromex timezone <target> "America/Sao_Paulo"
|
|
404
|
+
chromex cpu <target> 4
|
|
405
|
+
chromex audit <target> performance,accessibility desktop
|
|
406
|
+
chromex stats <target> --full
|
|
397
407
|
```
|
|
398
408
|
|
|
399
|
-
|
|
409
|
+
### Advanced
|
|
400
410
|
|
|
401
|
-
|
|
411
|
+
```bash
|
|
412
|
+
chromex eval <target> "document.title"
|
|
413
|
+
chromex evalraw <target> "Page.getLayoutMetrics"
|
|
414
|
+
chromex inject <target> "window.DEBUG=true"
|
|
415
|
+
chromex download <target> allow ~/.chromex/downloads
|
|
416
|
+
chromex coverage <target> start
|
|
417
|
+
chromex trace <target> start
|
|
418
|
+
chromex heap <target> snapshot ~/.chromex/heap/heap.heapsnapshot
|
|
419
|
+
chromex webauthn <target> enable
|
|
420
|
+
```
|
|
402
421
|
|
|
403
|
-
|
|
422
|
+
Run `chromex --help` for the full command reference.
|
|
404
423
|
|
|
405
|
-
|
|
406
|
-
|-------|-------------:|----------:|
|
|
407
|
-
| `snap --full` (baseline) | 65,455 | -- |
|
|
408
|
-
| `snap --query=issues` | 317 | **-99.5%** |
|
|
409
|
-
| `snap --query=star` | 1,490 | **-97.7%** |
|
|
410
|
-
| `snap --query=readme` | 936 | **-98.6%** |
|
|
424
|
+
## Agent-Focused Features
|
|
411
425
|
|
|
412
|
-
|
|
426
|
+
### Ref-Based Selection
|
|
413
427
|
|
|
414
|
-
|
|
428
|
+
`chromex snap --refs` assigns stable refs to interactive elements:
|
|
415
429
|
|
|
416
|
-
|
|
430
|
+
```bash
|
|
431
|
+
chromex snap <target> --refs
|
|
432
|
+
# @e1 [textbox] Email
|
|
433
|
+
# @e2 [textbox] Password
|
|
434
|
+
# @e3 [button] Sign in
|
|
417
435
|
|
|
436
|
+
chromex fill <target> @e1 "user@example.com"
|
|
437
|
+
chromex click <target> @e3
|
|
418
438
|
```
|
|
419
|
-
[scroll: page: down:1200px | sidebar: up:300px, down:800px]
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
### Visibility Filtering
|
|
423
439
|
|
|
424
|
-
|
|
425
|
-
- Disabled interactive elements are shown but not assigned refs (can't be interacted with)
|
|
426
|
-
- Generic wrapper nodes (`div`, `span` with no semantic role) are collapsed -- their children inherit the parent's depth
|
|
427
|
-
- Names longer than 200 characters are truncated with `...`
|
|
440
|
+
Refs are shorter and more robust than CSS selectors for most agent workflows.
|
|
428
441
|
|
|
429
|
-
|
|
442
|
+
### Incremental Snapshots
|
|
430
443
|
|
|
431
|
-
|
|
444
|
+
The first snapshot returns the page tree. Later snapshots return only changed nodes unless you pass `--full`.
|
|
432
445
|
|
|
433
446
|
```bash
|
|
447
|
+
chromex snap <target> --refs
|
|
434
448
|
chromex click <target> @e3
|
|
435
|
-
#
|
|
436
|
-
# Clicked @e3 [button] "Submit"
|
|
437
|
-
#
|
|
438
|
-
# [incremental: 5 changed, 40 unchanged]
|
|
439
|
-
# @e1 [heading] Thank you!
|
|
440
|
-
# @e2 [link] Back to home
|
|
441
|
-
# ...
|
|
449
|
+
# The click response includes a fresh incremental snapshot with refs.
|
|
442
450
|
```
|
|
443
451
|
|
|
444
|
-
|
|
452
|
+
### Query-Filtered Snapshots
|
|
445
453
|
|
|
446
|
-
|
|
454
|
+
Use `--query` to keep output small on large pages:
|
|
447
455
|
|
|
448
456
|
```bash
|
|
449
|
-
chromex
|
|
450
|
-
chromex
|
|
451
|
-
chromex click <target> @e3 # Only this one triggers snapshot
|
|
457
|
+
chromex snap <target> --query=issues --refs
|
|
458
|
+
chromex snap <target> --query="sign in" --refs
|
|
452
459
|
```
|
|
453
460
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
After any action that produces a fresh ref map (auto-snap on interactive commands, or an explicit `snap --refs`), chromex appends a `help[N]:` block with up to 3 next-step suggestions picked heuristically from the current elements and the last command:
|
|
461
|
+
Chromex preserves ancestor nodes so the filtered output still has usable context.
|
|
457
462
|
|
|
458
|
-
|
|
459
|
-
Navigated to https://github.com/login
|
|
463
|
+
### Contextual Hints
|
|
460
464
|
|
|
461
|
-
|
|
462
|
-
@e1 [textbox] Username or email address
|
|
463
|
-
@e2 [textbox] Password
|
|
464
|
-
@e3 [button] Sign in
|
|
465
|
-
@e4 [link] Forgot password?
|
|
465
|
+
After actions that refresh refs, Chromex can append a `help[N]:` block with likely next commands:
|
|
466
466
|
|
|
467
|
+
```text
|
|
467
468
|
help[3]:
|
|
468
|
-
chromex fill <t> @e1 "<value>" # textbox "
|
|
469
|
+
chromex fill <t> @e1 "<value>" # textbox "Email"
|
|
469
470
|
chromex click <t> @e3 # button "Sign in"
|
|
470
471
|
chromex click <t> @e4 # link "Forgot password?"
|
|
471
472
|
```
|
|
472
473
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
- **After `fill`** -- priority is a matching submit button (label matches `login`, `submit`, `send`, `search`, `go`, `continue`, ...) or `key Enter` fallback, then the next unfilled input.
|
|
476
|
-
- **After `nav`** -- first input (highest priority), then first submit button, then first link.
|
|
477
|
-
- **After `snap --refs`** (or any default) -- top interactive elements with non-empty names.
|
|
478
|
-
- **Maximum 3 hints per response.**
|
|
479
|
-
|
|
480
|
-
### Staleness Guard
|
|
481
|
-
|
|
482
|
-
Hints are only emitted when chromex can guarantee the ref map matches the DOM that was just rendered. This prevents the agent from clicking `@eN` coordinates that no longer exist on screen:
|
|
483
|
-
|
|
484
|
-
| Command | Hints? | Why |
|
|
485
|
-
|---------|--------|-----|
|
|
486
|
-
| `click`, `fill`, `nav`, `type`, ... (default) | Yes | auto-snap just ran with refs |
|
|
487
|
-
| `click @e1 --no-snap`, `fill ... --no-snap` | **No** | ref map may be stale |
|
|
488
|
-
| `snap --refs` | Yes | ref map populated by this call |
|
|
489
|
-
| `snap --refs` on a page with zero interactive elements | **No** | nothing to suggest, avoids a `snap --refs` loop |
|
|
490
|
-
| Bare `snap` (no `--refs`) | **No** | ref map was not refreshed |
|
|
474
|
+
Disable hints with `--no-hints`.
|
|
491
475
|
|
|
492
|
-
|
|
476
|
+
### Stable Output and Artifacts
|
|
493
477
|
|
|
494
|
-
|
|
478
|
+
Chromex keeps plain text as the default output, but also supports stable modes for scripts:
|
|
495
479
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
We measured the current plain-text output against three structured format candidates often proposed for agent interfaces: minified JSON, pretty-printed JSON, and a TOON-style compact encoder (a zero-dependency 60-line implementation of the YAML-inline compact style). Five representative chromex outputs were encoded in each format and tokenized with `tiktoken` (`cl100k_base`). Lower token counts are better.
|
|
480
|
+
```bash
|
|
481
|
+
chromex --raw eval <target> "document.title"
|
|
482
|
+
chromex list --json
|
|
483
|
+
chromex snap <target> --filename=~/.chromex/snapshots/home.yml --boxes
|
|
484
|
+
```
|
|
503
485
|
|
|
504
|
-
|
|
486
|
+
`--raw` prints only the primary command output and suppresses hints and auto-snapshot noise. `--json` returns a stable envelope with `ok`, `command`, `target`, `text`, `data`, `artifacts`, and `error`.
|
|
505
487
|
|
|
506
|
-
|
|
507
|
-
|--------------------------------|-----------:|---------------:|----------------:|----------------:|
|
|
508
|
-
| `snap-login-small` | **130** | 178 (+37%) | 301 (+132%) | 212 (+63%) |
|
|
509
|
-
| `snap-repo-large` (65 KB real) | **19,702** | 34,315 (+74%) | 63,232 (+221%) | 44,613 (+126%) |
|
|
510
|
-
| `net-list-50` | **454** | 574 (+26%) | 921 (+103%) | 706 (+56%) |
|
|
511
|
-
| `console-list-12` | **273** | 363 (+33%) | 576 (+111%) | 453 (+66%) |
|
|
512
|
-
| `fill-action-small` | **99** | 127 (+28%) | 221 (+123%) | 146 (+48%) |
|
|
488
|
+
Generated artifacts are written under `~/.chromex/artifacts/<workspace>/` by default. Paths in the Chromex namespace, such as `.chromex/storage/auth.json` or `~/.chromex/storage/auth.json`, resolve to `~/.chromex/...`. Other explicit absolute or relative file paths are respected as provided. Set `CHROMEX_ARTIFACT_ROOT` to override the default artifact root for CI or tests.
|
|
513
489
|
|
|
514
|
-
|
|
490
|
+
### Named Sessions
|
|
515
491
|
|
|
516
|
-
|
|
492
|
+
Named sessions let agents reuse isolated browser contexts without carrying target IDs:
|
|
517
493
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
494
|
+
```bash
|
|
495
|
+
chromex -s auth open https://example.com/login
|
|
496
|
+
chromex -s auth snap --refs
|
|
497
|
+
chromex -s auth click @e3
|
|
498
|
+
chromex sessions
|
|
499
|
+
chromex show --annotate
|
|
500
|
+
chromex close-all
|
|
501
|
+
chromex delete-data
|
|
502
|
+
```
|
|
524
503
|
|
|
525
|
-
|
|
504
|
+
`CHROMEX_SESSION=auth` can replace `-s auth` for shell scripts.
|
|
505
|
+
`chromex show` opens the generated dashboard in the default browser during normal CLI usage; set `CHROMEX_NO_OPEN=1` or use `--json`/`--raw` to only write the artifact.
|
|
526
506
|
|
|
527
|
-
|
|
507
|
+
Named sessions keep a private storage-state file under `~/.chromex/session-data/<name>/storage-state.json`. Chromex restores it when the named session is reopened and refreshes it after state-changing session commands.
|
|
528
508
|
|
|
529
|
-
|
|
530
|
-
- **`@eN` refs beat CSS selectors** not just for reliability (accessibility tree is stable across SPA re-renders) but also for token count -- `@e5` is one token, `document.querySelector('#login-form > div.field input[name="email"]')` is around fifteen.
|
|
531
|
-
- **`--query` and incremental diff** are where the real token savings live. A filtered snapshot on a large page drops output by 95% to 99%, and an incremental diff after an action drops it by 90% or more. These are multiplicative with the already-dense base format.
|
|
509
|
+
`chromex show --annotate` generates a local dashboard with screenshot previews, region/point marking, per-mark notes, and JSON export. Browsers with File System Access support can save the exported pack directly; other browsers download the JSON file.
|
|
532
510
|
|
|
533
|
-
###
|
|
511
|
+
### Storage State and Locators
|
|
534
512
|
|
|
535
|
-
|
|
513
|
+
Storage state captures cookies plus localStorage for the current origin:
|
|
536
514
|
|
|
537
515
|
```bash
|
|
538
|
-
|
|
516
|
+
chromex state <target> save ~/.chromex/storage/auth.json
|
|
517
|
+
chromex state <target> load ~/.chromex/storage/auth.json
|
|
539
518
|
```
|
|
540
519
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
## MCP vs CLI
|
|
544
|
-
|
|
545
|
-
Both interfaces call the same core, same daemons, same commands. The difference is how they integrate with Claude Code.
|
|
546
|
-
|
|
547
|
-
| | CLI (`chromex-cli`) | MCP Server (`chromex-mcp`) |
|
|
548
|
-
|---|---|---|
|
|
549
|
-
| Token overhead | Zero schema cost | ~500 tokens per tool used (deferred loading) |
|
|
550
|
-
| Auto-approve | Glob pattern in settings | `"mcp__chromex"` -- one line |
|
|
551
|
-
| Permissions | All-or-nothing | Per-tool granularity |
|
|
552
|
-
| Parameters | Positional string args | Typed JSON Schema |
|
|
553
|
-
| Screenshots | File path (needs `Read` to view) | Inline image (base64, no extra call) |
|
|
554
|
-
| Best for | Terminal, scripts, CI/CD, token-sensitive sessions | Plug-and-play automation, users who want zero-config |
|
|
520
|
+
Refs can also be converted into reusable locator output or starter action code:
|
|
555
521
|
|
|
556
|
-
|
|
522
|
+
```bash
|
|
523
|
+
chromex locator <target> @e5 --format=chromex-test
|
|
524
|
+
chromex locator <target> @e5 --format=css
|
|
525
|
+
chromex locator <target> @e5 --format=testing-library
|
|
526
|
+
chromex fill <target> @e1 "user@example.com" --code=chromex-test
|
|
527
|
+
```
|
|
557
528
|
|
|
558
|
-
|
|
529
|
+
### Evidence Packs
|
|
559
530
|
|
|
560
|
-
|
|
531
|
+
Evidence packs collect browser evidence without recording video:
|
|
561
532
|
|
|
562
533
|
```bash
|
|
563
|
-
|
|
534
|
+
chromex evidence <target> start checkout-flow
|
|
535
|
+
chromex click <target> @e3
|
|
536
|
+
chromex fill <target> @e5 "user@example.com"
|
|
537
|
+
chromex evidence <target> mark "after login"
|
|
538
|
+
chromex evidence <target> stop
|
|
539
|
+
chromex evidence <target> replay
|
|
564
540
|
```
|
|
565
541
|
|
|
566
|
-
|
|
542
|
+
Each pack is written under `~/.chromex/artifacts/<workspace>/evidence/` and includes screenshots, accessibility snapshots with boxes, HTML captures, console JSON, network JSON, action timeline, `evidence.json`, and `index.html` for local replay. Values passed to `fill`, `type`, and `form` are redacted from the action timeline.
|
|
543
|
+
|
|
544
|
+
## Application State Suite
|
|
567
545
|
|
|
568
|
-
|
|
546
|
+
Chromex exposes browser Application panel state without heavy browser automation runtimes or extra packages. This is useful for debugging PWAs, offline behavior, stale caches, local database migrations, authentication state, and quota issues from the same logged-in browser session an agent is already using.
|
|
569
547
|
|
|
570
548
|
```bash
|
|
571
|
-
#
|
|
572
|
-
|
|
549
|
+
# One-line overview for the current origin
|
|
550
|
+
chromex app <target> summary
|
|
573
551
|
|
|
574
|
-
#
|
|
575
|
-
|
|
576
|
-
```
|
|
552
|
+
# Origin quota and per-storage-type usage
|
|
553
|
+
chromex storage <target> usage
|
|
577
554
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
- You're using chromex from terminal/scripts, not from Claude Code
|
|
555
|
+
# Service Worker registrations and versions
|
|
556
|
+
chromex sw <target>
|
|
557
|
+
chromex sw <target> update https://example.com/
|
|
558
|
+
chromex sw <target> skip-waiting https://example.com/
|
|
583
559
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
- First time using chromex (discovery via tool schema)
|
|
560
|
+
# Cache Storage
|
|
561
|
+
chromex cache <target> list
|
|
562
|
+
chromex cache <target> entries <cacheId> --query=/api
|
|
563
|
+
chromex cache <target> body <cacheId> https://example.com/app.js
|
|
589
564
|
|
|
590
|
-
|
|
565
|
+
# IndexedDB
|
|
566
|
+
chromex idb <target> list
|
|
567
|
+
chromex idb <target> schema app-db
|
|
568
|
+
chromex idb <target> rows app-db users --limit=20
|
|
569
|
+
```
|
|
591
570
|
|
|
592
|
-
|
|
571
|
+
`chromex app <target> summary` includes origin, quota, localStorage key count, sessionStorage key count, cookie count, Cache Storage cache/entry counts, IndexedDB database count, active/waiting Service Worker counts, storage bucket count, and manifest status.
|
|
593
572
|
|
|
594
|
-
|
|
595
|
-
{
|
|
596
|
-
"permissions": {
|
|
597
|
-
"allow": [
|
|
598
|
-
"Bash(chromex-cli *)"
|
|
599
|
-
]
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
```
|
|
573
|
+
Destructive Application commands are explicit: `storage clear-site-data`, `sw unregister`, `cache delete-entry`, `cache delete`, and `idb clear`.
|
|
603
574
|
|
|
604
575
|
## Security
|
|
605
576
|
|
|
606
|
-
|
|
577
|
+
Chromex creates `~/.chromex/config.json` on first run:
|
|
607
578
|
|
|
608
579
|
```json
|
|
609
580
|
{
|
|
610
|
-
"
|
|
581
|
+
"commandTimeout": 15000,
|
|
582
|
+
"navigationTimeout": 30000,
|
|
583
|
+
"idleTimeout": 1200000,
|
|
611
584
|
"allowedDomains": [],
|
|
612
|
-
"
|
|
613
|
-
"
|
|
614
|
-
"auditLog": true
|
|
585
|
+
"blockedDomains": [],
|
|
586
|
+
"blockedCdpMethods": ["Browser.close", "Storage.getCookies"],
|
|
587
|
+
"auditLog": true,
|
|
588
|
+
"socketAuth": true
|
|
615
589
|
}
|
|
616
590
|
```
|
|
617
591
|
|
|
618
|
-
|
|
619
|
-
- **CDP blocklist**: dangerous methods blocked by default in `evalraw`
|
|
620
|
-
- **Socket auth**: 32-byte random token per session (mode 0600)
|
|
621
|
-
- **Audit log**: every command logged with timestamp and status
|
|
592
|
+
Recommended security practices:
|
|
622
593
|
|
|
623
|
-
|
|
594
|
+
- Add sensitive sites to `blockedDomains`, such as email, banking, password managers, and admin panels.
|
|
595
|
+
- Use `allowedDomains` in restricted environments where the agent should access only specific hosts.
|
|
596
|
+
- Keep `socketAuth` enabled.
|
|
597
|
+
- Keep `auditLog` enabled and review `~/.chromex/audit.log` when needed.
|
|
598
|
+
- Prefer `chromex launch --profile testing` for isolated browser state.
|
|
624
599
|
|
|
625
|
-
|
|
600
|
+
See [docs/security.md](docs/security.md) for the full security model.
|
|
626
601
|
|
|
627
|
-
|
|
628
|
-
2. **Daemon spawn** -- first command to a tab spawns a background Node.js process connected via CDP WebSocket
|
|
629
|
-
3. **Session persistence** -- daemon holds the session open; Chrome's "Allow" modal fires once per daemon
|
|
630
|
-
4. **Unix sockets** -- CLI/MCP communicates with daemon via authenticated Unix sockets
|
|
631
|
-
5. **Auto-exit** -- daemons shut down after 20 minutes of inactivity (configurable)
|
|
602
|
+
## How It Works
|
|
632
603
|
|
|
604
|
+
```text
|
|
605
|
+
CLI or MCP client -> authenticated Unix socket -> per-tab daemon -> CDP WebSocket -> browser
|
|
633
606
|
```
|
|
634
|
-
CLI Client ──Unix Socket + Auth──> Per-Tab Daemon ──CDP WebSocket──> Chrome
|
|
635
|
-
MCP Server ──Unix Socket + Auth──> (same) ──CDP WebSocket──> Chrome
|
|
636
|
-
```
|
|
637
607
|
|
|
638
|
-
|
|
608
|
+
1. Chromex finds the browser DevTools endpoint from `DevToolsActivePort` or `CDP_PORT_FILE`.
|
|
609
|
+
2. The first tab command starts a detached daemon for that tab.
|
|
610
|
+
3. The daemon attaches once through CDP and keeps the session open.
|
|
611
|
+
4. CLI and MCP commands talk to the daemon through an authenticated Unix socket.
|
|
612
|
+
5. Daemons exit after the configured idle timeout.
|
|
613
|
+
|
|
614
|
+
See [docs/architecture.md](docs/architecture.md) for implementation details.
|
|
639
615
|
|
|
640
616
|
## Documentation
|
|
641
617
|
|
|
642
618
|
| Guide | Description |
|
|
643
619
|
|-------|-------------|
|
|
644
|
-
| [Getting Started](docs/getting-started.md) | Installation,
|
|
645
|
-
| [Inspect
|
|
646
|
-
| [Navigate
|
|
647
|
-
| [Form Filling](docs/forms.md) | Fill, clear, select, check, upload, batch
|
|
648
|
-
| [Data Access](docs/data.md) | Cookies, localStorage, sessionStorage, PDF export |
|
|
649
|
-
| [Network Control](docs/network.md) | Throttling, interception, mocking, HAR recording |
|
|
650
|
-
| [Device Emulation](docs/emulation.md) | Responsive testing, geolocation, timezone, CPU throttling |
|
|
651
|
-
| [Security](docs/security.md) | Domain filtering, CDP blocklist, audit log, best practices |
|
|
652
|
-
| [Advanced](docs/advanced.md) | Script injection, code coverage, tracing, heap snapshots, WebAuthn |
|
|
653
|
-
| [Architecture](docs/architecture.md) |
|
|
620
|
+
| [Getting Started](docs/getting-started.md) | Installation, browser setup, first commands. |
|
|
621
|
+
| [Inspect and Debug](docs/inspect.md) | Screenshots, accessibility tree, refs, HTML, eval, network, performance, console. |
|
|
622
|
+
| [Navigate and Interact](docs/navigate.md) | Navigation, clicking, typing, scrolling, drag and drop, touch, dialogs. |
|
|
623
|
+
| [Form Filling](docs/forms.md) | Fill, clear, select, check, upload, batch form examples. |
|
|
624
|
+
| [Data Access](docs/data.md) | Cookies, localStorage, sessionStorage, Application state, Cache Storage, IndexedDB, Service Workers, PDF export. |
|
|
625
|
+
| [Network Control](docs/network.md) | Throttling, interception, mocking, HAR recording. |
|
|
626
|
+
| [Device Emulation](docs/emulation.md) | Responsive testing, geolocation, timezone, CPU throttling. |
|
|
627
|
+
| [Security](docs/security.md) | Domain filtering, CDP blocklist, audit log, best practices. |
|
|
628
|
+
| [Advanced](docs/advanced.md) | Script injection, code coverage, tracing, heap snapshots, WebAuthn. |
|
|
629
|
+
| [Architecture](docs/architecture.md) | Daemon model, connection modes, and file layout. |
|
|
630
|
+
|
|
631
|
+
## Development
|
|
632
|
+
|
|
633
|
+
```bash
|
|
634
|
+
git clone https://github.com/whallysson/chromex.git
|
|
635
|
+
cd chromex
|
|
636
|
+
bun install
|
|
637
|
+
bun run test
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
The runtime package has no dependencies. Development dependencies are used only for tests and token benchmarks.
|
|
641
|
+
|
|
642
|
+
Run the browser-backed smoke flow explicitly when validating a release candidate:
|
|
643
|
+
|
|
644
|
+
```bash
|
|
645
|
+
bun run test:smoke
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
The smoke script launches a temporary headless Chromium profile through `CDP_PORT_FILE`, exercises named sessions, snapshots, locators, storage state, annotation dashboard artifacts, and then stops the launched process.
|
|
649
|
+
|
|
650
|
+
To reproduce the token-format comparison:
|
|
651
|
+
|
|
652
|
+
```bash
|
|
653
|
+
bun tests/benchmarks/token-format-comparison.mjs
|
|
654
|
+
```
|
|
654
655
|
|
|
655
656
|
## License
|
|
656
657
|
|
|
657
|
-
MIT
|
|
658
|
+
MIT. See [LICENSE](LICENSE).
|