chromex-mcp 1.6.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.
Files changed (23) hide show
  1. package/README.md +131 -15
  2. package/package.json +4 -3
  3. package/plugins/chromex/skills/chromex/scripts/chromex.mjs +294 -26
  4. package/plugins/chromex/skills/chromex/scripts/lib/artifacts.mjs +55 -0
  5. package/plugins/chromex/skills/chromex/scripts/lib/commands/audit.mjs +2 -1
  6. package/plugins/chromex/skills/chromex/scripts/lib/commands/download.mjs +3 -1
  7. package/plugins/chromex/skills/chromex/scripts/lib/commands/evidence.mjs +284 -0
  8. package/plugins/chromex/skills/chromex/scripts/lib/commands/har.mjs +2 -1
  9. package/plugins/chromex/skills/chromex/scripts/lib/commands/heap.mjs +2 -1
  10. package/plugins/chromex/skills/chromex/scripts/lib/commands/intercept.mjs +131 -37
  11. package/plugins/chromex/skills/chromex/scripts/lib/commands/locator.mjs +173 -0
  12. package/plugins/chromex/skills/chromex/scripts/lib/commands/pdf.mjs +2 -1
  13. package/plugins/chromex/skills/chromex/scripts/lib/commands/screenshot.mjs +5 -3
  14. package/plugins/chromex/skills/chromex/scripts/lib/commands/show.mjs +308 -0
  15. package/plugins/chromex/skills/chromex/scripts/lib/commands/snapshot.mjs +39 -3
  16. package/plugins/chromex/skills/chromex/scripts/lib/commands/state.mjs +86 -0
  17. package/plugins/chromex/skills/chromex/scripts/lib/commands/stats.mjs +4 -2
  18. package/plugins/chromex/skills/chromex/scripts/lib/commands/tab.mjs +6 -1
  19. package/plugins/chromex/skills/chromex/scripts/lib/commands/trace.mjs +2 -1
  20. package/plugins/chromex/skills/chromex/scripts/lib/config.mjs +6 -1
  21. package/plugins/chromex/skills/chromex/scripts/lib/daemon.mjs +86 -8
  22. package/plugins/chromex/skills/chromex/scripts/lib/sessions.mjs +92 -0
  23. package/plugins/chromex/skills/chromex/scripts/mcp-server.mjs +95 -6
