turbo-browser-mcp 0.6.0 → 0.6.1

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 CHANGED
@@ -1,164 +1,253 @@
1
1
  # turbo-browser-mcp
2
2
 
3
3
  [![CI](https://github.com/Tthanh2k6/turbo-browser-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Tthanh2k6/turbo-browser-mcp/actions/workflows/ci.yml)
4
- ![Version](https://img.shields.io/badge/version-0.5.0-blue)
5
- ![Tests](https://img.shields.io/badge/tests-407%20passing%20(86%20suites)-brightgreen)
6
- ![Node](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen)
4
+ [![npm](https://img.shields.io/npm/v/turbo-browser-mcp)](https://www.npmjs.com/package/turbo-browser-mcp)
5
+ ![Tests](https://img.shields.io/badge/tests-437%20passing-brightgreen)
6
+ ![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen)
7
7
  ![License](https://img.shields.io/badge/license-MIT-lightgrey)
8
8
 
9
- `turbo-browser-mcp` is a Playwright-based Model Context Protocol (MCP) server built to cut LLM token waste and multi-turn latency in browser automation. It consolidates 25-33 fine-grained browser primitives into **10 batched tools** featuring delta DOM snapshots, single-turn React/Shadow DOM/iframe form prefill, direct disk file uploads (no Base64 in context), parallel tab sessions, network blocking presets, and a default human-in-the-loop Submit guard.
9
+ An MCP server for browser automation, built on Playwright. It has 11 tools where `@playwright/mcp` has 25 and `chrome-devtools-mcp` has 33, and each tool does more per call:
10
10
 
11
- ---
11
+ - one `smart_fill_form` call fills a whole form, including React inputs, selects, comboboxes, rich-text editors and file uploads read from disk;
12
+ - `inspect_compact` can return only the elements that changed since the last snapshot;
13
+ - `batch_actions` runs a list of clicks, key presses and form steps as one call.
12
14
 
13
- ## At-a-Glance Performance & Token Scorecard
15
+ Fewer calls means fewer model turns and less page text replayed in the conversation. The numbers are in [Benchmarks](#benchmarks).
14
16
 
15
- All figures below come from [`benchmarks/benchmark.mjs`](benchmarks/benchmark.mjs) (`npm run benchmark`) running headless Chromium locally with exact OpenAI `o200k_base` tokenization (`tiktoken 0.14.0`):
17
+ Buttons that look like a final commit (Submit, Send, Publish, Pay, Confirm, and their Korean, Japanese, Chinese and Vietnamese equivalents) are blocked by default, so an agent can prefill a form and leave the last click to a person. Pass `allowSubmit: true` per call or start with `--allow-submit` to turn this off.
16
18
 
17
- | Capability | Typical Baseline | `turbo-browser-mcp` | Speed / Turn Gain | Token Savings (`o200k_base`) |
18
- | :--- | :--- | :--- | :--- | :--- |
19
- | **Dense UI Snapshot** (140-btn SaaS console) | `18,654` tok HTML / `3,568` tok full ARIA | **`1,135` tok** compact (`28 ms`) | `1` call | **`93.9%` vs HTML** (`68.2%` vs ARIA) |
20
- | **Post-Click Delta Snapshot** (`onlyChanged: true`) | `3,582` tok full ARIA rescan | **`56` tok** changed lines (`18 ms`) | `1` call | **`98.4%` vs ARIA** (`99.7%` vs HTML) |
21
- | **10-Field Complex Form + Snapshot** (`smart_fill_form`) | `11` turns (`574 ms`, `12,197` dir / `72,614` cum tok) | **`1` turn** (`82 ms`, **`811` tok**) | **`7x` faster**, `11 -> 1` turns | **`93.4%` direct / `98.9%` cumulative** |
22
- | **48 KiB PDF Upload** (`49,152` bytes) | `44,728` tok inline Base64 tool arg | **`85` tok** disk path (`68 ms`) | Zero Base64 generation | **`99.8%` saved** |
23
- | **6-Step Interactive UI Flow** (`batch_actions`) | `6` turns (`411 ms`, `955` dir / `3,162` cum tok) | **`1` turn** (`357 ms`, **`406` tok**) | **`1.15x` faster**, `6 -> 1` turns | **`57.5%` direct / `87.2%` cumulative** |
24
- | **Open 6 Tabs Concurrently** (`open_many`) | `6` turns sequential (`998 ms`) | **`1` turn** batched (`420 ms`) | **`2.38x` faster**, `6x` fewer turns | `5` fewer prompt replays |
25
- | **Heavy Media Load** (`preset: "turbo"`, `304 KiB` assets) | `252 ms`, `9` media requests (`304 KiB`) | **`165 ms`**, `0` media requests (`0 KiB`) | **`1.53x` faster** | **`100%` media bandwidth cut** |
26
- | **Article Markdown Scraping** (`extract_clean_text`) | `3,595` tok raw HTML (`10,844` chars) | **`156` tok** clean Markdown (`641` chars) | Clean reader output | **`95.7%` saved** |
27
- | **Diagnostics Triage** (`page_diagnostics` errors-only) | `3,460` tok unfiltered (`32` req / `26` console) | **`601` tok** default errors (`2` req / `6` console) | Zero noise scrolling | **`82.6%` saved** |
28
- | **Static MCP Tool Schema** (every turn overhead) | `3,917` tok Playwright / `6,737` tok DevTools | **`3,170` tok** stripped (`3,541` full w/ annotations) | `11` tools vs `25` / `33` | **`19.1%` vs Playwright / `52.9%` vs DevTools** |
29
-
30
- > **Note on latency vs LLM inference turns:** Eliminating `10` round-trips on a 10-field form saves both `7x` in browser execution (`574 ms -> 82 ms`) and `10` separate LLM inference round-trips (`2-5s` per turn in agent loops) plus `~71,800` replayed history tokens.
31
-
32
- ---
33
-
34
- ## Why Browser Agents Stall: Side-by-Side Workflow
35
-
36
- Standard MCP servers charge an LLM round-trip for every snapshot, field fill, `<select>` choice, upload, and verification check. Each turn re-sends the growing conversation history back into the model.
37
-
38
- ```mermaid
39
- sequenceDiagram
40
- autonumber
41
- participant Agent as LLM Agent
42
- participant Std as Standard MCP (Playwright / DevTools)
43
- participant Turbo as turbo-browser-mcp
44
-
45
- Note over Agent,Std: Standard MCP (12+ LLM turns, full ARIA tree + history replay each step)
46
- Agent->>Std: 1. snapshot() -> full ARIA (~3,568 tok)
47
- loop Repeats 10+ times across fields, selects, checkboxes, upload
48
- Agent->>Std: fill / select_option / click
49
- Std-->>Agent: full ARIA or confirmation re-added to history
50
- end
51
- Agent->>Std: 12. upload inline or click chooser
52
-
53
- Note over Agent,Turbo: turbo-browser-mcp (2 LLM turns total, delta & inline snapshot)
54
- Agent->>Turbo: 1. inspect_compact(mode: "forms") -> compact refs (1,135 tok)
55
- Agent->>Turbo: 2. smart_fill_form(fields: [...10 fields + disk PDF...], returnSnapshot: true)
56
- Turbo-->>Agent: Filled 10 fields + guarded before Submit + inline snapshot (811 tok)
19
+ The server does not hide that the browser is automated: no stealth patches, no fingerprint changes, no CAPTCHA solving. For sites with a bot check it can hand the tab to a person and continue afterwards ([`wait_for_human`](#handing-a-step-to-a-person-wait_for_human---open-profile)).
20
+
21
+ ## Install
22
+
23
+ Needs Node 20 or newer and a Chromium-based browser (Chrome, Edge, Brave, or Playwright's Chromium).
24
+
25
+ Claude Code:
26
+
27
+ ```bash
28
+ claude mcp add turbo-browser -- npx -y turbo-browser-mcp
29
+ ```
30
+
31
+ Clients that read an `mcpServers` JSON config (Cursor, Claude Desktop, Antigravity and others):
32
+
33
+ ```json
34
+ {
35
+ "mcpServers": {
36
+ "turbo-browser": {
37
+ "command": "npx",
38
+ "args": ["-y", "turbo-browser-mcp"],
39
+ "env": { "TURBO_BROWSER_SAVE_ROOT": "/absolute/path/to/workspace" }
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ `TURBO_BROWSER_SAVE_ROOT` is the only folder the server may write screenshots, PDFs and storage files to, or read storage files from. Leave it out and the current working directory is used.
46
+
47
+ Check the setup, and install Chromium if no browser is found:
48
+
49
+ ```bash
50
+ npx -y turbo-browser-mcp --doctor
51
+ npx playwright-core install chromium
52
+ ```
53
+
54
+ By default the server first tries a Chrome that is already listening on `http://127.0.0.1:9222`, so the agent can use a browser you are signed in to, and otherwise launches its own headless Chromium. `--mode`, `--headed` and the other options are listed under [CLI options](#cli-options-and-environment-variables).
55
+
56
+ From source:
57
+
58
+ ```bash
59
+ git clone https://github.com/Tthanh2k6/turbo-browser-mcp.git
60
+ cd turbo-browser-mcp
61
+ npm install
62
+ node src/index.mjs --doctor
63
+ ```
64
+
65
+ ## Tools
66
+
67
+ | Tool | Purpose | Key Parameters |
68
+ | :--- | :--- | :--- |
69
+ | `tabs_batch` | Ordered tab & browser lifecycle | `operations[]` (`list`, `open`, `open_many`, `navigate`, `activate`, `resize`, `emulate`, `reload`, `back`, `forward`, `close`, `close_browser`), `isolatedContext`, `concurrency` (1-10) |
70
+ | `inspect_compact` | Token-capped element/form/article snapshot | `mode` (`interactive`, `forms`, `article`, `all`), `onlyChanged`, `query`, `boxes`, `maxChars`, `includeFrames`, `savePath` |
71
+ | `smart_fill_form` | Batch form, editor & disk file prefill | `fields[]` (`ref`, `selector`, `value`, `option`, `values`, `check`, `not`, `keys`, `file`, `files`, `frameIdx`, `all`), `gmail`, `overwrite`, `stopBeforeSubmit`, `returnSnapshot` |
72
+ | `act_fast` | Single targeted page action | `action` (`16` actions), `ref`/`selector`/`text`/`label`/`(x, y)`, `modifiers`, `dropData`, `allowSubmit`, `observeAftermath`, `returnSnapshot` |
73
+ | `batch_actions` | Ordered chain of actions + form steps | `steps[]`, `continueOnError`, `allowSubmit`, `expect`, `submissionKey`, `allowDuplicate`, `observeAftermath`, `returnSnapshot`, `snapshotMaxChars` |
74
+ | `extract_clean_text` | Clean text or compact Markdown reader | `format` (`text`, `markdown`), `selector`, `includeFrames`, `maxChars`, `savePath` |
75
+ | `evaluate_js` | Scoped JS expression or `(el, arg)` call | `expression`, `arg`, `frameIdx`, `ref`/`selector`/`text`, `savePath` |
76
+ | `page_diagnostics` | Console, network, downloads & dialogs | `level` (`errors`, `all`), `statusFilter` (`errors`, `all`), `includeStatic`, `urlFilter`, `reqId`, `part`, `dialogPolicy`, `clear`, `savePath` |
77
+ | `capture_page` | PNG/JPEG screenshots & PDF export | `mode` (`screenshot`, `pdf`), `type`, `quality`, `fullPage`, `scale` (`css`, `device`), `ref`/`selector`/`text`, `returnImage`, `savePath` |
78
+ | `network_session` | Resource blockers, cookies & storage | `preset` (`turbo`, `no-images`, `no-media`, `clean`), `blockResources`, `blockUrls`, `cookieAction`, `storageAction`, `loadStorageStatePath`, `saveStorageStatePath` |
79
+ | `wait_for_human` | Hand a step to a person, resume in the same session | `message`, `urlMatches`, `selector`, `textMatches`, `textGone`, `timeoutMs`, `pollMs` |
80
+
81
+ ### Examples
82
+
83
+ #### Fill a form, attach a PDF from disk, return the result in the same call
84
+
85
+ ```json
86
+ {
87
+ "name": "smart_fill_form",
88
+ "arguments": {
89
+ "fields": [
90
+ { "selector": "#full_name", "value": "Alex Nguyen" },
91
+ { "selector": "#email", "value": "alex@example.com" },
92
+ { "selector": "#country", "option": "United States" },
93
+ { "selector": "#skills", "values": ["TypeScript", "Playwright"] },
94
+ { "selector": "#agree_terms", "check": true },
95
+ { "selector": "#resume_pdf", "file": "./assets/resume.pdf" }
96
+ ],
97
+ "stopBeforeSubmit": true,
98
+ "returnSnapshot": true
99
+ }
100
+ }
101
+ ```
102
+
103
+ #### Read only what changed after opening a modal
104
+
105
+ ```json
106
+ {
107
+ "name": "inspect_compact",
108
+ "arguments": {
109
+ "mode": "interactive",
110
+ "onlyChanged": true,
111
+ "maxChars": 3000
112
+ }
113
+ }
57
114
  ```
58
115
 
59
- ---
116
+ #### Open tabs in parallel in separate cookie contexts
117
+
118
+ ```json
119
+ {
120
+ "name": "tabs_batch",
121
+ "arguments": {
122
+ "operations": [
123
+ { "action": "open", "url": "https://example.com/app", "isolatedContext": "acct-a" },
124
+ { "action": "open_many", "urls": ["https://example.com/docs", "https://example.com/pricing"], "concurrency": 4 }
125
+ ]
126
+ }
127
+ }
128
+ ```
129
+
130
+ #### Allow the final click, check for a receipt, refuse a repeat
131
+
132
+ ```json
133
+ {
134
+ "name": "batch_actions",
135
+ "arguments": {
136
+ "steps": [
137
+ { "action": "smart_fill_form", "fields": [{ "selector": "#name", "value": "홍길동" }] },
138
+ { "action": "click", "text": "다음" },
139
+ { "action": "click", "text": "확인" }
140
+ ],
141
+ "allowSubmit": true,
142
+ "expect": { "textMatches": "접수번호\\s*R-\\d+", "timeoutMs": 8000 },
143
+ "submissionKey": "photo-contest:2026-11-15:entry-1"
144
+ }
145
+ }
146
+ ```
60
147
 
61
- ## What `turbo-browser-mcp` Supports
148
+ ## What each tool does
62
149
 
63
- ### 1. Connection & Session Isolation
64
- - **4 connection modes (`--mode auto|cdp|persistent|launch`):**
150
+ ### Connection and sessions (`tabs_batch`)
151
+ - 4 connection modes (`--mode auto|cdp|persistent|launch`):
65
152
  - `auto` (default): probes `--cdp http://127.0.0.1:9222` first so agents can reuse an existing signed-in browser session, then falls back to launching Chromium.
66
153
  - `cdp`: attach directly to a running Chromium/Chrome/Edge remote debugging port.
67
154
  - `persistent`: launch with a reusable `--user-data-dir` profile across runs.
68
155
  - `launch`: start a clean browser session (`--headless` by default, or `--headed`).
69
- - **Auto binary discovery (`src/playwright-loader.mjs`):** checks `playwright-core` cache revisions across Windows, macOS, and Linux, system installs of Google Chrome, Microsoft Edge, Brave, and Chromium, or an explicit `--executable <path>`.
70
- - **Per-tab isolation (`tabs_batch`):** open tabs inside named `isolatedContext` sandboxes with separate cookies and storage, batch-open up to 10 concurrent URLs (`open_many`), activate, reload, go `back`/`forward`, `resize` viewport, and emulate `colorScheme`, `media`, `reducedMotion`, `contrast`, `forcedColors`, or custom `userAgent`.
156
+ - Auto binary discovery (`src/playwright-loader.mjs`): checks `playwright-core` cache revisions across Windows, macOS, and Linux, system installs of Google Chrome, Microsoft Edge, Brave, and Chromium, or an explicit `--executable <path>`.
157
+ - Per-tab isolation (`tabs_batch`): open tabs inside named `isolatedContext` sandboxes with separate cookies and storage, batch-open up to 10 concurrent URLs (`open_many`), activate, reload, go `back`/`forward`, `resize` viewport, and emulate `colorScheme`, `media`, `reducedMotion`, `contrast`, `forcedColors`, or custom `userAgent`.
71
158
 
72
- ### 2. DOM, Iframe & Shadow DOM Inspection (`inspect_compact`)
73
- - **Snapshot modes:** `interactive`, `forms`, `article`, and `all`.
74
- - **Cross-boundary traversal:** flattens main frame DOM, child iframes (`includeFrames`, `frameIdx`), and open Shadow DOM. Injects an init script hooking `Element.prototype.attachShadow` (`WeakMap` + `WeakRef`/`FinalizationRegistry` + `window.__tbmGetShadowRoot`) to keep post-init closed Shadow roots inspectable and guarded, traverses `<slot>` `assignedNodes({ flatten: true })`, and supports Form-Associated Custom Elements.
75
- - **Token controls:** `onlyChanged: true` emits only elements added or changed since the prior snapshot; `query` filters by regex or substring; `boxes: true` adds `[box=x,y,w,h]` only when needed; `maxChars` caps payload size; `savePath` writes full output to disk.
159
+ ### Page snapshots (`inspect_compact`)
160
+ - Snapshot modes: `interactive`, `forms`, `article`, and `all`.
161
+ - Cross-boundary traversal: flattens main frame DOM, child iframes (`includeFrames`, `frameIdx`), and open Shadow DOM. Injects an init script hooking `Element.prototype.attachShadow` (`WeakMap` + `WeakRef`/`FinalizationRegistry` + `window.__tbmGetShadowRoot`) to keep post-init closed Shadow roots inspectable and guarded, traverses `<slot>` `assignedNodes({ flatten: true })`, and supports Form-Associated Custom Elements.
162
+ - Token controls: `onlyChanged: true` emits only elements added or changed since the prior snapshot; `query` filters by regex or substring; `boxes: true` adds `[box=x,y,w,h]` only when needed; `maxChars` caps payload size; `savePath` writes full output to disk.
76
163
 
77
- ### 3. Single-Turn Smart Form Engine (`smart_fill_form`)
164
+ ### Forms in one call (`smart_fill_form`)
78
165
  Prefills an entire form in one MCP call while flushing microtasks and macrotasks between controlled inputs:
79
- - **Standard & framework inputs:** text, email, password, number, date, textarea, `<input type="range">`, checkboxes, radio groups (`check`, `not`, `overwrite`). Triggers React-controlled state updates via native property setters and synthetic events.
80
- - **Selects & custom widgets:** `<select>` and `<select multiple>` (`option` / `values`), ARIA comboboxes, ARIA switches, `contenteditable` rich editors, and Gmail compose dialogs (`gmail: { to, subject, body }`).
81
- - **Frame & wildcard targeting:** target specific iframes via `frameIdx`, or set `all: true` to populate matching controls across frames.
82
- - **Direct disk uploads:** pass `file` or `files` paths directly to Playwright `setInputFiles` without loading binary files or Base64 strings into LLM context.
83
- - **Atomic verification:** pass `returnSnapshot: true` to inspect the updated form state in the same tool response.
166
+ - Standard & framework inputs: text, email, password, number, date, textarea, `<input type="range">`, checkboxes, radio groups (`check`, `not`, `overwrite`). Triggers React-controlled state updates via native property setters and synthetic events.
167
+ - Selects & custom widgets: `<select>` and `<select multiple>` (`option` / `values`), ARIA comboboxes, ARIA switches, `contenteditable` rich editors, and Gmail compose dialogs (`gmail: { to, subject, body }`).
168
+ - Frame & wildcard targeting: target specific iframes via `frameIdx`, or set `all: true` to populate matching controls across frames.
169
+ - Direct disk uploads: pass `file` or `files` paths directly to Playwright `setInputFiles` without loading binary files or Base64 strings into LLM context.
170
+ - Atomic verification: pass `returnSnapshot: true` to inspect the updated form state in the same tool response.
84
171
 
85
- ### 4. 16 Interactive Actions & Multi-Step Chaining (`act_fast`, `batch_actions`)
86
- - **`act_fast` actions:** `click`, `dblclick`, `hover`, `focus`, `clear`, `fill`, `type` (`slowly`, `delayMs`, `submit`), `select`, `check`, `uncheck`, `drag`, `drop` (`file`, `files`, or custom MIME `dropData`), `press` (`key` + `modifiers`: `Alt`, `Control`, `ControlOrMeta`, `Meta`, `Shift`), `scroll` (`dx`, `dy`), `wait` (`ms`, `state`, `loadState`, `text`, `textGone`, `url`), and `upload`.
87
- - **Targeting options:** compact `[eN]` `ref`, CSS `selector`, visible `text`, `label`, or viewport `(x, y)` coordinates, with `button` (`left`, `right`, `middle`) and `frameIdx`.
88
- - **`batch_actions`:** runs an ordered list of DOM actions and nested `smart_fill_form` steps in one MCP call, stopping safely if blocked by the Submit guard or optionally continuing on step errors (`continueOnError`).
172
+ ### Actions and chains (`act_fast`, `batch_actions`)
173
+ - `act_fast` actions: `click`, `dblclick`, `hover`, `focus`, `clear`, `fill`, `type` (`slowly`, `delayMs`, `submit`), `select`, `check`, `uncheck`, `drag`, `drop` (`file`, `files`, or custom MIME `dropData`), `press` (`key` + `modifiers`: `Alt`, `Control`, `ControlOrMeta`, `Meta`, `Shift`), `scroll` (`dx`, `dy`), `wait` (`ms`, `state`, `loadState`, `text`, `textGone`, `url`), and `upload`.
174
+ - Targeting options: compact `[eN]` `ref`, CSS `selector`, visible `text`, `label`, or viewport `(x, y)` coordinates, with `button` (`left`, `right`, `middle`) and `frameIdx`.
175
+ - `batch_actions`: runs an ordered list of DOM actions and nested `smart_fill_form` steps in one MCP call, stopping safely if blocked by the Submit guard or optionally continuing on step errors (`continueOnError`).
89
176
 
90
- ### 5. Clean Extraction, Evaluation & Media Capture (`extract_clean_text`, `evaluate_js`, `capture_page`)
91
- - **`extract_clean_text`:** extracts readable plain text or compact Markdown (`format: "text" | "markdown"`) from main/article containers and iframes, stripped of script and style noise.
92
- - **`evaluate_js`:** runs JS expressions or `(el, arg)` element functions in any frame (`frameIdx`) with JSON-serialized results and optional `savePath` export.
93
- - **`capture_page`:** full-page or element-scoped screenshots (`png` or `jpeg` with `quality`, `css` or `device` scale, optional `returnImage`) and PDF generation saved to a confined `savePath`.
177
+ ### Text, JavaScript and screenshots (`extract_clean_text`, `evaluate_js`, `capture_page`)
178
+ - `extract_clean_text`: extracts readable plain text or compact Markdown (`format: "text" | "markdown"`) from main/article containers and iframes, stripped of script and style noise.
179
+ - `evaluate_js`: runs JS expressions or `(el, arg)` element functions in any frame (`frameIdx`) with JSON-serialized results and optional `savePath` export.
180
+ - `capture_page`: full-page or element-scoped screenshots (`png` or `jpeg` with `quality`, `css` or `device` scale, optional `returnImage`) and PDF generation saved to a confined `savePath`.
94
181
 
95
- ### 6. Network Blocking, Storage State & Diagnostics (`network_session`, `page_diagnostics`)
96
- - **`network_session` presets:** `turbo`, `no-images`, `no-media`, and `clean` (unblock all), alongside custom `blockResources` and `blockUrls` patterns.
97
- - **Session & storage management:** read/write/clear browser `cookies`, `localStorage`/`sessionStorage`, and export or reload full Playwright `storageState` JSON files (`saveStorageStatePath`, `loadStorageStatePath`).
98
- - **`page_diagnostics`:** defaults to errors-only (`level: "errors"`, `statusFilter: "errors"`) to surface failures cleanly without flooding context, while supporting `all`, `includeStatic`, `urlFilter`, deep request/response inspection (`reqId` + `part`), completed downloads, and dialog auto-handling (`dialogPolicy`: `accept`/`dismiss`).
182
+ ### Network, storage and diagnostics (`network_session`, `page_diagnostics`)
183
+ - `network_session` presets: `turbo`, `no-images`, `no-media`, and `clean` (unblock all), alongside custom `blockResources` and `blockUrls` patterns.
184
+ - Session & storage management: read/write/clear browser `cookies`, `localStorage`/`sessionStorage`, and export or reload full Playwright `storageState` JSON files (`saveStorageStatePath`, `loadStorageStatePath`).
185
+ - `page_diagnostics`: defaults to errors-only (`level: "errors"`, `statusFilter: "errors"`) to surface failures cleanly without flooding context, while supporting `all`, `includeStatic`, `urlFilter`, deep request/response inspection (`reqId` + `part`), completed downloads, and dialog auto-handling (`dialogPolicy`: `accept`/`dismiss`).
99
186
 
100
- ---
187
+ ## Benchmarks
101
188
 
102
- ## Reproducible Benchmarks (`npm run benchmark`)
189
+ ### Per-tool measurements (`npm run benchmark`)
103
190
 
104
- Run the benchmark suite yourself with Chromium and Playwright installed:
191
+ These come from [`benchmarks/benchmark.mjs`](benchmarks/benchmark.mjs) on local fixture pages in headless Chromium. Tokens are counted with `tiktoken` (`o200k_base`). They measure the size of tool output and the time spent in the browser. Model time is not included, so read them as an upper bound on what an agent gains, not as an agent result.
105
192
 
106
- ```bash
107
- npm run benchmark
108
- ```
193
+ "Cumulative" tokens model a chat agent that re-reads every earlier tool result on each turn: over N turns, the output of turn i is read N − i + 1 times. Each call saved is also one model round-trip, which in most agent loops takes longer than the browser work itself.
109
194
 
110
- **Environment & methodology:** Headless Chromium via `playwright-core`, counting exact OpenAI `o200k_base` tokens via Python `tiktoken` (`approx-bpe` fallback if `tiktoken` is unavailable). Cumulative workflow tokens model standard chat-history replay across $N$ sequential turns: $\sum_{i=1}^{N} (N - i + 1) \cdot T_i$, plus a one-shot baseline where the first turn captures context before acting.
111
-
112
- ### 1. Snapshot & Reader Extraction (Chars & Exact `o200k_base` Tokens)
195
+ ### Snapshots and text extraction
113
196
 
114
197
  | Scenario | Raw HTML | Full Playwright ARIA | `turbo-browser-mcp` Output | Saved vs ARIA | Saved vs HTML |
115
198
  | :--- | :--- | :--- | :--- | :--- | :--- |
116
- | **140-Button SaaS Console** (`inspect_compact`) | `61,010` chars (`18,654` tok) | `12,771` chars (`3,568` tok) | **`3,968` chars (`1,135` tok)** | **`68.2%`** | **`93.9%`** |
117
- | **Post-Click Delta** (`onlyChanged: true`) | `61,010` chars (`18,654` tok) | `12,825` chars (`3,582` tok) | **`168` chars (`56` tok)** | **`98.4%`** | **`99.7%`** |
118
- | **Article Markdown Extraction** (`extract_clean_text`) | `10,844` chars (`3,595` tok) | n/a | **`641` chars (`156` tok)** | n/a | **`95.7%`** |
119
- | **Diagnostics Filter** (`32` reqs, `26` console logs) | `9,651` chars (`3,460` tok, `all`) | n/a | **`1,761` chars (`601` tok, `errors`)** | n/a | **`82.6%`** |
199
+ | 140-Button SaaS Console (`inspect_compact`) | `61,010` chars (`18,654` tok) | `12,771` chars (`3,568` tok) | `3,968` chars (`1,135` tok) | `68.2%` | `93.9%` |
200
+ | Post-Click Delta (`onlyChanged: true`) | `61,010` chars (`18,654` tok) | `12,825` chars (`3,582` tok) | `168` chars (`56` tok) | `98.4%` | `99.7%` |
201
+ | Article Markdown Extraction (`extract_clean_text`) | `10,844` chars (`3,595` tok) | n/a | `641` chars (`156` tok) | n/a | `95.7%` |
202
+ | Diagnostics Filter (`32` reqs, `26` console logs) | `9,651` chars (`3,460` tok, `all`) | n/a | `1,761` chars (`601` tok, `errors`) | n/a | `82.6%` |
120
203
 
121
- ### 2. Multi-Turn Forms, Workflows, Uploads & Network Speed
204
+ ### Forms, multi-step flows, uploads and page loading
122
205
 
123
206
  | Scenario | Step-by-Step Baseline | `turbo-browser-mcp` | Execution Speedup | Token Savings |
124
207
  | :--- | :--- | :--- | :--- | :--- |
125
- | **10-Field Complex Form + Verify** (`smart_fill_form`) | `11` turns, `574 ms`, `12,197` direct / `72,614` cum tok | **`1` turn**, **`82 ms`**, **`811` tok** (`filled=10`) | **`7x` faster** | **`93.4%` dir / `98.9%` cum** |
126
- | **48 KiB PDF Upload** (`49,152` bytes via `file`) | `65,679` chars (`44,728` tok) Base64 payload | **`263` chars (`85` tok)** disk path (`68 ms`) | Zero LLM Base64 encode | **`99.8%`** |
127
- | **6-Step UI Flow** (`batch_actions`) | `6` turns, `411 ms`, `955` dir / `3,162` cum tok | **`1` turn**, **`357 ms`**, **`406` tok** | **`1.15x` faster** | **`57.5%` dir / `87.2%` cum** |
128
- | **Open 6 Tabs** (`tabs_batch` `open_many`, `60 ms` TTFB) | `6` turns sequential (`998 ms`) | **`1` turn** batched (`420 ms`) | **`2.38x` faster** (`6 -> 1` turns) | Eliminates `5` turns |
129
- | **Heavy Media Load** (`8x32 KiB` imgs + `48 KiB` font) | `252 ms`, `9` media hits (`304 KiB`) | **`165 ms`**, `0` media hits (`0 KiB`) | **`1.53x` faster** | **`100%` media saved** |
208
+ | 10-Field Complex Form + Verify (`smart_fill_form`) | `11` turns, `574 ms`, `12,197` direct / `72,614` cum tok | `1` turn, `82 ms`, `811` tok (`filled=10`) | `7x` faster | `93.4%` dir / `98.9%` cum |
209
+ | 48 KiB PDF Upload (`49,152` bytes via `file`) | `65,679` chars (`44,728` tok) Base64 payload | `263` chars (`85` tok) disk path (`68 ms`) | Zero LLM Base64 encode | `99.8%` |
210
+ | 6-Step UI Flow (`batch_actions`) | `6` turns, `411 ms`, `955` dir / `3,162` cum tok | `1` turn, `357 ms`, `406` tok | `1.15x` faster | `57.5%` dir / `87.2%` cum |
211
+ | Open 6 Tabs (`tabs_batch` `open_many`, `60 ms` TTFB) | `6` turns sequential (`998 ms`) | `1` turn batched (`420 ms`) | `2.38x` faster (`6 -> 1` turns) | Eliminates `5` turns |
212
+ | Heavy Media Load (`8x32 KiB` imgs + `48 KiB` font) | `252 ms`, `9` media hits (`304 KiB`) | `165 ms`, `0` media hits (`0 KiB`) | `1.53x` faster | `100%` media saved |
130
213
 
131
- ### 3. Static MCP Tool Definition Footprint
214
+ ### Tool schema size (sent to the model on every turn)
132
215
 
133
216
  Measured against installed MCP JSON schemas on disk (compact parameter schemas without `annotations`):
134
217
 
135
218
  | MCP Server | Tool Count | Compact Schema Chars | Exact `o200k_base` Tokens | Savings with `turbo-browser-mcp` |
136
219
  | :--- | :--- | :--- | :--- | :--- |
137
- | `turbo-browser-mcp` | **`11`** (`15,144` full / `13,631` compact) | **`13,631`** | **`3,170`** (`3,541` full w/ annotations) | Baseline (`11` tools) |
138
- | `@playwright/mcp` | `25` | `18,457` | `3,917` | **`19.1%` fewer static tokens** |
139
- | `chrome-devtools-mcp` | `33` | `30,252` | `6,737` | **`52.9%` fewer static tokens** |
220
+ | `turbo-browser-mcp` | `11` (`15,144` full / `13,631` compact) | `13,631` | `3,170` (`3,541` full w/ annotations) | Baseline (`11` tools) |
221
+ | `@playwright/mcp` | `25` | `18,457` | `3,917` | `19.1%` fewer static tokens |
222
+ | `chrome-devtools-mcp` | `33` | `30,252` | `6,737` | `52.9%` fewer static tokens |
140
223
 
141
224
  v0.5.0 added `wait_for_human` and the commit-safety parameters for about 160 tokens per turn (v0.4.0: `3,010` compact). To keep that small, `expect` / `submissionKey` / `allowDuplicate` are declared only on `batch_actions` (a one-step batch works for a single click), and the network guard is switched on by environment variable, so it costs no schema tokens. The label lists for other languages run inside the page and are never sent to the model.
142
225
 
143
- ---
226
+ ### Scripted end-to-end task (`npm run benchmark:e2e`)
227
+
228
+ [`benchmarks/E2E_COMPARISON.md`](benchmarks/E2E_COMPARISON.md) runs a fixed script against a Korean-language contest wizard (6 fields, a `다음` step, a `확인` inside a modal, a receipt page). One action per call with a full ARIA snapshot after each takes 9 calls and 32,942 cumulative context tokens. `inspect_compact` plus one `batch_actions` call with `expect` takes 2 calls and 1,430 tokens, and confirms the receipt number itself. The same file covers the commit-safety cases.
144
229
 
145
- ## Comparison vs `@playwright/mcp` and `chrome-devtools-mcp`
230
+ ### Agent benchmark against other browser stacks (in progress)
231
+
232
+ [`benchmarks/e2e-agent/`](benchmarks/e2e-agent/) gives a coding agent three tasks on local fixture sites (a job application with a file upload, a catalog search, a booking with a confirmation step) and runs it with each stack: turbo-browser-mcp, agent-browser, browse and browser-use. A separate script checks each result on the server side, and the runner records model tokens and wall time. The plan and success checks are in [`benchmarks/E2E_PLAN.md`](benchmarks/E2E_PLAN.md). Results will be added here once every stack has finished all three tasks. Until then, the numbers above say nothing about how this server compares with those tools in a full agent run.
233
+
234
+ ## Comparison with `@playwright/mcp` and `chrome-devtools-mcp`
146
235
 
147
236
  | Feature | `turbo-browser-mcp` | `@playwright/mcp` | `chrome-devtools-mcp` |
148
237
  | :--- | :--- | :--- | :--- |
149
- | **Tool Surface Size** | **10 batched tools** | 25 granular tools | 33 granular tools |
150
- | **Delta Snapshots (`onlyChanged`)** | Built-in | Full tree every snapshot | Full tree every snapshot |
151
- | **Closed Shadow DOM Hook** | Post-init `attachShadow` hook + `<slot>` flattening | Open Shadow DOM | CDP / standard DOM access |
152
- | **Single-Call Smart Form + Contenteditable** | Yes (React, Shadow DOM, iframe, Gmail, ranges) | Multi-turn fill + separate select calls | Basic `fill_form` |
153
- | **Disk File Upload (Zero Base64)** | Native `file`/`files` path in `smart_fill_form` & `act_fast` | Dedicated `browser_file_upload` turn | Dedicated `upload_file` turn |
154
- | **Default Human-in-the-Loop Submit Guard** | Yes (`allowSubmit=false`, form/iframe/Enter hooks) | No | No |
155
- | **Parallel `open_many` + `isolatedContext`** | Single batched call | Separate sequential tab calls | Separate page calls |
156
- | **One-Call `turbo` Media Blocker** | Built-in (`turbo`, `no-images`, `no-media`) | Manual JS / routing | Network emulation |
157
- | **Performance / Heap Profiling** | Not included | Not included | **Trace, Lighthouse, Heap Snapshot** |
238
+ | Number of tools | 11 | 25 granular tools | 33 granular tools |
239
+ | Delta Snapshots (`onlyChanged`) | Built-in | Full tree every snapshot | Full tree every snapshot |
240
+ | Closed Shadow DOM Hook | Post-init `attachShadow` hook + `<slot>` flattening | Open Shadow DOM | CDP / standard DOM access |
241
+ | Single-Call Smart Form + Contenteditable | Yes (React, Shadow DOM, iframe, Gmail, ranges) | Multi-turn fill + separate select calls | Basic `fill_form` |
242
+ | Disk File Upload (Zero Base64) | Native `file`/`files` path in `smart_fill_form` & `act_fast` | Dedicated `browser_file_upload` turn | Dedicated `upload_file` turn |
243
+ | Default Human-in-the-Loop Submit Guard | Yes (`allowSubmit=false`, form/iframe/Enter hooks) | No | No |
244
+ | Parallel `open_many` + `isolatedContext` | Single batched call | Separate sequential tab calls | Separate page calls |
245
+ | One-Call `turbo` Media Blocker | Built-in (`turbo`, `no-images`, `no-media`) | Manual JS / routing | Network emulation |
246
+ | Performance / Heap Profiling | Not included | Not included | Trace, Lighthouse, Heap Snapshot |
158
247
 
159
- > **When to keep Chrome DevTools MCP alongside `turbo-browser-mcp`:** `chrome-devtools-mcp` provides Lighthouse audits, performance trace analysis, CSS computed style panels, and V8 heap snapshots. `turbo-browser-mcp` focuses on fast multi-step UI automation, forms, and scraping with minimal token overhead.
248
+ > When to keep Chrome DevTools MCP alongside `turbo-browser-mcp`: `chrome-devtools-mcp` provides Lighthouse audits, performance trace analysis, CSS computed style panels, and V8 heap snapshots. `turbo-browser-mcp` focuses on fast multi-step UI automation, forms, and scraping with minimal token overhead.
160
249
 
161
- ### Tool Parity Map
250
+ ### Tool mapping
162
251
 
163
252
  | Capability | `turbo-browser-mcp` | `@playwright/mcp` | `chrome-devtools-mcp` |
164
253
  | :--- | :--- | :--- | :--- |
@@ -173,25 +262,25 @@ v0.5.0 added `wait_for_human` and the commit-safety parameters for about 160 tok
173
262
  | Screenshots & PDF export | `capture_page` | `browser_take_screenshot` | `take_screenshot` |
174
263
  | Blocking presets, cookies & storage | `network_session` | `browser_evaluate` + context config | Partial via `evaluate_script` / `emulate` |
175
264
 
176
- ---
265
+ ## Safety
177
266
 
178
- ## Safety: Human-in-the-Loop Submit Guard & Path Confinement
267
+ ### Submit guard and file path limits
179
268
 
180
- 1. **Human-in-the-loop Submit Guard (`allowSubmit=false` by default):**
269
+ 1. Human-in-the-loop Submit Guard (`allowSubmit=false` by default):
181
270
  - `smart_fill_form` (`stopBeforeSubmit: true`), `act_fast`, and `batch_actions` inspect matching elements, W3C AccName labels (`isSafeSubmitter`), implicit HTML form Enter submissions, key chords (`Shift+Enter`, `Enter+Shift`), `HTMLFormElement.prototype.submit`/`requestSubmit`, and same-origin iframe `contentWindow`/`contentDocument` proxies.
182
271
  - Final actions resembling `Submit`, `Publish`, `Send`, `Post`, `Apply`, `Confirm`, or payment triggers are blocked unless `allowSubmit: true` is explicitly passed or `--allow-submit` is enabled at startup.
183
272
  - Trade-off: pre-existing closed Shadow roots on already-open CDP tabs (attached before the init script ran) or strict cross-origin sandboxed frames fall back to Playwright frame handles, coordinate actions, and keyboard input.
184
- 2. **Workspace Path Confinement (`TURBO_BROWSER_SAVE_ROOT`):**
273
+ 2. Workspace Path Confinement (`TURBO_BROWSER_SAVE_ROOT`):
185
274
  - File outputs (`savePath`, `saveStorageStatePath`) and state inputs (`loadStorageStatePath`) are strictly confined to the current working directory or `TURBO_BROWSER_SAVE_ROOT`.
186
275
  - Lexical checks, `lstatSync`/`readlinkSync` symlink verification, and `realpathSync` validation block `..` traversal, UNC network paths, dangling symlinks, cyclic symlinks, and Windows junctions before reading or writing.
187
276
 
188
- ### Commit safety added in v0.5.0 (from Show HN and dev.to feedback)
277
+ ### Commit checks: `expect`, `submissionKey`, modal and network guards
189
278
 
190
279
  Readers who run agents on real portals pointed out three gaps in a label-based guard. v0.5.0 adds an opt-in answer to each. `expect`, `submissionKey` and `allowDuplicate` appear in the `batch_actions` schema; `act_fast` accepts the same arguments without advertising them. The network guard is turned on with `TURBO_BROWSER_NETWORK_GUARD=true` and covers `act_fast`, `batch_actions` and `smart_fill_form`.
191
280
 
192
- 1. **A landed click is not a confirmed submission → `expect`.** After an allowed submit, pass `expect: { urlMatches?, textMatches?, selector?, timeoutMs? }`. The result carries `submitVerified` and `evidence` (the new URL, a text snippet such as a receipt number, or the matched selector). If nothing shows up in time you get `submitVerified: false` and a reason, so the agent does not report "done" on an empty submission list.
193
- 2. **A re-run is a second entry, not a retry → `submissionKey`.** With `submissionKey: "portal:2026-11-15:entry-42"`, every allowed submit is appended to a JSONL ledger (`~/.turbo-browser-mcp/submissions.jsonl`, or `TURBO_BROWSER_LEDGER`, or `ledgerPath` inside the save root). A later call with the same key is refused with `blockedBy: "ledger"` unless `allowDuplicate: true`.
194
- 3. **Labels lie → modal rule + `networkGuard`.** On many Korean portals the last step reads 다음 and the real commit is a 확인 inside a modal that opens afterwards.
281
+ 1. A landed click is not a confirmed submission → `expect`. After an allowed submit, pass `expect: { urlMatches?, textMatches?, selector?, timeoutMs? }`. The result carries `submitVerified` and `evidence` (the new URL, a text snippet such as a receipt number, or the matched selector). If nothing shows up in time you get `submitVerified: false` and a reason, so the agent does not report "done" on an empty submission list.
282
+ 2. A re-run is a second entry, not a retry → `submissionKey`. With `submissionKey: "portal:2026-11-15:entry-42"`, every allowed submit is appended to a JSONL ledger (`~/.turbo-browser-mcp/submissions.jsonl`, or `TURBO_BROWSER_LEDGER`, or `ledgerPath` inside the save root). A later call with the same key is refused with `blockedBy: "ledger"` unless `allowDuplicate: true`.
283
+ 3. Labels lie → modal rule + `networkGuard`. On many Korean portals the last step reads 다음 and the real commit is a 확인 inside a modal that opens afterwards.
195
284
  - Affirmative buttons (`확인`, `OK`, `Yes`, `Confirm`, `確認`, `确定`, `Đồng ý`, …) inside `dialog` / `[role=dialog]` / `[role=alertdialog]` / `[aria-modal=true]` now count as commits (`blockedBy: "modal"`). Cookie banners (dialog text mentions cookies) and date/time pickers (dialog contains a calendar grid or date input) are excluded; a confirmation that only mentions "privacy" or "consent" is still blocked.
196
285
  - When an action makes the page call `form.submit()` / `requestSubmit()` or fire a `submit` event and the guard stops it, the result now says so (`submitSuppressed`, `note`) instead of a bare `ok: true`. The action itself (a select, a check) still counts as done, so batches continue.
197
286
  - Common Korean, Japanese, Chinese and Vietnamese submit labels were added (`제출`, `신청`, `등록`, `결제`, `送信`, `確定`, `提交`, `Hoàn tất`, …), and `다음`, `次へ`, `下一步` are treated like `Next`.
@@ -203,12 +292,12 @@ Limits:
203
292
  - The ledger is written only when the call returns. If the call throws after the page already sent the submission (for example a navigation timeout), nothing is recorded; check the site before re-running.
204
293
  - `expect.selector` that is not a valid selector never matches, so the call reports `submitVerified: false` after the timeout.
205
294
 
206
- ### Human-first sessions (`wait_for_human`, `--open-profile`)
295
+ ### Handing a step to a person (`wait_for_human`, `--open-profile`)
207
296
 
208
- Some sites fail their bot check whenever the browser is remote-controlled, so a person has to open the same profile in a normal browser first. turbo-browser-mcp does **not** try to hide automation: no stealth plugins, no fingerprint or `navigator.webdriver` patching, no CAPTCHA solving. It supports two hand-off flows instead.
297
+ Some sites fail their bot check whenever the browser is remote-controlled, so a person has to open the same profile in a normal browser first. turbo-browser-mcp does not try to hide automation: no stealth plugins, no fingerprint or `navigator.webdriver` patching, no CAPTCHA solving. It supports two hand-off flows instead.
209
298
 
210
- 1. **Before the session:** `turbo-browser-mcp --open-profile --url https://site.example/login` opens plain Chrome (no debugging port, no automation flags) on the dedicated profile `~/.turbo-browser-mcp/chrome-profile` (or `--user-data-dir`). The human logs in or passes the check and closes the window. Then start the server with `--user-data-dir <same path>` or `--launch-chrome`, and the agent reuses those cookies. This works for sites that check at login; a site that re-checks on every request will still see an automated browser.
211
- 2. **During the session:** the agent calls `wait_for_human` with a message and a condition (`urlMatches`, `selector`, `textMatches` or `textGone`). The tool brings the tab to the front and polls until the condition holds, then the agent continues in the same tab with the same cookies. Keep `timeoutMs` below your MCP client's request timeout and call it again to keep waiting.
299
+ 1. Before the session: `turbo-browser-mcp --open-profile --url https://site.example/login` opens plain Chrome (no debugging port, no automation flags) on the dedicated profile `~/.turbo-browser-mcp/chrome-profile` (or `--user-data-dir`). The human logs in or passes the check and closes the window. Then start the server with `--user-data-dir <same path>` or `--launch-chrome`, and the agent reuses those cookies. This works for sites that check at login; a site that re-checks on every request will still see an automated browser.
300
+ 2. During the session: the agent calls `wait_for_human` with a message and a condition (`urlMatches`, `selector`, `textMatches` or `textGone`). The tool brings the tab to the front and polls until the condition holds, then the agent continues in the same tab with the same cookies. Keep `timeoutMs` below your MCP client's request timeout and call it again to keep waiting.
212
301
 
213
302
  ```json
214
303
  {
@@ -221,136 +310,23 @@ Some sites fail their bot check whenever the browser is remote-controlled, so a
221
310
  }
222
311
  ```
223
312
 
224
- ---
225
-
226
- ## All 11 Tools Reference
227
-
228
- | Tool | Purpose | Key Parameters |
229
- | :--- | :--- | :--- |
230
- | `tabs_batch` | Ordered tab & browser lifecycle | `operations[]` (`list`, `open`, `open_many`, `navigate`, `activate`, `resize`, `emulate`, `reload`, `back`, `forward`, `close`, `close_browser`), `isolatedContext`, `concurrency` (1-10) |
231
- | `inspect_compact` | Token-capped element/form/article snapshot | `mode` (`interactive`, `forms`, `article`, `all`), `onlyChanged`, `query`, `boxes`, `maxChars`, `includeFrames`, `savePath` |
232
- | `smart_fill_form` | Batch form, editor & disk file prefill | `fields[]` (`ref`, `selector`, `value`, `option`, `values`, `check`, `not`, `keys`, `file`, `files`, `frameIdx`, `all`), `gmail`, `overwrite`, `stopBeforeSubmit`, `returnSnapshot` |
233
- | `act_fast` | Single targeted page action | `action` (`16` actions), `ref`/`selector`/`text`/`label`/`(x, y)`, `modifiers`, `dropData`, `allowSubmit`, `returnSnapshot` |
234
- | `batch_actions` | Ordered chain of actions + form steps | `steps[]`, `continueOnError`, `allowSubmit`, `expect`, `submissionKey`, `allowDuplicate`, `returnSnapshot`, `snapshotMaxChars` |
235
- | `extract_clean_text` | Clean text or compact Markdown reader | `format` (`text`, `markdown`), `selector`, `includeFrames`, `maxChars`, `savePath` |
236
- | `evaluate_js` | Scoped JS expression or `(el, arg)` call | `expression`, `arg`, `frameIdx`, `ref`/`selector`/`text`, `savePath` |
237
- | `page_diagnostics` | Console, network, downloads & dialogs | `level` (`errors`, `all`), `statusFilter` (`errors`, `all`), `includeStatic`, `urlFilter`, `reqId`, `part`, `dialogPolicy`, `clear`, `savePath` |
238
- | `capture_page` | PNG/JPEG screenshots & PDF export | `mode` (`screenshot`, `pdf`), `type`, `quality`, `fullPage`, `scale` (`css`, `device`), `ref`/`selector`/`text`, `returnImage`, `savePath` |
239
- | `network_session` | Resource blockers, cookies & storage | `preset` (`turbo`, `no-images`, `no-media`, `clean`), `blockResources`, `blockUrls`, `cookieAction`, `storageAction`, `loadStorageStatePath`, `saveStorageStatePath` |
240
- | `wait_for_human` | Hand a step to a person, resume in the same session | `message`, `urlMatches`, `selector`, `textMatches`, `textGone`, `timeoutMs`, `pollMs` |
241
-
242
- #### Submit with proof and an idempotency key
243
- ```json
244
- {
245
- "name": "batch_actions",
246
- "arguments": {
247
- "steps": [
248
- { "action": "smart_fill_form", "fields": [{ "selector": "#name", "value": "홍길동" }] },
249
- { "action": "click", "text": "다음" },
250
- { "action": "click", "text": "확인" }
251
- ],
252
- "allowSubmit": true,
253
- "expect": { "textMatches": "접수번호\\s*R-\\d+", "timeoutMs": 8000 },
254
- "submissionKey": "photo-contest:2026-11-15:entry-1"
255
- }
256
- }
257
- ```
258
-
259
- ### Copy-Paste JSON Examples
260
-
261
- #### 1. Fill a 10-field form with a disk PDF & inspect result in 1 turn
262
- ```json
263
- {
264
- "name": "smart_fill_form",
265
- "arguments": {
266
- "fields": [
267
- { "selector": "#full_name", "value": "Alex Nguyen" },
268
- { "selector": "#email", "value": "alex@example.com" },
269
- { "selector": "#country", "option": "United States" },
270
- { "selector": "#skills", "values": ["TypeScript", "Playwright"] },
271
- { "selector": "#agree_terms", "check": true },
272
- { "selector": "#resume_pdf", "file": "./assets/resume.pdf" }
273
- ],
274
- "stopBeforeSubmit": true,
275
- "returnSnapshot": true
276
- }
277
- }
278
- ```
279
-
280
- #### 2. Read only changed controls after opening a modal (`onlyChanged`)
281
- ```json
282
- {
283
- "name": "inspect_compact",
284
- "arguments": {
285
- "mode": "interactive",
286
- "onlyChanged": true,
287
- "maxChars": 3000
288
- }
289
- }
290
- ```
291
-
292
- #### 3. Open tabs concurrently in isolated contexts & speed up loading with `turbo`
293
- ```json
294
- {
295
- "name": "tabs_batch",
296
- "arguments": {
297
- "operations": [
298
- { "action": "open", "url": "https://example.com/app", "isolatedContext": "acct-a" },
299
- { "action": "open_many", "urls": ["https://example.com/docs", "https://example.com/pricing"], "concurrency": 4 }
300
- ]
301
- }
302
- }
303
- ```
304
-
305
- ---
306
-
307
- ## Quick Start
308
-
309
- ### Install & Check Environment
310
- ```bash
311
- git clone https://github.com/Tthanh2k6/turbo-browser-mcp.git
312
- cd turbo-browser-mcp
313
- npm install
314
- npm run doctor
315
- ```
316
-
317
- If you need Playwright's bundled Chromium (or have no system Chrome/Edge/Brave installed):
318
- ```bash
319
- npx playwright-core install chromium
320
- ```
321
-
322
- ### MCP Client Config (Claude Code, Cursor, Antigravity, Codex)
323
-
324
- Using local clone:
325
- ```json
326
- {
327
- "mcpServers": {
328
- "turbo-browser": {
329
- "command": "node",
330
- "args": ["/absolute/path/to/turbo-browser-mcp/src/index.mjs"],
331
- "env": {
332
- "TURBO_BROWSER_SAVE_ROOT": "/absolute/path/to/allowed/workspace"
333
- }
334
- }
335
- }
336
- }
337
- ```
313
+ ## Click aftermath reporting
338
314
 
339
- Using `npx` / binary entrypoint:
340
- ```json
341
- {
342
- "mcpServers": {
343
- "turbo-browser": {
344
- "command": "npx",
345
- "args": ["-y", "turbo-browser-mcp"]
346
- }
347
- }
348
- }
349
- ```
315
+ Set `observeAftermath: true` on `act_fast` or `batch_actions` (or set
316
+ `TURBO_BROWSER_OBSERVE_AFTERMATH=true`) to observe navigation and mutating
317
+ fetch/XHR requests for one second after each click. It is off by default.
318
+ The result includes `aftermath: { beforeUrl, afterUrl, navigated,
319
+ mutatingRequests, unexpectedSubmit }`. Requests include their method, URL,
320
+ and a `finalSubmit` classification. Main-frame origin/path changes or
321
+ commit-like requests produce a warning when `allowSubmit` is false.
350
322
 
351
- ---
323
+ This reports an action that has already occurred. It cannot prevent a commit
324
+ or prove that a submission succeeded. Wizard navigation can trigger a warning,
325
+ and opaque endpoints or requests outside the observation window can be missed.
326
+ Use the network guard for prevention and `expect` for receipt verification.
327
+ See [fixture and classification details](test/COMMUNITY_FIXTURES.md).
352
328
 
353
- ## CLI Options & Environment Variables
329
+ ## CLI options and environment variables
354
330
 
355
331
  | CLI Flag | Environment Variable | Default | Description |
356
332
  | :--- | :--- | :--- | :--- |
@@ -367,70 +343,44 @@ Using `npx` / binary entrypoint:
367
343
  | `--open-profile [--url <u>]` | `TURBO_BROWSER_OPEN_URL` | `~/.turbo-browser-mcp/chrome-profile` | Open the profile in a normal, non-automated Chrome so a human can log in or pass a check first |
368
344
  | - | `TURBO_BROWSER_NETWORK_GUARD` | `false` | Turn on the network commit guard by default |
369
345
  | - | `TURBO_BROWSER_NETWORK_GUARD_ALLOW` | `""` | Comma-separated URL regexes the network guard lets through |
346
+ | - | `TURBO_BROWSER_OBSERVE_AFTERMATH` | `false` | Report navigation and mutating requests after each click (see [Click aftermath](#click-aftermath-reporting)) |
370
347
  | - | `TURBO_BROWSER_LEDGER` | `~/.turbo-browser-mcp/submissions.jsonl` | Submission ledger used by `submissionKey` |
371
- | `--version` / `-v` | - | - | Print server version (`0.5.0`) |
348
+ | `--version` / `-v` | - | - | Print server version |
372
349
  | `--help` / `-h` | - | - | Print CLI usage summary |
373
350
  | - | `TURBO_BROWSER_SAVE_ROOT` | `process.cwd()` | Root directory confining `savePath` and `storageState` files |
374
351
  | - | `PLAYWRIGHT_CORE_PATH` | auto-resolved | Explicit path to `playwright-core/index.mjs` |
375
352
 
376
- ### Unattended Overnight / AFK Automation (Eliminating Chrome 144+ Approval Prompts)
377
-
378
- In Chrome 136+/144+, enabling `chrome://inspect/#remote-debugging` on the default `User Data` directory exposes a WebSocket in `DevToolsActivePort` that displays an **"Allow remote debugging?"** prompt whenever a new WebSocket client connects. `turbo-browser-mcp` provides two built-in solutions so overnight AFK multi-agent runs never hang on a prompt:
353
+ ### Unattended runs and the Chrome 144+ remote-debugging prompt
379
354
 
380
- 1. **Automatic CDP Keep-Alive Bridge Daemon (`npm run bridge` / `--bridge`, enabled automatically on `DevToolsActivePort`)**:
381
- - Spawns a detached background multiplexer (`src/cdp-bridge.mjs` on `http://127.0.0.1:9224`) that holds **one persistent upstream WebSocket** to Chrome open indefinitely and intercepts `Browser.close` so downstream scripts never terminate your browser.
382
- - You click **Allow** once when starting your session; afterwards, any number of MCP servers, CLI scripts, or subagents can connect and disconnect all night with **0 additional prompts**.
383
- 2. **Zero-Prompt Dedicated Profile Launcher (`npm run launch-chrome` / `--launch-chrome`)**:
384
- - Launches Chrome with `--remote-debugging-port=9222` and a dedicated `--user-data-dir` (`~/.turbo-browser-mcp/chrome-profile`), where Chrome exposes standard HTTP/WS CDP with **0 confirmation dialogs even on the very first connection**.
355
+ In Chrome 136+/144+, enabling `chrome://inspect/#remote-debugging` on the default `User Data` directory exposes a WebSocket in `DevToolsActivePort` that displays an "Allow remote debugging?" prompt whenever a new WebSocket client connects. `turbo-browser-mcp` provides two built-in solutions so overnight AFK multi-agent runs never hang on a prompt:
385
356
 
386
- ---
357
+ 1. Automatic CDP Keep-Alive Bridge Daemon (`npm run bridge` / `--bridge`, enabled automatically on `DevToolsActivePort`):
358
+ - Spawns a detached background multiplexer (`src/cdp-bridge.mjs` on `http://127.0.0.1:9224`) that holds one persistent upstream WebSocket to Chrome open indefinitely and intercepts `Browser.close` so downstream scripts never terminate your browser.
359
+ - You click Allow once when starting your session; afterwards, any number of MCP servers, CLI scripts, or subagents can connect and disconnect all night with 0 additional prompts.
360
+ 2. Zero-Prompt Dedicated Profile Launcher (`npm run launch-chrome` / `--launch-chrome`):
361
+ - Launches Chrome with `--remote-debugging-port=9222` and a dedicated `--user-data-dir` (`~/.turbo-browser-mcp/chrome-profile`), where Chrome exposes standard HTTP/WS CDP with 0 confirmation dialogs even on the very first connection.
387
362
 
388
- ## Verification
363
+ ## Development
389
364
 
390
365
  ```bash
391
- npm test # 437 tests across 87 suites (29 test files under test/*.test.mjs)
392
- npm run doctor # Environment check for Node, Playwright, Chromium, and CDP
393
- npm run bridge # Start/verify persistent CDP Keep-Alive Bridge daemon
394
- npm run benchmark # Local Chromium speed & exact o200k_base token benchmark
395
- npm run benchmark:e2e # End-to-end wizard task + commit-safety cases (see benchmarks/E2E_COMPARISON.md)
366
+ npm test # 437 tests in 87 suites (test/*.test.mjs)
367
+ npm run doctor # Node, Playwright, Chromium and CDP check
368
+ npm run benchmark # per-tool token and timing benchmark
369
+ npm run benchmark:e2e # scripted wizard task and commit-safety cases
396
370
  ```
397
371
 
398
- Tested automatically on GitHub Actions (`ubuntu-latest`) across **Node 20** and **Node 22**.
372
+ CI runs the tests on Ubuntu with Node 20 and 22.
399
373
 
400
- ## Click aftermath reporting
374
+ ## Known limits
401
375
 
402
- Set `observeAftermath: true` on `act_fast` or `batch_actions` (or set
403
- `TURBO_BROWSER_OBSERVE_AFTERMATH=true`) to observe navigation and mutating
404
- fetch/XHR requests for one second after each click. It is off by default.
405
- The result includes `aftermath: { beforeUrl, afterUrl, navigated,
406
- mutatingRequests, unexpectedSubmit }`. Requests include their method, URL,
407
- and a `finalSubmit` classification. Main-frame origin/path changes or
408
- commit-like requests produce a warning when `allowSubmit` is false.
376
+ - Portaled comboboxes (react-select, Radix, Headless UI style) have a click path and a keyboard fallback that searches up to 100 options and checks the committed value. Virtualized lists beyond the included fixtures still need testing against real apps.
377
+ - Sites with bot detection may need `wait_for_human` and a person to pass the check in the same browser. The server does not bypass those checks.
378
+ - The network guard and click aftermath only watch a short window after each action, and do not inspect WebSocket messages or service-worker requests. Details are under [commit checks](#commit-checks-expect-submissionkey-modal-and-network-guards).
379
+ - Closed Shadow roots that existed before the server attached to a tab cannot be reached through the hook. Actions there fall back to frame handles, coordinates and keyboard input.
409
380
 
410
- This reports an action that has already occurred. It cannot prevent a commit
411
- or prove that a submission succeeded. Wizard navigation can trigger a warning,
412
- and opaque endpoints or requests outside the observation window can be missed.
413
- Use the network guard for prevention and `expect` for receipt verification.
414
- See [fixture and classification details](test/COMMUNITY_FIXTURES.md).
381
+ ## Credits
415
382
 
416
- ## Known limits / roadmap
417
-
418
- - Portaled comboboxes have click and keyboard paths. The keyboard fallback
419
- searches up to 100 active options and checks the committed value. Virtualized
420
- selects beyond the included behavioral fixtures still need broader testing
421
- against real react-select, Radix, and Headless UI applications.
422
- - Sites with bot detection may require `wait_for_human` and a human to complete
423
- the check in the same browser session. Automation does not bypass those checks.
424
- - End-to-end comparisons with other browser stacks are pending. The
425
- [comparison plan](benchmarks/E2E_PLAN.md) defines three tasks, success checks,
426
- and model-token, turn, and wall-time measurements. Existing local benchmarks
427
- do not establish comparative agent performance.
428
-
429
- Community suggestions: johnnylemonny and alexcodebytes on portaled and
430
- virtualized selects; eye_java_420f1faa10ae8b86 on keyboard selection and submit
431
- aftermath; amintacccp on safe submit labels; snake_doc and lukevp on end-to-end
432
- comparison and abstraction levels; vidarh on human handoff; harrysong138759
433
- on receipt verification and duplicate submissions.
383
+ Several features came from readers of the Show HN post and the dev.to article: johnnylemonny and alexcodebytes (portaled and virtualized selects), eye_java_420f1faa10ae8b86 (keyboard selection and click aftermath), amintacccp (safe submit labels), snake_doc and lukevp (end-to-end comparison, level of abstraction), vidarh (human hand-off), harrysong138759 (receipt verification and duplicate submissions).
434
384
 
435
385
  ## License
436
386