package/README.md CHANGED
@@ -4,14 +4,14 @@
4
4
  [![Node.js 22+](https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen.svg)](https://nodejs.org/)
5
5
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
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 73 typed tools.
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
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 Puppeteer or Playwright.
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
10
 
11
11
  ## Why Chromex
12
12
 
13
13
  - **CLI-first for lower token usage**: terminal commands return compact plain text and avoid MCP tool-schema overhead.
14
- - **Optional MCP server**: 73 typed tools for Claude Code and other MCP clients when tool discovery, typed parameters, and inline screenshots matter more than token budget.
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
15
  - **No runtime dependencies**: Node.js 22+ built-ins only, including native WebSocket support.
16
16
  - **Agent-friendly page model**: accessibility snapshots, `@eN` refs, incremental diffs, query filters, auto-snapshots, and contextual hints.
17
17
  - **Persistent per-tab daemons**: one CDP session per tab, held open through an authenticated Unix socket.
@@ -21,13 +21,17 @@ Use Chromex when an agent needs to inspect pages, take screenshots, navigate, cl
21
21
  ## What You Can Do Today
22
22
 
23
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.
24
26
  - Read page state through compact accessibility snapshots, filtered snapshots, DOM snapshots, HTML, screenshots, and highlighted elements.
25
27
  - Act on UI through refs, CSS selectors, coordinates, keyboard input, forms, uploads, drag and drop, touch gestures, dialogs, and load-more loops.
26
28
  - Debug production behavior with console history, network request details, response bodies, HAR export, request blocking, API mocking, throttling, and offline mode.
27
29
  - Test browser conditions with device presets, viewport resizing, DPR, geolocation, timezone, locale, CPU throttling, incognito contexts, proxies, and custom Chrome flags.
28
30
  - Diagnose performance and quality with Core Web Vitals, transfer size, DOM/memory counters, Lighthouse audits, JS/CSS coverage, Chrome traces, and heap snapshots.
29
- - Validate modern browser flows such as passkey/WebAuthn registration and login, downloads, cookies, storage, PDF export, and isolated profiles.
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.
30
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.
31
35
 
32
36
  ## Positioning
33
37
 
@@ -36,7 +40,7 @@ Chromex is a direct CDP layer for coding agents. It sits between raw Chrome DevT
36
40
  | Alternative | Trade-off | Chromex angle |
37
41
  |-------------|-----------|---------------|
38
42
  | Raw CDP WebSocket | Maximum browser power, but too verbose for agents. | Compact commands, refs, snapshots, and safety defaults. |
39
- | Puppeteer or Playwright libraries | Excellent automation frameworks, but they add dependencies and framework-level abstractions. | Zero-runtime-dependency CLI/MCP that talks to your existing Chromium browser. |
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. |
40
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. |
41
45
  | Manual DevTools | Great for humans, not scriptable enough for agents. | DevTools-grade inspection exposed as terminal and MCP commands. |
42
46
 
@@ -48,7 +52,7 @@ Chromex is a direct CDP layer for coding agents. It sits between raw Chrome DevT
48
52
 
49
53
  ## Zero-Dependency Boundary
50
54
 
51
- The core runtime uses only Node.js built-in modules. Chromex does not install Puppeteer, Playwright, Selenium, browser drivers, telemetry SDKs, update checkers, or bundled browsers.
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.
52
56
 
53
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.
54
58
 
@@ -163,12 +167,22 @@ chromex click 6BE8 @e3
163
167
  # 5. Inspect browser state.
164
168
  chromex console 6BE8 list
165
169
  chromex net 6BE8
166
- chromex shot 6BE8 /tmp/page.png
170
+ chromex shot 6BE8
167
171
  chromex app 6BE8
168
172
  ```
169
173
 
170
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.
171
175
 
176
+ For repeatable agent workflows, use named sessions instead of carrying target IDs manually:
177
+
178
+ ```bash
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
184
+ ```
185
+
172
186
  ## Token-Efficient Agent Workflow
173
187
 
174
188
  Chromex is optimized for agents that need to act on browser state without wasting context.
@@ -180,6 +194,8 @@ Chromex is optimized for agents that need to act on browser state without wastin
180
194
  5. Let auto-snapshot show post-action state after interactive commands.
181
195
  6. Add `--no-snap` only for fast scripted batches where you do not need immediate page state.
182
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.
183
199
 
184
200
  Examples:
185
201
 
@@ -188,6 +204,11 @@ chromex snap 6BE8 --query=login --refs
188
204
  chromex click 6BE8 @e4
189
205
  chromex wait 6BE8 networkidle
190
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
191
212
  ```
192
213
 
193
214
  ## MCP Server
@@ -216,7 +237,9 @@ claude mcp add chromex npx chromex-mcp@latest
216
237
  claude mcp add chromex bunx chromex-mcp@latest
217
238
  ```
218
239
 
219
- 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`, and `chromex_indexeddb_rows`.
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`.
241
+
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.
220
243
 
221
244
  ### Claude Code Auto-Approve
222
245
 
@@ -272,6 +295,10 @@ claude mcp remove chromex
272
295
  ```bash
273
296
  chromex list
274
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
275
302
  chromex close <target>
276
303
  chromex focus <target>
277
304
  chromex launch --url https://example.com
@@ -288,14 +315,19 @@ chromex stop
288
315
  ```bash
289
316
  chromex snap <target> --refs
290
317
  chromex snap <target> --query=login
318
+ chromex snap <target> --filename=~/.chromex/snapshots/login.yml --boxes
291
319
  chromex html <target> "#main"
292
- chromex shot <target> /tmp/page.png
293
- chromex shot <target> /tmp/full.png --full
320
+ chromex shot <target>
321
+ chromex shot <target> ~/.chromex/screenshots/full.png --full
294
322
  chromex shot <target> @e5
295
323
  chromex console <target> list
296
324
  chromex net <target>
297
325
  chromex perf <target>
298
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
299
331
  ```
300
332
 
301
333
  ### Navigate and Wait
@@ -317,6 +349,8 @@ chromex clickxy <target> 100 200
317
349
  chromex key <target> Enter
318
350
  chromex type <target> "hello world"
319
351
  chromex hover <target> @e12
352
+ chromex locator <target> @e12 --format=chromex-test
353
+ chromex click <target> @e12 --code=chromex-test
320
354
  chromex drag <target> "#source" "#dest"
321
355
  chromex dialog <target> accept
322
356
  ```
@@ -340,6 +374,8 @@ chromex cookies <target> set '{"name":"token","value":"abc"}'
340
374
  chromex storage <target> local
341
375
  chromex storage <target> session
342
376
  chromex storage <target> usage
377
+ chromex state <target> save ~/.chromex/storage/auth.json
378
+ chromex state <target> load ~/.chromex/storage/auth.json
343
379
  chromex app <target> summary
344
380
  chromex sw <target>
345
381
  chromex cache <target> list
@@ -347,7 +383,7 @@ chromex cache <target> entries <cacheId> --query=/api
347
383
  chromex idb <target> list
348
384
  chromex idb <target> schema <databaseName>
349
385
  chromex idb <target> rows <databaseName> <objectStoreName> --limit=20
350
- chromex pdf <target> /tmp/page.pdf
386
+ chromex pdf <target>
351
387
  ```
352
388
 
353
389
  ### Network, Emulation, and Diagnostics
@@ -355,8 +391,12 @@ chromex pdf <target> /tmp/page.pdf
355
391
  ```bash
356
392
  chromex throttle <target> 3g
357
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
358
398
  chromex har <target> start
359
- chromex har <target> stop /tmp/trace.har
399
+ chromex har <target> stop ~/.chromex/har/trace.har
360
400
  chromex emulate <target> iphone-15-pro
361
401
  chromex resize <target> 1280 720
362
402
  chromex geo <target> -23.55 -46.63
@@ -372,10 +412,10 @@ chromex stats <target> --full
372
412
  chromex eval <target> "document.title"
373
413
  chromex evalraw <target> "Page.getLayoutMetrics"
374
414
  chromex inject <target> "window.DEBUG=true"
375
- chromex download <target> allow /tmp/downloads
415
+ chromex download <target> allow ~/.chromex/downloads
376
416
  chromex coverage <target> start
377
417
  chromex trace <target> start
378
- chromex heap <target> snapshot /tmp/heap.heapsnapshot
418
+ chromex heap <target> snapshot ~/.chromex/heap/heap.heapsnapshot
379
419
  chromex webauthn <target> enable
380
420
  ```
381
421
 
@@ -433,9 +473,77 @@ help[3]:
433
473
 
434
474
  Disable hints with `--no-hints`.
435
475
 
476
+ ### Stable Output and Artifacts
477
+
478
+ Chromex keeps plain text as the default output, but also supports stable modes for scripts:
479
+
480
+ ```bash
481
+ chromex --raw eval <target> "document.title"
482
+ chromex list --json
483
+ chromex snap <target> --filename=~/.chromex/snapshots/home.yml --boxes
484
+ ```
485
+
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`.
487
+
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.
489
+
490
+ ### Named Sessions
491
+
492
+ Named sessions let agents reuse isolated browser contexts without carrying target IDs:
493
+
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
+ ```
503
+
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.
506
+
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.
508
+
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.
510
+
511
+ ### Storage State and Locators
512
+
513
+ Storage state captures cookies plus localStorage for the current origin:
514
+
515
+ ```bash
516
+ chromex state <target> save ~/.chromex/storage/auth.json
517
+ chromex state <target> load ~/.chromex/storage/auth.json
518
+ ```
519
+
520
+ Refs can also be converted into reusable locator output or starter action code:
521
+
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
+ ```
528
+
529
+ ### Evidence Packs
530
+
531
+ Evidence packs collect browser evidence without recording video:
532
+
533
+ ```bash
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
540
+ ```
541
+
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
+
436
544
  ## Application State Suite
437
545
 
438
- Chromex exposes browser Application panel state without Puppeteer, Playwright, 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.
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.
439
547
 
440
548
  ```bash
441
549
  # One-line overview for the current origin
@@ -531,6 +639,14 @@ bun run test
531
639
 
532
640
  The runtime package has no dependencies. Development dependencies are used only for tests and token benchmarks.
533
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
+
534
650
  To reproduce the token-format comparison:
535
651
 
536
652
  ```bash
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "chromex-mcp",
3
- "version": "1.6.0",
4
- "description": "Zero-dependency Chrome DevTools Protocol MCP server for AI agents. 73 typed tools, Application state inspection, per-tab daemons, security hardened, contextual hints, query-filtered snapshots.",
3
+ "version": "1.7.0",
4
+ "description": "Zero-dependency Chrome DevTools Protocol MCP server for AI agents. 78 typed tools, Application state inspection, evidence packs, per-tab daemons, security hardened, contextual hints, query-filtered snapshots.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "chromex": "bin/chromex.mjs",
@@ -16,6 +16,7 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "test": "vitest run",
19
+ "test:smoke": "node tests/smoke/agent-dx-smoke.mjs",
19
20
  "test:watch": "vitest"
20
21
  },
21
22
  "keywords": [
@@ -30,7 +31,7 @@
30
31
  "browser",
31
32
  "testing",
32
33
  "scraping",
33
- "playwright-alternative"
34
+ "browser-automation"
34
35
  ],
35
36
  "author": {
36
37
  "name": "Whallysson Avelino",