@pyrokine/mcp-chrome 3.0.1 → 3.1.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 (144) hide show
  1. package/README.md +678 -341
  2. package/README_zh.md +694 -291
  3. package/dist/cdp/client.d.ts +7 -3
  4. package/dist/cdp/client.d.ts.map +1 -1
  5. package/dist/cdp/client.js +252 -63
  6. package/dist/cdp/client.js.map +1 -1
  7. package/dist/cdp/launcher.d.ts +1 -1
  8. package/dist/cdp/launcher.d.ts.map +1 -1
  9. package/dist/cdp/launcher.js +33 -12
  10. package/dist/cdp/launcher.js.map +1 -1
  11. package/dist/core/auto-wait.d.ts.map +1 -1
  12. package/dist/core/auto-wait.js +88 -52
  13. package/dist/core/auto-wait.js.map +1 -1
  14. package/dist/core/browser-driver.d.ts +72 -15
  15. package/dist/core/browser-driver.d.ts.map +1 -1
  16. package/dist/core/browser-driver.js.map +1 -1
  17. package/dist/core/browser-event-schema.d.ts +287 -0
  18. package/dist/core/browser-event-schema.d.ts.map +1 -0
  19. package/dist/core/browser-event-schema.js +104 -0
  20. package/dist/core/browser-event-schema.js.map +1 -0
  21. package/dist/core/browser-events.d.ts +99 -0
  22. package/dist/core/browser-events.d.ts.map +1 -0
  23. package/dist/core/browser-events.js +1312 -0
  24. package/dist/core/browser-events.js.map +1 -0
  25. package/dist/core/challenge-page.d.ts +39 -0
  26. package/dist/core/challenge-page.d.ts.map +1 -0
  27. package/dist/core/challenge-page.js +226 -0
  28. package/dist/core/challenge-page.js.map +1 -0
  29. package/dist/core/dom-helpers.d.ts +28 -0
  30. package/dist/core/dom-helpers.d.ts.map +1 -0
  31. package/dist/core/dom-helpers.js +311 -0
  32. package/dist/core/dom-helpers.js.map +1 -0
  33. package/dist/core/errors.d.ts +4 -0
  34. package/dist/core/errors.d.ts.map +1 -1
  35. package/dist/core/errors.js +51 -7
  36. package/dist/core/errors.js.map +1 -1
  37. package/dist/core/file-upload.d.ts +22 -0
  38. package/dist/core/file-upload.d.ts.map +1 -0
  39. package/dist/core/file-upload.js +194 -0
  40. package/dist/core/file-upload.js.map +1 -0
  41. package/dist/core/locator.d.ts +10 -2
  42. package/dist/core/locator.d.ts.map +1 -1
  43. package/dist/core/locator.js +121 -200
  44. package/dist/core/locator.js.map +1 -1
  45. package/dist/core/os-mouse.d.ts +11 -0
  46. package/dist/core/os-mouse.d.ts.map +1 -1
  47. package/dist/core/os-mouse.js +102 -29
  48. package/dist/core/os-mouse.js.map +1 -1
  49. package/dist/core/retry.d.ts.map +1 -1
  50. package/dist/core/retry.js +4 -1
  51. package/dist/core/retry.js.map +1 -1
  52. package/dist/core/session.d.ts +61 -12
  53. package/dist/core/session.d.ts.map +1 -1
  54. package/dist/core/session.js +1040 -259
  55. package/dist/core/session.js.map +1 -1
  56. package/dist/core/types.d.ts +5 -1
  57. package/dist/core/types.d.ts.map +1 -1
  58. package/dist/core/types.js +16 -1
  59. package/dist/core/types.js.map +1 -1
  60. package/dist/core/unified-session.d.ts +41 -35
  61. package/dist/core/unified-session.d.ts.map +1 -1
  62. package/dist/core/unified-session.js +872 -263
  63. package/dist/core/unified-session.js.map +1 -1
  64. package/dist/core/utils.d.ts +5 -4
  65. package/dist/core/utils.d.ts.map +1 -1
  66. package/dist/core/utils.js +73 -18
  67. package/dist/core/utils.js.map +1 -1
  68. package/dist/extension/bridge.d.ts +48 -17
  69. package/dist/extension/bridge.d.ts.map +1 -1
  70. package/dist/extension/bridge.js +239 -37
  71. package/dist/extension/bridge.js.map +1 -1
  72. package/dist/extension/http-server.d.ts +7 -2
  73. package/dist/extension/http-server.d.ts.map +1 -1
  74. package/dist/extension/http-server.js +211 -49
  75. package/dist/extension/http-server.js.map +1 -1
  76. package/dist/index.js +14 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/tools/browse.d.ts.map +1 -1
  79. package/dist/tools/browse.js +56 -28
  80. package/dist/tools/browse.js.map +1 -1
  81. package/dist/tools/browser-event-output.d.ts +7 -0
  82. package/dist/tools/browser-event-output.d.ts.map +1 -0
  83. package/dist/tools/browser-event-output.js +19 -0
  84. package/dist/tools/browser-event-output.js.map +1 -0
  85. package/dist/tools/challenge.d.ts +17 -5
  86. package/dist/tools/challenge.d.ts.map +1 -1
  87. package/dist/tools/challenge.js +110 -189
  88. package/dist/tools/challenge.js.map +1 -1
  89. package/dist/tools/cookies.d.ts.map +1 -1
  90. package/dist/tools/cookies.js +33 -8
  91. package/dist/tools/cookies.js.map +1 -1
  92. package/dist/tools/diagnostics.d.ts.map +1 -1
  93. package/dist/tools/diagnostics.js +14 -0
  94. package/dist/tools/diagnostics.js.map +1 -1
  95. package/dist/tools/evaluate.d.ts +6 -5
  96. package/dist/tools/evaluate.d.ts.map +1 -1
  97. package/dist/tools/evaluate.js +92 -52
  98. package/dist/tools/evaluate.js.map +1 -1
  99. package/dist/tools/extract.d.ts.map +1 -1
  100. package/dist/tools/extract.js +149 -103
  101. package/dist/tools/extract.js.map +1 -1
  102. package/dist/tools/input.d.ts.map +1 -1
  103. package/dist/tools/input.js +555 -229
  104. package/dist/tools/input.js.map +1 -1
  105. package/dist/tools/logs.d.ts.map +1 -1
  106. package/dist/tools/logs.js +50 -11
  107. package/dist/tools/logs.js.map +1 -1
  108. package/dist/tools/manage.d.ts.map +1 -1
  109. package/dist/tools/manage.js +111 -16
  110. package/dist/tools/manage.js.map +1 -1
  111. package/dist/tools/network-sanitizer.d.ts +1 -0
  112. package/dist/tools/network-sanitizer.d.ts.map +1 -1
  113. package/dist/tools/network-sanitizer.js +30 -1
  114. package/dist/tools/network-sanitizer.js.map +1 -1
  115. package/dist/tools/page-context.d.ts +4 -3
  116. package/dist/tools/page-context.d.ts.map +1 -1
  117. package/dist/tools/page-context.js +56 -14
  118. package/dist/tools/page-context.js.map +1 -1
  119. package/dist/tools/post-condition.d.ts +1 -1
  120. package/dist/tools/post-condition.d.ts.map +1 -1
  121. package/dist/tools/post-condition.js +136 -44
  122. package/dist/tools/post-condition.js.map +1 -1
  123. package/dist/tools/schema.d.ts +7 -4
  124. package/dist/tools/schema.d.ts.map +1 -1
  125. package/dist/tools/schema.js +32 -122
  126. package/dist/tools/schema.js.map +1 -1
  127. package/dist/tools/target-diagnostics.d.ts +3 -3
  128. package/dist/tools/target-diagnostics.d.ts.map +1 -1
  129. package/dist/tools/target-diagnostics.js +17 -7
  130. package/dist/tools/target-diagnostics.js.map +1 -1
  131. package/dist/tools/wait.d.ts.map +1 -1
  132. package/dist/tools/wait.js +94 -40
  133. package/dist/tools/wait.js.map +1 -1
  134. package/extension/dist/assets/{content.ts-qe6IB5DK.js → content.ts-BAMOcF3R.js} +1 -1
  135. package/extension/dist/assets/{content.ts-loader-DUWbDHRS.js → content.ts-loader-4F9a1EWZ.js} +1 -1
  136. package/extension/dist/assets/index.ts-B79g2ikq.js +19820 -0
  137. package/extension/dist/assets/{page-scripts-D508WLkW.js → page-scripts-CSxn58h1.js} +257 -366
  138. package/extension/dist/assets/{popup.html-B-eVq48O.js → popup.html-DwwHo00N.js} +2 -2
  139. package/extension/dist/manifest.json +4 -4
  140. package/extension/dist/service-worker-loader.js +1 -1
  141. package/extension/dist/src/popup/popup.html +3 -3
  142. package/package.json +8 -6
  143. package/scripts/start-chrome.ps1 +9 -1
  144. package/extension/dist/assets/index.ts-D7_LCUoV.js +0 -9319
package/README.md CHANGED
@@ -15,7 +15,8 @@ existing browser, **CDP mode** (fallback) launches a dedicated instance.
15
15
  - **8 Unified Tools**: Action-based design covering browse, input, extract, wait, evaluate, manage, cookies, logs
16
16
  - **Multi-Page Targeting**: `targetId` selects a page in either backend without changing browser focus; `tabId` remains
17
17
  an alias
18
- - **iframe Penetration**: `frame` parameter targets elements inside iframes (CSS selector or index, Extension mode)
18
+ - **Frames and Shadow DOM**: `frame` selects a child frame or a nested selector/index path in either backend;
19
+ CSS, text and semantic queries enter open shadow roots
19
20
  - **Semantic Targeting**: 11 ways to locate elements (role, text, label, CSS, CSS+text combo, XPath, coordinates, etc.)
20
21
  - **Auto-Wait**: Built-in clickability and input-ready detection with deadline-based timeout budget
21
22
  - **Dual Input Mode**: `precise` (debugger API, bypasses CSP) or `stealth` (JS injection, no debug banner)
@@ -38,37 +39,6 @@ existing browser, **CDP mode** (fallback) launches a dedicated instance.
38
39
  Local zero-config auto-connect is unchanged. Reloading the Extension or restarting the MCP client does not require a
39
40
  manual Connect click.
40
41
 
41
- ## Request scope and failure handling
42
-
43
- An input sequence keeps its selected backend and page until the sequence and target restoration finish. Concurrent
44
- `browse(action="connect")` waits for that scope. A CDP request with `frame` returns a capability error before resolving
45
- or operating on an Extension page. Extension frame resolution checks the selected document and probes the native iframe
46
- owner, so reordering same-URL frames cannot redirect execution by a stale DOM index.
47
-
48
- Explicit `wait="networkidle"` enables Network observation before navigation and waits for requests to finish followed by
49
- 500 ms of quiet. Missing or interrupted observation returns an error; the default `load` path does not attach a debugger
50
- for network-idle tracking. CDP network logs retain the HTTP status when a response body fails and record one terminal
51
- entry per request. Temporary CDP page selection preserves separate log buffers for each target.
52
-
53
- Input `timeout` includes page selection, preparation and key RPCs. An acknowledgement that arrives after the deadline
54
- cannot produce success; uncertain execution is reported as `actionStatus="unknown"` with `retryable=false`. Read the
55
- current page state before deciding the next action.
56
-
57
- Group operations serialize with page release and recheck membership and managed authority while holding the affected
58
- page locks. For page creation, use `active`; `activate` is accepted only by `movePage`. Popup settings report failed
59
- storage writes, and delayed stored values cannot override a newer setting. Default local auto-connect remains enabled
60
- without a manual pairing or connection step.
61
-
62
- ## Compatible Clients
63
-
64
- | Client | Status |
65
- | ------------------------- | ------ |
66
- | Claude Code | ✅ |
67
- | Claude Desktop | ✅ |
68
- | Cursor | ✅ |
69
- | Windsurf | ✅ |
70
- | Any MCP-compatible client | ✅ |
71
-
72
42
  ## Installation
73
43
 
74
44
  Requires Node.js 20.19 or newer.
@@ -106,7 +76,8 @@ Chrome discovery checks Windows App Paths, `PATH`, installed Chrome channels, Ch
106
76
  ```powershell
107
77
  & '<npm-root>\@pyrokine\mcp-chrome\scripts\start-chrome.ps1' -Port 9222
108
78
  # Or specify a portable executable and profile explicitly:
109
- & '<npm-root>\@pyrokine\mcp-chrome\scripts\start-chrome.ps1' -Port 9222 -ExecutablePath 'C:\Browsers\chrome.exe' -ProfileDir 'C:\Temp\mcp-chrome-profile'
79
+ & '<npm-root>\@pyrokine\mcp-chrome\scripts\start-chrome.ps1' -Port 9222 `
80
+ -ExecutablePath 'C:\Browsers\chrome.exe' -ProfileDir 'C:\Temp\mcp-chrome-profile'
110
81
  ```
111
82
 
112
83
  Then call `browse(action="connect", port=9222)`. The script keeps its Chrome process in the foreground; Chrome exit
@@ -178,6 +149,20 @@ To require a pairing token instead of zero-config local use, set `MCP_CHROME_ALL
178
149
  and disable "Allow no-token local connection" in the Extension popup. Disabling that policy immediately cancels pending
179
150
  health checks, WebSocket handshakes, and scheduled reconnects, so an older no-token attempt cannot connect afterward.
180
151
 
152
+ Token connections require authentication protocol v2 on both sides. Each command, response, cancellation and heartbeat
153
+ is authenticated with direction-separated session keys and an increasing sequence number. Health proofs bind the nonces,
154
+ server instance and port. The Extension waits for an authenticated ready message; the server waits for an authenticated
155
+ hello. Older strict-token peers are rejected with a protocol diagnostic. Default no-token discovery and automatic
156
+ reconnection retain their existing behavior.
157
+
158
+ The popup Disconnect action pauses connections for the current Extension session, including Service Worker recovery.
159
+ Connect resumes discovery. Reloading the Extension or restarting Chrome clears the pause and restores auto-connect.
160
+ When one MCP Server restarts, the Extension retries that server with the existing backoff while keeping other server connections active. Explicit Disconnect cancels these retries.
161
+
162
+ Discovery reports the initial server-port set and changes, including an empty set. Unchanged scans and automatic reconnects do not repeat that summary; each scan still checks the full port range. Explicit disconnect starts a new reporting cycle. Ordinary pre-open failures remain debug-level. Authentication or protocol rejections from identified MCP servers produce one bounded warning when their summary changes.
163
+
164
+ Popup settings report storage failures, and delayed old values cannot overwrite a newer choice. A temporary saved-pause read failure can recover on a later connection attempt in the same Worker. Explicit Disconnect stops local connections immediately; a pause-write failure remains visible. Default local auto-connect needs no manual pairing or Connect click.
165
+
181
166
  ### Mode 2: CDP Mode (Fallback)
182
167
 
183
168
  CDP mode launches or connects to a dedicated Chrome instance. Used when the Extension is not installed, or for
@@ -198,6 +183,168 @@ browse(action="open", url="https://example.com")
198
183
  > return to Extension mode. A CDP connection created only as fallback yields to Extension after the Extension
199
184
  > reconnects.
200
185
 
186
+ ## Target: Unified Element Locator
187
+
188
+ All tools use a unified `Target` type for element location. CSS, text, role and label queries traverse open shadow
189
+ roots in stable order; XPath retains native document-tree semantics. `aria-labelledby` uses IDs from the element's own
190
+ tree, preserves multiple-reference order and takes precedence over `aria-label`. Content-named roles such as `tab`,
191
+ `checkbox` and `menuitem` include visible descendant text, including nested spans. State names use the same rules;
192
+ ordinary inputs retain their current values in `value` and `pageContent`, separately from their names. Password,
193
+ hidden and file input values are not read by state extraction. Closed shadow roots remain outside Extension DOM queries.
194
+
195
+ Examples:
196
+
197
+ ```typescript
198
+ // By accessibility (recommended - most stable)
199
+ const byRole = { role: 'button', name: 'Submit' }
200
+
201
+ // By accessibility with exact accessible name
202
+ const byExactRole = { role: 'button', name: 'Submit', exact: true }
203
+
204
+ // By text content
205
+ const byText = { text: 'Click here', exact: true }
206
+
207
+ // By form label
208
+ const byLabel = { label: 'Email' }
209
+
210
+ // By placeholder
211
+ const byPlaceholder = { placeholder: 'Enter your name' }
212
+
213
+ // By title attribute
214
+ const byTitle = { title: 'Close dialog' }
215
+
216
+ // By alt text (images)
217
+ const byAlt = { alt: 'Profile picture' }
218
+
219
+ // By test ID
220
+ const byTestId = { testId: 'submit-button' }
221
+
222
+ // By CSS selector
223
+ const byCss = { css: '#login-form .submit-btn' }
224
+
225
+ // Disambiguate multiple matches (0-based)
226
+ const secondMatch = { css: '.ant-select-input', nth: 1 }
227
+
228
+ // By CSS + text (filter by text content)
229
+ const byCssText = { css: 'button', text: 'Submit', exact: true }
230
+
231
+ // By XPath
232
+ const byXPath = { xpath: "//button[@type='submit']" }
233
+
234
+ // By coordinates
235
+ const byCoordinates = { x: 100, y: 200 }
236
+ ```
237
+
238
+ Text-only targets choose the innermost complete-text match, including nested text nodes. Explicit XPath preserves document order. Both backends use display, visibility and nonzero dimensions for visibility; an initially absent hidden/detached target succeeds on its first query.
239
+
240
+ In both backends, target lookup failures from `input`, `extract`, and `wait` report the failed locator, zero-based
241
+ `nth`, URL, tab/frame scope, managed state, last locator state, and at most 10 candidate summaries within the request
242
+ budget. `matchCount` is the observed total, not the candidate limit; an out-of-range `nth` does not turn 15 matches into
243
+ zero. Unknown counts or managed state are `null`, and unavailable diagnostics include `diagnosticError`. CDP retains
244
+ `ELEMENT_NOT_FOUND` for lookup failures and `TIMEOUT` for element waits, together with existing URL and log fields.
245
+ Diagnostics read the failed target before its scope is restored and never replay input.
246
+
247
+ Targeted operations resolve `target.nth` directly in both backends, including indices beyond the default 50-result
248
+ candidate list and pure-text indices beyond 200. A single-target result does not report a total; its diagnostic
249
+ `matchCount` is `null` unless a separate lookup measured the total. Element waits check that selected target, so an
250
+ existing high-index element cannot satisfy `hidden` or `detached` merely because candidate output is bounded.
251
+
252
+ Page tools accept `targetId` in either backend; the older `tabId` alias is still accepted. If both are supplied, they
253
+ must match. An explicit target changes only the operation scope and restores the previous default afterward.
254
+ `browse.close` and `manage.closePage` require an explicit ID. Page responses, including action failures, include
255
+ `pageContext` with the effective target and its source (`explicit`, `default`, `created`, `reused`, or `unconfirmed`),
256
+ before/after URL and revision, default target before/after, and Chrome's active target when Extension reports it.
257
+ `unconfirmed` means a page-creation action failed without returning a created target ID. CDP reports browser activity as
258
+ unavailable rather than treating the selected operation target as foreground.
259
+
260
+ Page URL fields in these snapshots, browse results, page/window management, state, metadata, and diagnostic bundles
261
+ redact credential query parameters, including `ticket`, and report `urlRedacted`, `urlOriginalLength`, and
262
+ `redactedQueryParameters`. Native `pendingUrl` and `favIconUrl` fields use equivalent field-prefixed markers.
263
+ Navigation waits and navigation error messages use the same display redaction. Navigation
264
+ and `expectedUrl` comparisons use the original URL; page content and user-script results retain their requested content.
265
+ Use `expectedRevision` or an original URL you hold for conditions; a redacted display URL cannot serve as `expectedUrl`.
266
+
267
+ When an older Extension lacks `page_snapshot`, unconditional page actions can still use a fresh page-list URL. Their
268
+ `pageContext.before` and `after` snapshots report `revision=null` with a `warning` about the unavailable revision and
269
+ atomic conditions. Requests with `expectedUrl` or `expectedRevision` return `DRIVER_CAPABILITY_ERROR`,
270
+ `actionExecuted=false`, and `actionStatus="not_started"` before dispatch; update the Extension to use these conditions.
271
+ Evaluate and input retain `failureStage="precondition"`, with matching top-level and error-context status and no script
272
+ or input events dispatched. Other snapshot errors still stop the action, and compatibility reads share the original
273
+ timeout budget.
274
+
275
+ In Extension mode, a page snapshot that reports the requested tab is missing returns `TARGET_NOT_FOUND` with
276
+ `context.targetId` and the original `context.nativeMessage`. Input rejected before dispatch retains `eventsExecuted=0`
277
+ and `actionExecuted=false`. The failed request is not redirected to another page or replayed. User-script exceptions
278
+ with the same text are not classified as missing pages.
279
+
280
+ Creation failures retain `error.context.createdTargetId`, window ID, actual `managed`, `actionExecuted`,
281
+ `actionStatus="partial"` and `failureStage` when Chrome has returned the identity. If an RPC response is unknown,
282
+ `actionStatus` and `actionExecuted` are `"unknown"`; `pageContext.targetId` is null unless the created identity is
283
+ known, never the previous default page. Failed creation is not automatically repeated or undone.
284
+
285
+ Temporary target restoration is reported separately in `pageContext.targetRestoration`: `restored` selects the previous
286
+ default, `cleared` leaves no default when none existed, `previous_target_closed` clears a closed default, and `failed`
287
+ reports restoration or cleanup errors while clearing the temporary selection. `error` and `cleanupError` retain the
288
+ respective failure messages. The primary action result or original error is preserved; completed input is not replayed
289
+ or reported as unexecuted. `browse attach` and `manage adoptPage` keep their persistent-default behavior. Concurrent
290
+ page responses describe the page actually used by each action.
291
+
292
+ `browse.list` returns each page's revision and metadata. Revisions combine a backend epoch with a per-page counter.
293
+ Extension counts main-frame navigations and MCP actions; CDP counts observed navigation for the attached page and
294
+ conservatively counts sent mutating commands, including evaluations. Neither driver tracks arbitrary DOM changes made by
295
+ the page itself; re-read URL and revision before a conditional action. `browse` navigation/close, `input`, `evaluate`,
296
+ and eligible `manage` page actions accept `expectedUrl` and `expectedRevision`. A mismatch at the backend returns
297
+ `ACTION_PRECONDITION_FAILED` before that page action is sent. A multi-event action checks conditions before its first
298
+ modifying command, not before every event. A failed or timed-out action can still change the revision when it may have
299
+ had partial effects.
300
+
301
+ ## Request scope and failure handling
302
+
303
+ An input sequence keeps its backend and page through execution and target restoration. CDP binds frame execution to its context and OOPIF session; Extension checks the document and native iframe owner, so same-URL iframe reordering preserves the selected identity. Concurrent `browse(action="connect")` waits for that request scope.
304
+
305
+ Input and evaluate share one budget across queueing, page selection, preparation, dispatch and verification. Cancellation or budget settlement stops queued scripts, remaining events and later context or diagnostic reads. Keys newly held by that request are released with a separate bounded cleanup budget. Confirmed final events retain `actionStatus="completed"` if later response handling exceeds the deadline; dispatched actions without confirmation retain `unknown` and `retryable=false`. Read the current page before deciding on another action.
306
+
307
+ Coordinate input waits for synchronous scroll cascades, including open Shadow roots created during preparation, then reads the current frame-local rectangle. Unrelated requestAnimationFrame scrolling does not keep a stable target waiting. Continuous synchronous self-scrolling is bounded by the request deadline, even when the target stays still.
308
+
309
+ MCP cancellation also stops queued window and group changes. The Extension checks the request after asynchronous preflight and before native changes or uncommitted ownership, read-grant and metadata updates. A successful storage commit is synchronized to memory; required registration after creation and cleanup after closing still finish. Event-ref controls remain available while another page action is waiting.
310
+
311
+ Extract uses the same signal for queueing, page reads and exports. Cookie, log, event, evaluate and extract outputs check the signal and deadline during preparation and before publication. Cancellation stops later reads, unpublished files and later log manifests; published files remain available and temporary-file cleanup finishes. A completed script retains its execution state if its output is stopped.
312
+
313
+ ## Operation status and diagnostics
314
+
315
+ Input and evaluate expose execution and verification separately:
316
+
317
+ | Field | Values | Meaning |
318
+ | -------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------- |
319
+ | `actionExecuted` | `false`, `true`, `"unknown"` | Known principal-action execution fact |
320
+ | `actionStatus` | `not_started`, `completed`, `failed`, `unknown` | Principal-action outcome |
321
+ | `verificationStatus` | `matched`, `not_matched`, `unavailable`, `error` | Post-condition observation |
322
+ | `failureStage` | Context, precondition, queue, action, verification or output | Stage that failed |
323
+ | `retryable` | Boolean | Whether the principal action can be retried |
324
+ | `diagnosticsStatus` | Status of supplemental diagnostics | Diagnostics keep the primary result and observations collected before failure |
325
+
326
+ Page-thrown exceptions retain their message text, including empty strings, JSON-shaped text and primitive values, with `actionExecuted=true` and `actionStatus="failed"`. Existing exception descriptions and stacks are preserved. Once the script's result has resolved, failures during type inspection, diagnostic summaries, or JSON encoding and decoding of results and error details report `actionExecuted=true`, `actionStatus="completed"`, `failureStage="output"` and `retryable=false`, including in stealth mode. Promise rejection while adopting the return value remains an action failure. If an encoded error summary cannot be decoded, `error.context.originalOutputError` retains the first output diagnostic.
327
+
328
+ An initial snapshot failure reports `false/not_started`, `failureStage="context"` and `pageContext.contextPhase="before"`. A snapshot checking `expectedUrl` or `expectedRevision` uses `precondition` for both stage fields. If a target, frame, Challenge, argument or per-event preparation RPC has an unknown receipt or an internal evaluate output failure before the principal action is dispatched, the top-level action remains `false/not_started/context`; the auxiliary operation keeps its own facts in the error context. Confirmed earlier input events remain counted. Late replies do not dispatch or replay the principal action.
329
+
330
+ A page precondition mismatch reports `false/not_started/precondition`. Target diagnostics read the current tab instead of cached attach metadata.
331
+
332
+ ### Native failures and diagnostics
333
+
334
+ Native script termination, `Internal error`, `Object couldn't be returned by value`, and
335
+ `Object reference chain is too long` responses from CDP `Runtime` script commands preserve the original error code.
336
+ evaluate and `manage cdp` return `actionExecuted=true`, `actionStatus="unknown"`, and `retryable=false` without
337
+ replaying the command. evaluate also returns `retryable=false` when an in-flight RPC timeout or stale execution context
338
+ leaves the result unknown; failures before dispatch use their reported `retryable` field. Page-thrown exceptions with the same text
339
+ remain non-retryable action failures.
340
+
341
+ Recognized Extension CDP rejections return `CDP_ERROR` with the method, target, native message and available protocol
342
+ code. The context distinguishes a disabled Debugger domain, stale script ID, browser-level command restriction, missing
343
+ method, command permission refusal (`Not allowed`), and native result serialization failure. A resource or method lookup
344
+ failure does not imply that the entire domain is unsupported. These remain failed calls with warning diagnostics;
345
+ unknown errors retain error-level reporting. A closed tab found during a native snapshot or permission check remains a
346
+ target failure, separate from page-thrown exceptions with matching text.
347
+
201
348
  ## Available Tools (8 Tools)
202
349
 
203
350
  ### browse - Browser Management & Navigation
@@ -214,10 +361,16 @@ browse(action="open", url="https://example.com")
214
361
  | `refresh` | Reload page |
215
362
  | `close` | Close the page specified by `targetId` |
216
363
 
364
+ A default `launch` uses a connected Extension. Explicit `headless`, `incognito`, `userDataDir`, `executablePath`, or
365
+ `port` selects a new CDP browser and returns `mode="cdp"`. An existing CDP connection is reported as a conflict before
366
+ creating or closing a browser; supplied launch settings are applied or rejected.
367
+
217
368
  Extension-specific: `list` returns the flat `targets` array plus a `windows` tree. Each target includes `managed`
218
369
  (whether the tab is controlled by MCP Chrome), `isActive` (Chrome's active tab within its window), `windowId`, `index`,
219
- `pinned`, `incognito`, and `status` (`loading`/`complete`). The tree includes `windowCount`, `focusedWindowId`,
220
- `activeTargetId`, and each window's ordered `tabs` list. `defaultTargetId` identifies the selected operation target; CDP
370
+ `pinned`, `incognito`, and `status` (`loading`/`complete`). Summary mode returns `windowCount` and each window's ordered
371
+ `targetIds`; `details="full"` includes the full native target and window properties. When Chrome has a focused window, `focusedWindowId`
372
+ identifies it and `activeTargetId` identifies its active tab. With no focused Chrome window, both fields are omitted;
373
+ each window still reports its own `activeTabId`. `defaultTargetId` identifies the selected operation target; CDP
221
374
  does not infer Chrome's foreground tab from this selection. `open` auto-creates tab group (cyan color). `open`, `back`,
222
375
  `forward`, and `refresh` accept `diagnostics=true` to return new console warnings/errors and failed network requests
223
376
  observed during the action, including the first `open` that creates a page automatically. `open` and `refresh` honor
@@ -230,15 +383,23 @@ the entire CDP connection.
230
383
 
231
384
  In Extension mode, `back` and `forward` use native browser history first. Only a native no-history error permits a
232
385
  script fallback, and only on a scriptable document; restricted URLs and browser error pages are not injected. With no
233
- available history they return `navigated=false`. Other native failures are preserved. A destroyed execution context or a
386
+ available history they return `navigated=false` without consuming the navigation wait budget. The page fallback checks `history.length` and, when available, the Navigation API's direction flag before dispatch. Other native failures are preserved. A destroyed execution context or a
234
387
  browser refusing injection into an error page still returns an operation failure, recorded as a warning in the Extension
235
388
  rather than a program error. Arbitrary debugger commands are never automatically replayed.
236
389
 
390
+ If a CDP history-navigation command is rejected, the original error is returned and that navigation wait ends immediately, keeping later requests available.
391
+
237
392
  For `open`, `back`, `forward`, and `refresh`, `timeout` starts at request entry. Target preparation, queueing, protocol
238
393
  calls, page loading, Challenge inspection and clicks, diagnostics, and target restoration share the remaining budget;
239
394
  navigation RPCs do not add transport time. An expired queued action is not dispatched, and later requests still wait for
240
395
  an earlier in-flight action to settle. Explicit `timeout=0` rejects before navigation dispatch. Page creation retains
241
- its separate load-wait and transport-time contract.
396
+ its separate load-wait and transport-time contract. When the navigation wait exhausts the request deadline, later metadata and diagnostic reads stop. A shorter wait timeout leaves the enclosing request's remaining budget available.
397
+
398
+ MCP cancellation stops queued browse actions before dispatch and ends active navigation or Challenge waits. The same signal stops later OS mouse commands and CDP launch steps after an interrupted wait; launch cleanup terminates only a process created by that request and not yet delivered.
399
+
400
+ If a mouse button was already pressed, the request retains the tab lock until its necessary release completes or the independent 5000 ms cleanup budget ends. Subsequent navigation and input remain queued during release. A failed or timed-out release reports `releaseStatus="unknown"` with an explicit error; check and release the mouse button before continuing.
401
+
402
+ A confirmed navigation keeps `actionExecuted=true` and `actionStatus="completed"` when its later state read fails, with `failureStage="metadata"` and `retryable=false`; page verification retains its own result.
242
403
 
243
404
  A timeout does not undo a Chrome operation already dispatched. When its result is unknown, the response reports
244
405
  `TIMEOUT`, `actionExecuted="unknown"`, `actionStatus="unknown"`, and `retryable=false`; read the actual page state
@@ -258,48 +419,6 @@ Evaluate retains Challenge result fields on success, action failure, verificatio
258
419
  `originResponsePending=true` means verification succeeded but the origin server has not responded; it does not mean the
259
420
  destination content has loaded.
260
421
 
261
- Page tools accept `targetId` in either backend; the older `tabId` alias is still accepted. If both are supplied, they
262
- must match. An explicit target changes only the operation scope and restores the previous default afterward.
263
- `browse.close` and `manage.closePage` require an explicit ID. Page responses, including action failures, include
264
- `pageContext` with the effective target and its source (`explicit`, `default`, `created`, `reused`, or `unconfirmed`),
265
- before/after URL and revision, default target before/after, and Chrome's active target when Extension reports it.
266
- `unconfirmed` means a page-creation action failed without returning a created target ID. CDP reports browser activity as
267
- unavailable rather than treating the selected operation target as foreground.
268
-
269
- When an older Extension lacks `page_snapshot`, unconditional page actions can still use a fresh page-list URL. Their
270
- `pageContext.before` and `after` snapshots report `revision=null` with a `warning` about the unavailable revision and
271
- atomic conditions. Requests with `expectedUrl` or `expectedRevision` return `DRIVER_CAPABILITY_ERROR`,
272
- `actionExecuted=false`, and `actionStatus="not_started"` before dispatch; update the Extension to use these conditions.
273
- Evaluate and input retain `failureStage="precondition"`, with matching top-level and error-context status and no script
274
- or input events dispatched. Other snapshot errors still stop the action, and compatibility reads share the original
275
- timeout budget.
276
-
277
- In Extension mode, a page snapshot that reports the requested tab is missing returns `TARGET_NOT_FOUND` with
278
- `context.targetId` and the original `context.nativeMessage`. Input rejected before dispatch retains `eventsExecuted=0`
279
- and `actionExecuted=false`. The failed request is not redirected to another page or replayed. User-script exceptions
280
- with the same text are not classified as missing pages.
281
-
282
- Creation failures retain `error.context.createdTargetId`, window ID, actual `managed`, `actionExecuted`,
283
- `actionStatus="partial"` and `failureStage` when Chrome has returned the identity. If an RPC response is unknown,
284
- `actionStatus` and `actionExecuted` are `"unknown"`; `pageContext.targetId` is null unless the created identity is
285
- known, never the previous default page. Failed creation is not automatically repeated or undone.
286
-
287
- Temporary target restoration is reported separately in `pageContext.targetRestoration`: `restored` selects the previous
288
- default, `cleared` leaves no default when none existed, `previous_target_closed` clears a closed default, and `failed`
289
- reports restoration or cleanup errors while clearing the temporary selection. `error` and `cleanupError` retain the
290
- respective failure messages. The primary action result or original error is preserved; completed input is not replayed
291
- or reported as unexecuted. `browse attach` and `manage adoptPage` keep their persistent-default behavior. Concurrent
292
- page responses describe the page actually used by each action.
293
-
294
- `browse.list` returns each page's revision and metadata. Revisions combine a backend epoch with a per-page counter.
295
- Extension counts main-frame navigations and MCP actions; CDP counts observed navigation for the attached page and
296
- conservatively counts sent mutating commands, including evaluations. Neither driver tracks arbitrary DOM changes made by
297
- the page itself; re-read URL and revision before a conditional action. `browse` navigation/close, `input`, `evaluate`,
298
- and eligible `manage` page actions accept `expectedUrl` and `expectedRevision`. A mismatch at the backend returns
299
- `ACTION_PRECONDITION_FAILED` before that page action is sent. A multi-event action checks conditions before its first
300
- modifying command, not before every event. A failed or timed-out action can still change the revision when it may have
301
- had partial effects.
302
-
303
422
  For `browse`, only `open`, `back`, `forward`, `refresh`, and `close` accept these conditions. Other actions, including
304
423
  `attach`, reject them with `INVALID_ARGUMENT` before changing any target.
305
424
 
@@ -309,12 +428,12 @@ page. `releasePage` revokes full managed access without closing the tab or chang
309
428
  log state and removes debugging and console capture resources. If Chrome prevents resource cleanup, the response
310
429
  includes `warnings` while managed access is still revoked.
311
430
 
312
- Managed access survives a Service Worker restart. Reloading the Extension also restores access to surviving managed
313
- tabs whose original document identity still matches, without refreshing or adopting them again. Tabs with unavailable
314
- document identity require explicit `adoptPage` after an Extension reload; ordinary navigation keeps managed access,
315
- and `releasePage` remains revoked after a restart or reload. A reused tab ID does not authorize a different document.
316
- A managed tab can keep using this Extension's existing debugger session after a Service Worker restart. Sessions owned
317
- by other debuggers still return `DEBUGGER_BLOCKED`.
431
+ Managed access survives a Service Worker restart. Reloading the Extension also restores access to surviving managed tabs
432
+ whose original document identity still matches, without refreshing or adopting them again. Tabs with unavailable
433
+ document identity require explicit `adoptPage` after an Extension reload; ordinary navigation keeps managed access, and
434
+ `releasePage` remains revoked after a restart or reload. A reused tab ID does not authorize a different document. A
435
+ managed tab can keep using this Extension's existing debugger session after a Service Worker restart. Sessions owned by
436
+ other debuggers still return `DEBUGGER_BLOCKED`.
318
437
 
319
438
  Use `manage(action="grantReadAccess", targetId=...)` to grant ordinary reads and `revokeReadAccess` to revoke them; no
320
439
  popup click is required. Both require an explicit target and accept `expectedUrl`/`expectedRevision`. Grants belong to
@@ -325,57 +444,90 @@ target ID alone does not authorize reading. The grant covers ordinary content re
325
444
  attributes, computed styles, and page state. Scripts, debugger operations, screenshots, input, and cookie access do not
326
445
  inherit it; existing cookie operations have separate URL/name filter rules. When page management or navigation is
327
446
  refused for lack of managed access, the revision and any valid ordinary-read grant remain unchanged.
328
- `manage(action="pageMetadata", targetId=...)` reads or updates `taskHint` and `note`, and list results show creation and
329
- last-use timestamps. Reads and updates accept `expectedUrl`/`expectedRevision`; a mismatch returns
330
- `ACTION_PRECONDITION_FAILED` without reading or updating notes. This metadata is process-local and is removed when a
331
- page is closed; it never authorizes content access.
447
+ `manage(action="pageMetadata", targetId=...)` reads or updates `taskHint` and `note`, with
448
+ `expectedUrl`/`expectedRevision` conditions. A mismatch returns `ACTION_PRECONDITION_FAILED` before reading or updating
449
+ notes. Extension persists `origin=created/adopted/unknown`, creation time and task notes. Existing v1 pages migrate to
450
+ unknown and remain managed. Extension metadata is authoritative after Server restart; storage failures return errors.
451
+ CDP metadata remains local to the Server process. Origin, document identity and trusted native relationships
452
+ are maintained
453
+ by Extension; notes never grant content access.
454
+
455
+ Start each task with `browse list`, select a suitable page by task name and notes, and attach in the
456
+ background to reuse it.
457
+ Call `newPage` only when no suitable page exists, supplying `taskHint` and a `note` that identifies temporary, output or
458
+ reusable use. `newPage` always creates a new page. By default, it uses an existing normal window containing a trusted
459
+ created page, then another existing normal window. With no normal window it returns an error; lost caches never create a
460
+ window. Task groups are reused only through trusted creation records and current native membership, never their name.
461
+ Mixed user groups and same-name user groups remain untouched. Renaming a task updates the native group title when all
462
+ trusted members share that task. Native moves, closure and membership changes clear invalid relationships.
463
+
464
+ At task completion, use the existing close/release actions on an explicit page set. Default cleanup closes only pages
465
+ created for this task whose notes explicitly identify temporary use. Preserve adopted/unknown pages, outputs, reusable
466
+ test pages and mixed user groups; release unused temporary permissions through existing actions. Explicitly authorized
467
+ closure retains the existing managed-page contract. Disconnects and idle periods never close pages. Native
468
+ groups require
469
+ Extension; CDP accepts metadata-only `taskHint/note` options.
470
+
471
+ Explicit `networkidle` starts Network observation before navigation and requires 500 ms of quiet after tracked requests finish. Missing or interrupted observation returns an error. The default `load` path does not attach a debugger for network-idle tracking.
332
472
 
333
473
  ### Access challenges
334
474
 
335
475
  After `open`, `back`, `forward`, `refresh`, `input`, and `evaluate`, MCP Chrome waits for a Cloudflare JS Challenge or
336
476
  Turnstile checkbox. When Extension mode is active, navigation starts without debugger logging. While a Challenge title
337
- persists, MCP Chrome reads the live tab title passively for the first eight seconds. If the interstitial persists, it checks for a visible Turnstile control and
338
- clicks it only when it finds one. Extension inspect uses an isolated world. Challenge titles detach the debugger before
339
- inspection; ordinary-page checks retain an existing connection unless a visible verification control or unresolved
340
- challenge content is found. Same-page
341
- fixture buttons use the existing page click. If a Cloudflare Turnstile iframe is present, inspect CSS coordinates are
342
- converted to screen coordinates and the OS mouse moves along a path, hovers, then presses and releases: `xdotool` on
343
- Linux uses the focused Chrome client-window geometry and `xprop` GTK frame extents only when that window title matches
344
- the test page. Missing tools, invalid geometry, or a viewport mismatch stop the click instead of guessing the content
345
- origin from Chrome `screenX` or `outerHeight - innerHeight`; `cliclick` or System Events on macOS; and PowerShell
346
- `mouse_event` on Windows. Widget clicks target the checkbox on the left of the compact Turnstile card, including when
347
- the host wrapper is wider than the card, not the label. If a Cloudflare iframe is already in the DOM, the OS mouse is
348
- used even when that iframe reports a zero-size rect, including the later host `Verify you are human` / `请验证您是真人`
349
- button. The OS click runs only when the managed test tab is already the active tab in an already-focused window; mixed
350
- windows are not focused. Debugger is detached and the viewport is read again before the OS click. Missing OS mouse tools
351
- or an unfocused window return a visible error instead of a silent CDP click. A Turnstile widget is clicked only after
352
- two inspections report the same click point; unrelated elements do not become widgets just because their sizes match.
353
- Distant OS-mouse paths start near the control instead of flying across the screen. The same checkbox or compact widget
354
- is clicked at most once; if Cloudflare then shows a visible `Verify you are human` or `请验证您是真人` button, that
355
- button is inspected as `verify` and clicked at most once in the same wait. Use the default `diagnostics=false` for
356
- challenge-protected pages because diagnostics starts debugger console and network collection.
477
+ persists, MCP Chrome reads the live tab title passively for the first eight seconds. If the interstitial persists, it
478
+ checks for a visible Turnstile control and clicks it only when it finds one. Extension inspect uses an isolated world.
479
+ Challenge titles detach the debugger before inspection; ordinary-page checks retain an existing connection unless a
480
+ visible verification control or unresolved challenge content is found. Same-page fixture buttons use the existing page
481
+ click. If a Cloudflare Turnstile iframe is present, inspect CSS coordinates are converted to screen coordinates and the
482
+ OS mouse moves along a path, hovers, then presses and releases: `xdotool` on Linux uses the focused Chrome client-window
483
+ geometry and `xprop` GTK frame extents only when that window title matches the test page. Missing tools, invalid
484
+ geometry, or a viewport mismatch stop the click instead of guessing the content origin from Chrome `screenX` or
485
+ `outerHeight - innerHeight`; `cliclick` or System Events on macOS; and PowerShell `mouse_event` on Windows. Widget
486
+ clicks target the checkbox on the left of the compact Turnstile card, including when the host wrapper is wider than the
487
+ card, not the label. If a Cloudflare iframe is already in the DOM, the OS mouse is used even when that iframe reports a
488
+ zero-size rect, including the later host `Verify you are human` / `请验证您是真人` button. The OS click runs only when
489
+ the managed test tab is already the active tab in an already-focused window; mixed windows are not focused. Debugger is
490
+ detached before the OS click. After movement and hover, the control position, viewport and active window are checked again
491
+ before pressing. On Linux, a 1 px native round trip calibrates the current content origin while the debugger banner
492
+ animates. If the control moves, the mouse repeats the path, hover and calibration within the original timeout. A changed
493
+ page, control stage or focus stops the click. Missing OS mouse tools or an unfocused window return a visible error instead
494
+ of a silent CDP click. A Turnstile widget is clicked only after two inspections report the same
495
+ click point; unrelated elements do not become widgets just because their sizes match. Distant OS-mouse paths start near
496
+ the control instead of flying across the screen. The same checkbox or compact widget is clicked at most once; if
497
+ Cloudflare then shows a visible `Verify you are human` or `请验证您是真人` button, that button is inspected as `verify`
498
+ and clicked at most once in the same wait. Use the default `diagnostics=false` for challenge-protected pages because
499
+ diagnostics starts debugger console and network collection.
357
500
 
358
501
  Detection covers titles such as `Just a moment...` and `请稍候…`, visible challenge DOM or body-text markers, and
359
502
  `Verify you are human` / `请验证您是真人` controls, including visible `button` elements with that exact text. A normal
360
503
  title still requires a bounded check of visible content: visible `正在进行安全验证` blocks the action, while hidden
361
- markers do not. Pages without challenge evidence continue without a fixed eight-second wait. Same-page buttons use
362
- page input when no Cloudflare iframe is present. CDP reads live titles with `Target.getTargetInfo`. A leftover
363
- Cloudflare iframe or an old pending header alone does not keep a recovered page pending or trigger scrolling or a
364
- click. Cached titles do not decide the result. MCP Chrome does not call a CAPTCHA solver, retry navigation, or export
365
- `cf_clearance` values. A CDP timeout does not prove that the site fails in a user Chrome session; check the returned
366
- `mode` before diagnosing the site.
504
+ markers do not. Pages without challenge evidence continue without a fixed eight-second wait. Same-page buttons use page
505
+ input when no Cloudflare iframe is present. CDP reads live titles with `Target.getTargetInfo`. A leftover Cloudflare
506
+ iframe or an old pending header alone does not keep a recovered page pending or trigger scrolling or a click. Cached
507
+ titles do not decide the result. MCP Chrome does not call a CAPTCHA solver, retry navigation, or export `cf_clearance`
508
+ values. A CDP timeout does not prove that the site fails in a user Chrome session; check the returned `mode` before
509
+ diagnosing the site.
510
+
511
+ A completed embedded widget can retain its container. An associated nonempty response marks that widget complete;
512
+ reset or expiry returns it to pending. Each widget is checked separately, and a response in another form cannot complete
513
+ it. Detection returns completion state without returning the response value.
514
+
515
+ Input and evaluate check for a new challenge after the action returns, using the remaining budget. A verification
516
+ failure retains the action's completed state and never replays it. If the confirmed final event exhausts the budget,
517
+ `challengeVerificationStatus="unavailable"` explains that no post-action challenge check could run. A post-action timeout
518
+ returns `retryable=false` and `nextAction="wait_and_verify"`; wait for verification and inspect the business result.
367
519
 
368
520
  A resolved challenge returns `challengeResolved=true`, `challengeKind`, `waitedMs`, `clickedTurnstile`, and
369
521
  `clearanceCookiePresent` (name presence only). If the visible page text says verification succeeded and Cloudflare is
370
522
  waiting for the origin, the result also has `originResponsePending=true`; verification passed, but the destination page
371
523
  is not loaded yet. Hidden template text such as a `display:none` success heading does not count, and a visible Turnstile
372
- checkbox still counts as pending. Challenge results and errors include `mode`. Timeout returns `CHALLENGE_TIMEOUT` with
373
- `retryable=true`, `clickedTurnstile`, and the observed `challengeKind` (a Turnstile click is not reported as `js`).
524
+ checkbox still counts as pending. Challenge results and errors include `mode`. Before-action timeout returns
525
+ `CHALLENGE_TIMEOUT` with `retryable=true`, `clickedTurnstile`, and the observed `challengeKind` (a Turnstile click is not reported as `js`).
374
526
  Cloudflare Access denied returns `CHALLENGE_DENIED`. Interactive CAPTCHAs, Bot Fight Mode, and IP reputation checks
375
527
  cannot be completed by waiting or clicking a checkbox. A later normal main-document response clears the header flag;
376
528
  ordinary iframe document responses and clearing network logs do not.
377
529
 
378
- ### input - Keyboard & Mouse Input
530
+ ### input - Keyboard, Mouse & File Input
379
531
 
380
532
  Event sequence model supporting arbitrary combinations:
381
533
 
@@ -388,6 +540,7 @@ Event sequence model supporting arbitrary combinations:
388
540
  | `wheel` | Mouse wheel scroll |
389
541
  | `touchstart` / `touchmove` / `touchend` | Touch events |
390
542
  | `type` | Type text (with optional `delay`, `dispatch` for React/Vue) |
543
+ | `upload` | Select local files in a file input; `files:[]` clears the selection |
391
544
  | `wait` | Pause between events |
392
545
  | `select` | Select text by content (mouse sim) |
393
546
  | `replace` | Find and replace text |
@@ -396,6 +549,11 @@ Event sequence model supporting arbitrary combinations:
396
549
  | `editorInsert` | Insert text at the current editor selection |
397
550
  | `editorCommand` | Execute browser editing commands such as `bold` or `insertOrderedList` |
398
551
 
552
+ On background Extension tabs, a default unmodified left click on an element uses checked synthetic events and returns a
553
+ `warnings` entry with `isTrusted=false`, without selecting the tab. On a rendered active tab, precise mode uses native input.
554
+ Background coordinate clicks, movement, or modified/multiple clicks require explicit
555
+ `manage(action="inputMode",inputMode="stealth")`; mouse-button cleanup remains available.
556
+
399
557
  Special-case parameters:
400
558
 
401
559
  - `keydown` accepts `commands` (e.g. `["selectAll"]`, `["copy"]`, `["paste"]`, `["cut"]`, `["undo"]`, `["redo"]`) to
@@ -414,25 +572,48 @@ waits for a page state after the events so callers can distinguish dispatched in
414
572
  accepts 50-5000 ms. A `postCondition.script` may be an expression, function, async function, or Promise expression;
415
573
  functions are invoked and the final Promise value is awaited before matching, while thrown or rejected errors fail the
416
574
  check. `targetId` (or legacy `tabId`) selects a page in either backend; `frame` selects an iframe (CSS selector or
417
- index) in Extension mode. When either scope is provided, the action, diagnostics, and post-condition use the backend
575
+ index or a nested path) in either backend. When either scope is provided, the action, diagnostics, and post-condition use the backend
418
576
  selected for that target scope.
419
577
 
420
- If the frame, execution context, or debugger becomes unavailable during verification, the check returns
421
- `verificationStatus="unavailable"`. A script that throws or rejects, even with the same error text, returns `error`.
422
- An already completed action keeps `actionStatus="completed"` and `failureStage="verification"`; verification does not
423
- replay the action.
578
+ Text, selector and URL checks recover a transient lost context within the remaining input and verification deadlines. A context that stays unavailable, a closed native connection, or an exhausted read budget returns `verificationStatus="unavailable"`. Script checks report native context failures immediately. Native execution termination and engine execution timeouts during verification return `unavailable` in both Extension and CDP. Selector syntax errors and page-thrown or rejected errors return `error`, including when an exception's string conversion also throws. Error text mentioning a frame or timeout does not change the source. A completed input keeps `actionStatus="completed"`, `failureStage="verification"` and top-level `retryable=false`. Use `postCondition.retryable` to retry the check on its own. Verification shares the action's total deadline; an exhausted total budget starts no new check.
579
+
580
+ Cancellation interrupts verification reads and polling waits. Input then attempts a bounded release of keys newly pressed by that request before the next queued action starts. Keys held before the request remain held; release failures retain a diagnostic.
581
+
582
+ Text checks match rendered page text and visible, non-password form values. The bounded `actual` excerpt includes the matched text. Clicks on a Shadow host accept its own shadow descendants; synthetic click, key and input events reach host and document listeners, while mouseenter and change retain their local event semantics.
583
+
584
+ Coordinate targets use the selected frame's viewport coordinates. Native precise input accounts for the frame's content boundary, scaling, rotation, skew and nested placement; input whose coordinates cannot be mapped reliably fails before the affected event. Earlier completed events retain their progress. Stealth events keep frame-local coordinates.
585
+
586
+ Target-based coordinate preparation follows assigned slots and Shadow hosts to the actual scroll container. On visible pages, it checks the target rectangle and ancestor scroll positions across consecutive renders, including cascades triggered by page listeners that stop event propagation. A stable target remains actionable beside a looping, unrelated scroller. A page hidden during this wait uses its current layout without waiting for paused animation frames; a page that becomes visible resumes render checks. Continuous target motion or ancestor scrolling can exhaust the shared request deadline, leaving that event undispatched.
587
+
588
+ An omitted wheel target keeps the current mouse position. Extension wheel helper setup and input target the same resolved documentId; replacement or removal before input returns not_started without selecting the new document.
589
+
590
+ Wheel and mouse events carry the currently held Ctrl, Shift, Alt and Meta fields, including combined modifiers and precise right-click events that use synthetic dispatch. Synthetic events retain `isTrusted=false`; application listeners can inspect the modifier fields and cancel their default scroll.
591
+
592
+ Extension coordinate wheel follows each axis's effective scroll range, including reverse Flex layouts and vertical writing modes. Fractional deltas accumulate across consecutive inputs to the same scroll container, including changes to the hit descendant and scrolling performed by that wheel listener. Position changes between inputs reset that container's pending fraction; another container or document starts its own sequence. Native scroll progress identifies fractional endpoints under CSS zoom. When native progress is unavailable, a console warning identifies the CSSOM-bounds compatibility path. Element scroll distances account for effective CSS zoom; ordinary transform scale keeps its existing wheel-distance semantics. Viewport scrolling uses its own units.
593
+
594
+ Scroll-container eligibility accounts for the namespace, principal box and text-editing controls. MathML math layouts, flow-root and inline flow-root list items, block ruby and Chrome-supported `-webkit-box`/`-webkit-inline-box` layouts retain their scrolling and boundary behavior. A text input can scroll its internal text even when Chrome reports computed overflow as clip. A block SVG viewport does not become a CSS scroll boundary from hidden/contain declarations; a foreignObject with a scrolling box retains its own auto scrolling and hidden contain/none boundary, and embedded HTML retains its own scrolling behavior. At a real container boundary, `overscroll-behavior-x/y: contain` or `none` stops that axis, including zero-range containers; `auto` lets an unconsumed axis continue along the original chain. A nested `overflow:hidden` container keeps its boundary policy without scrolling itself; ordinary clip/visible, non-atomic inline and display:contents nodes do not add that boundary.
595
+
596
+ The viewport follows root/body overflow propagation. A body with no principal box, including display:contents, does not supply its overflow. Effective containment on html/body, including content-visibility or container-type, keeps the body independent. A body supplying viewport overflow is not a separate boundary, and hidden/clip viewport axes do not scroll. A scrollable target consumes its own input first. Absolute/fixed targets then follow the nearest applicable positioning containing block through the composed tree, including slots and foreignObject content. Transform, filter, containment, 3D/motion conditions and applicable will-change names keep their own box-eligibility rules.
597
+
598
+ The composed, cancelable wheel event reaches Shadow host and document listeners. Effective `preventDefault()` suppresses the simulated default scroll; the event still reports `actionStatus="completed"` and counts as one executed input. Each axis selects its scroll route from the boundary at input start. A listener that resizes or repositions a scroll container retains its own changes; the default action uses the resulting position on the selected route. A container that loses its scroll range lets unconsumed input continue along the original chain under its overscroll policy. Removing or moving the hit element does not redirect that wheel to a newly inserted ancestor or an unrelated viewport.
599
+
600
+ Extension wheel uses programmatic scrolling for its default action. Scroll snapping follows that programmatic endpoint, which can differ from native wheel intent. Mandatory and proximity snap layouts retain their declared snapping; native wheel endpoint differences are an accepted compatibility behavior.
424
601
 
425
602
  For keyboard `type`, `timeout` includes Challenge waiting, focus preparation, character input, and `delay`/`humanize`
426
603
  delays. Extension precise/stealth and CDP use the remaining budget. An explicit budget such as `timeout=45000` allows
427
- valid input to take longer than the default 30000 ms. When the budget expires, subsequent characters and events stop.
428
- Already dispatched input cannot be undone, so a timeout may leave partial input. A response with `actionExecuted=true`,
429
- `actionStatus="unknown"`, and `retryable=false` requires an independent page read to check the actual value; do not
430
- replay the whole event sequence.
604
+ valid input to take longer than the default 30,000 milliseconds. When the budget expires, subsequent characters and
605
+ events stop. Already dispatched input cannot be undone, so a timeout may leave partial input. A response with
606
+ `actionExecuted=true`, `actionStatus="unknown"`, and `retryable=false` requires an independent page read to check the
607
+ actual value; do not replay the whole event sequence.
431
608
 
432
609
  Mouse target lookup, stepped movement, and `humanize` delays also share the remaining input budget. Each movement and
433
610
  the subsequent click check the deadline; expiry stops further movement and clicking. Already dispatched native events
434
611
  cannot be undone. Read the page independently after an unknown result instead of replaying the action.
435
612
 
613
+ Explicit Extension precise `keydown`/`keyup` events use native keyboard input. Focus preparation shares the remaining request budget. When focus emulation is needed, response `warnings` explains that the document temporarily reports `visible`; the actual tab and window focus stay unchanged. The original setting is restored before `postCondition` runs.
614
+
615
+ A recovered debugger session with an unknown original focus setting on a background tab returns `KEYBOARD_FOCUS_STATE_UNKNOWN` and `not_started`, preserving that setting. Explicit stealth or an independent CDP session remain available. Restoration failures return `keyboardFocusCleanup`; completed events retain `completed`, and unconfirmed dispatch retains `unknown`. Failure, cancellation or expiry attempts to release keys newly pressed by this request. Successful requests preserve intentionally held keys.
616
+
436
617
  Command focus, text selection, and replacement share the remaining event budget. Expiry stops subsequent actions; Shift
437
618
  release is still attempted without hiding an earlier action error. Stepped CDP touch movement also stops at the
438
619
  deadline.
@@ -444,36 +625,94 @@ events follow the same button mapping.
444
625
  In stealth mode, `delay` separates characters; the first character has no initial wait. Background page timer throttling
445
626
  can lengthen subsequent intervals, but the same deadline still stops further input.
446
627
 
447
- Precise Extension and CDP keyboard input use the current caret and selection. A `target` is clicked before typing and
448
- can change the insertion point. To append to a contenteditable element, focus it, place the caret at its end, then send
449
- `type` without a `target` so that it does not click again.
628
+ Default precise keyboard `type` in Extension and CDP mode dispatches Enter for each newline (CRLF is normalized).
629
+ An editor that submits on Enter can therefore submit part of a multiline input. For multiline replacement in Extension
630
+ mode, use `mode="controlled"` (or `dispatch=true`) with a `target`: it replaces the complete value or contenteditable
631
+ text and dispatches input/change without Enter. Form controls keep their native value setters.
632
+
633
+ Keyboard input and `editorInsert` use the current caret and selection. Keyboard `type` with a `target` clicks it first
634
+ and can change the insertion point; `editorInsert` focuses its target without clicking and inserts through the browser
635
+ editing API without Enter. To append multiline text, place the caret at the end and send `editorInsert` without a
636
+ `target`. A nonempty selection is replaced, not appended. Read the resulting value to verify the editor accepted it.
450
637
 
451
638
  CDP clicks and keyboard input also wait for stable element position and size in background pages without activating
452
639
  them. Visibility, enabled-state, viewport, and click coverage checks still apply. Target lookup, actionability checks,
453
640
  and the final coordinate read share the remaining event budget. If any of these stages exhausts it, no mouse or keyboard
454
641
  event is dispatched.
455
642
 
456
- **`click`-specific**: `force: true` requires `forceReason` and a non-coordinate element `target`, and skips
457
- actionability checks (useful for testing or hidden elements), but still dispatches the standard DOM mouse-event sequence
458
- and does not call framework-private handlers. The same checks apply to middle/right clicks and multiple clicks. Missing
459
- targets and coordinate targets cannot use `force`. Actionability failures return `ACTIONABILITY_FAILED` with `rect`,
460
- `clickPoint`, covering element details, candidate blockers, and suggestions. **`type`-specific**: `mode="controlled"` or
461
- `dispatch: true` sets `.value` directly and fires `input`/ `change` events — use for React/Vue controlled inputs where
462
- keyboard events don't update state. Requires a non-coordinate `target`. Extension mode only. Controlled input and target
463
- lookup failures return structured context with `locator`, `matchCount`, `nth`, bounded `candidates`, and an
464
- `activeElement` summary without input values. The focus summary is `null` when unavailable; a failed DOM query also
465
- returns `diagnosticError`. Selection-specific errors also report editor and selection state. Password input values are
466
- omitted from failure diagnostics, and input `find` or replacement `text` values are redacted from failed responses. For
467
- `select` and `replace`, event-level `nth` selects the Nth text occurrence while nested `target.nth` selects the Nth
468
- matching element; both are zero-based and may be used together. Locator targets for `select` and `replace` work in CDP
469
- mode without Extension ref IDs.
470
-
471
- In both backends, target lookup failures from `input`, `extract`, and `wait` report the failed locator, zero-based `nth`,
472
- URL, tab/frame scope, managed state, last locator state, and at most 10 candidate summaries within the request budget.
473
- `matchCount` is the observed total, not the candidate limit; an out-of-range `nth` does not turn 15 matches into zero.
474
- Unknown counts or managed state are `null`, and unavailable diagnostics include `diagnosticError`. CDP retains
475
- `ELEMENT_NOT_FOUND` for lookup failures and `TIMEOUT` for element waits, together with existing URL and log fields.
476
- Diagnostics read the failed target before its scope is restored and never replay input.
643
+ **`click`-specific**: `force: true` requires `forceReason` and a non-coordinate element `target`. It skips actionability checks while dispatching standard DOM mouse events. Middle/right and multiple clicks use the same rules; a coordinate or omitted target cannot use force. Failures return `ACTIONABILITY_FAILED` with `rect`, `clickPoint`, covering elements, candidate blockers and suggestions.
644
+
645
+ **`type`-specific**: `mode="controlled"` or `dispatch:true` replaces the value or contenteditable text and sends `input`/`change` without Enter. It requires a non-coordinate `target` and Extension mode. Targets must be HTML `input`, `textarea`, `select` or contenteditable; effectively disabled controls, readonly controls, unsupported containers and file inputs are rejected before focus or input events. Disabled fieldsets follow HTML rules, including the first-legend exception. Use `upload` for a file input. Ordinary controls, customized built-ins and same-origin controls adopted from another document use the native value setter for their actual form interface; an unavailable setter returns an error before focus.
646
+
647
+ Controlled input and target-lookup failures return `locator`, `matchCount`, `nth`, bounded `candidates` and an `activeElement` summary without input values. Unavailable focus is `null`; a failed DOM query adds `diagnosticError`.
648
+
649
+ Cancellation or expiry after a confirmed Extension precise character or Enter event preserves executed progress and invalidates the old page revision. Cancellation before the first dispatch keeps the not-started state. Read the current value and revision before another action.
650
+
651
+ For a tag field that commits on Enter, send the text and explicit Enter events, then check the created tag. This `input` example uses `#tag-entry` for the field and `#tags` for its tag list; use the selectors from the page:
652
+
653
+ ```json
654
+ {
655
+ "events": [
656
+ { "type": "type", "target": { "css": "#tag-entry" }, "text": "12345" },
657
+ { "type": "keydown", "key": "Enter" },
658
+ { "type": "keyup", "key": "Enter" }
659
+ ],
660
+ "postCondition": { "selector": "#tags [data-value=\"12345\"]" }
661
+ }
662
+ ```
663
+
664
+ #### Text selection and sensitive input
665
+
666
+ `replace` uses text selection for `textarea` and input types `text`, `search`, `tel`, `url` and `password`. Other input types use a native full-value update and return requested and actual browser-normalized values. Standalone `select` on an unsupported type returns `UNSUPPORTED_SELECTION`. CDP locator targets are focused through CDP rather than Extension ref IDs.
667
+
668
+ Event-level `nth` selects a text occurrence; nested `target.nth` selects a matching element. Both are zero-based and can be combined. Selection errors include editor and selection state.
669
+
670
+ Password values are omitted from failure context and text post-condition observations; failed input responses also redact supplied `find` and replacement `text`, including locator details in `error.logs`. Password `select`/`replace` hides console and network diagnostic bodies on success and failure, returning `diagnostics.redacted=true` and `reason="sensitive_input_or_unresolved_target"`. An unresolved selection target receives the same protection. Ordinary input keeps its diagnostics, and password protection ends with the current input request.
671
+
672
+ #### Upload local files
673
+
674
+ Prefer mcp-chrome for browsing, page interaction, and file uploads. Uploads reuse the current page and Extension/CDP
675
+ connection. Use Chrome DevTools for browser or extension diagnostics and specific tasks that mcp-chrome does not cover.
676
+
677
+ Select a file at its original path, including files in Downloads, through the `input` tool's `upload` event:
678
+
679
+ ```json
680
+ {
681
+ "events": [
682
+ {
683
+ "type": "upload",
684
+ "target": { "css": "input[type=file]" },
685
+ "files": ["./review.zip"]
686
+ }
687
+ ]
688
+ }
689
+ ```
690
+
691
+ `files` is required. Paths refer to readable regular files on the MCP Server machine. Relative paths use the Server's
692
+ working directory; absolute paths and `~/` paths are supported. The Server transfers file bytes, so the browser may run
693
+ on another machine. The selected files' combined size must be below 50 MiB; a total at or above that limit fails before
694
+ changing the file input.
695
+
696
+ Use multiple paths for an input with the `multiple` attribute. Use `files:[]` to clear it:
697
+
698
+ ```json
699
+ {"events":[{"type":"upload","target":{"css":"#attachments"},"files":[]}]}
700
+ ```
701
+
702
+ The target must be an `input[type=file]`. Hidden file inputs work without clicking or opening a system file chooser.
703
+ Existing element locators and `target.nth` select the input; `frame` selects a child or nested iframe in either backend. Uploads use the current
704
+ Extension or CDP connection and the selected input mode. Default precise mode supports strict CSP pages; stealth keeps
705
+ the page's CSP restrictions. Extension upload requires managed-page access, checked before any local file read.
706
+
707
+ The result summarizes the selected file names, sizes, MIME types, and dispatched events. The input receives `input`
708
+ followed by `change`, using synthetic events. Sites requiring trusted events need site-specific verification. A page
709
+ that clears the input in its `change` handler still receives the file selection; the result describes the assignment
710
+ before those handlers run.
711
+
712
+ Use `postCondition` for the site's attachment-ready or upload-complete state, and submit separately when the site
713
+ requires it. A failed post-condition preserves the completed input action. File reads, transfer, and assignment share
714
+ the input timeout and cancellation. A failure before assignment leaves the selection unchanged. An unconfirmed
715
+ assignment returns `actionStatus="unknown"` and `retryable=false`; inspect the page before deciding what to do next.
477
716
 
478
717
  ### extract - Content Extraction
479
718
 
@@ -491,41 +730,45 @@ Text extraction uses the browser's `innerText` for HTML pages and selected eleme
491
730
  `style`/`script` source and hidden descendants. Explicitly selected non-rendered HTML follows the browser's `innerText`
492
731
  rules; SVG/XML nodes use `textContent`. Use `html` for source markup.
493
732
 
494
- Parameters: `output` saves result to file (or directory for `images=data`). `images` (`info`/`data`) extracts image
495
- metadata or data alongside HTML. `frameHtml` extracts the current iframe document after `frame` routing. Screenshot
496
- accepts `clip` for coordinate-region capture, `compareWith` for PNG baseline comparison, and `diffOutput` for a PNG diff
497
- image. `diffOutput` requires `compareWith`. A `target` screenshot that has no match, whose `nth` is out of range, or
498
- whose box has zero size returns a target error rather than silently returning a viewport screenshot. Screenshot
499
- responses include `metadata.format`, `width`, `height`, `dimensionSource`, `byteSize`, `fullPage`, `scale`, `clip`, and
500
- `capabilities`. Capture is limited to 16,384 pixels per side, 12,000,000 pixels total, 48 MiB estimated RGBA memory and
501
- 25 MiB encoded data. PNG baselines are checked before reading; comparison is capped at 25 MiB per PNG and 12,000,000
502
- pixels, and decompressed scanlines must exactly match the validated dimensions and are bounded during inflate. Malformed
503
- or expansion-heavy PNGs are rejected. Use `clip` or `scale` for larger captures. Screenshot and diagnostic bundle
504
- capabilities report `hiddenTabScreenshot: false` in both Extension and CDP modes. Hidden Extension tabs return
505
- `HIDDEN_TAB_SCREENSHOT` without automatic activation. If another debugger blocks the precise screenshot path, viewport
506
- fallback reports `degraded`, `fallback`, and `limitations`; unsupported fallback options return structured
507
- `SCREENSHOT_FALLBACK_UNSUPPORTED` errors. `state` returns `interactiveElements`; `metadata` returns `frames` in both
508
- Extension and CDP modes. The document `url` is returned in both backends; Extension `frame` routing returns that iframe
509
- document's URL. CDP frame entries retain declared fields as `null` when unavailable, including DOM selectors and owner
510
- rectangles; frame-tree order and IDs are preserved. Metadata also returns the page's current `managed` state and a
511
- `metadata` object with `createdBy`, `createdAt`, `lastUsedAt`, `taskHint`, and `note`, matching `browse list` and
512
- `manage pageMetadata`. These notes describe the page even when `frame` selects an iframe document. They are local to the
513
- current Server process; unknown creation provenance stays `unknown`, and another Server does not inherit the notes. They
514
- are not cross-session ownership or permission evidence. Inline and file outputs include the same fields. `managed`
515
- describes Extension page management; CDP returns false without restricting normal operations through the CDP connection.
516
- `targetId` (or `tabId`) selects a page in either backend; `frame` is Extension-only.
733
+ #### HTML and images
734
+
735
+ `output` saves to a file, or a directory for `images=data`. `images=info|data` includes image metadata or bytes with HTML. Image data is limited to 2 MiB per image and 8 MiB per request. Directory export reads and writes one image at a time; each index entry records an `omitted` reason for unavailable or over-budget data. Inline output keeps the first 20 images with the same reasons and byte budgets. `frameHtml` reads the current document after `frame` routing.
736
+
737
+ #### Screenshots
738
+
739
+ Use `clip` for a coordinate region, `compareWith` for a PNG baseline and `diffOutput` for a PNG difference image. `diffOutput` requires `compareWith`. An unmatched, out-of-range or zero-sized target returns a target error. Responses contain `metadata.format`, `width`, `height`, `dimensionSource`, `byteSize`, `fullPage`, `scale`, `clip` and `capabilities`.
740
+
741
+ Capture limits are 16,384 pixels per side, 12,000,000 pixels total, 48 MiB estimated RGBA memory and 25 MiB encoded data. PNG baselines are checked before reading. Comparison limits each PNG to 25 MiB and 12,000,000 pixels; inflate output and scanline lengths must match the validated dimensions. Malformed or expansion-heavy PNGs are rejected. Use `clip` or `scale` for larger captures.
742
+
743
+ Screenshot and diagnostic-bundle capabilities report `hiddenTabScreenshot=false` in both backends. A hidden Extension tab returns `HIDDEN_TAB_SCREENSHOT`. Full-page capture preserves viewport and device emulation. If another debugger blocks precise capture, viewport fallback reports `metadata.degraded`, `metadata.fallback` and `metadata.limitations` in inline and file output. A window-level capture is discarded when the active tab changes, including A-to-B-to-A. Unsupported fallback options return `SCREENSHOT_FALLBACK_UNSUPPORTED`.
744
+
745
+ #### State and metadata
746
+
747
+ `state` returns `interactiveElements`. Both backends return metadata `frames` and the actual document `url`; Extension `frame` routing returns the selected document's URL. Unavailable declared CDP frame fields remain `null`, including DOM selectors and owner rectangles. Frame-tree order and IDs are preserved.
748
+
749
+ Metadata includes current `managed` state and `createdBy`, `createdAt`, `lastUsedAt`, `taskHint` and `note`, matching `browse list` and `manage pageMetadata` in both inline and file output. Notes belong to the page even when `frame` selects an iframe document. Extension preserves creation records, notes and trusted group relationships across Server and Extension reloads, checking live identity during restoration. CDP notes belong to the current Server process. Unknown provenance stays `unknown`; notes grant no access or cross-session ownership. CDP returns `managed=false` while retaining normal operations through its connection.
750
+
751
+ Page selection uses `targetId` or legacy `tabId`; `frame` selects a child or nested document in either backend.
517
752
 
518
753
  **`attribute` special prefix**: `computed:<property>` returns the computed CSS style value (e.g. `computed:color`,
519
754
  `computed:font-size`). Use `computed:*` to return all computed style properties as JSON (returns 300+ properties — use
520
755
  `output` to save to file).
521
756
 
757
+ `extract.timeout` is the overall browser-operation budget in milliseconds (default 30000), including queueing,
758
+ page/frame preparation, target waiting, content reads, and page-context metadata. Each RPC uses the remaining budget;
759
+ `state` does not start a separate 30-second wait. An unconfirmed dispatched request returns unknown and is not replayed.
760
+
522
761
  **`state`-specific**: `depth` controls accessibility-tree traversal depth (default 15). Reduce it to limit response size
523
762
  on large pages. `mode` selects `accessibility` (default, derived from the a11y tree) or `domsnapshot` (raw
524
763
  `DOMSnapshot.captureSnapshot`, available through CDP or a managed Extension page). DOMSnapshot captures the whole page
525
- and rejects `target`, `frame`, and `depth` instead of ignoring those limits. Ordinary read grants do not grant debugger
526
- access. Unavailable sibling iframe probes are listed in metadata as `unavailableFrames` and per-frame
764
+ and rejects `target`, `frame`, and `depth`. Ordinary read grants cover accessibility state; Extension DOMSnapshot requires full managed access to use the debugger.
765
+ Unavailable sibling iframe probes are listed in metadata as `unavailableFrames` and per-frame
527
766
  `unavailableReason`; a uniquely verified selected iframe remains usable.
528
767
 
768
+ `target` restricts accessibility state to the selected element and its descendants in both backends. `depth` is relative to that subtree.
769
+
770
+ Accessibility state does not read hidden/password/file input value getters for element names or state text, including default `all`, subtrees and file output. Hidden controls retain their labels and `visible=false`. Labels, placeholders and titles provide names; ordinary inputs retain current values separately in `value` and `pageContent`, including named inputs. Submit labels retain their full text. Explicit script, HTML and attribute reads keep their existing behavior.
771
+
529
772
  ### wait - Wait for Conditions
530
773
 
531
774
  | For | Description |
@@ -535,7 +778,7 @@ access. Unavailable sibling iframe probes are listed in metadata as `unavailable
535
778
  | `time` | Fixed delay |
536
779
  | `idle` | Wait for DOM or network quiet period |
537
780
 
538
- Parameters: `targetId` (or `tabId`) selects a page in either backend; `frame` selects an iframe in Extension mode.
781
+ Parameters: `targetId` (or `tabId`) selects a page in either backend; `frame` selects a child document or nested path in either backend.
539
782
 
540
783
  In CDP mode, `visible` requires a nonzero DOM rectangle and CSS that does not hide the element (`display:none` or
541
784
  `visibility:hidden/collapse`). `hidden` accepts these hidden states or a missing element; `attached` and `detached` only
@@ -545,23 +788,23 @@ check whether the element exists.
545
788
  a quiet period with no DOM changes. In CDP mode, it waits for network quiet instead. `ms` controls the relevant quiet
546
789
  period (default 500ms). The response returns `idleKind` and `idlePeriodMs`; Extension responses also return `domStable`.
547
790
 
791
+ CDP idle includes requests already in flight. Independent idle and same-document `networkidle` exclude Worker requests with an empty `loaderId`, whose terminal events can be absent from the page session; page Fetch and Script requests remain pending until completion.
792
+
548
793
  ### evaluate - JavaScript Execution
549
794
 
550
795
  Execute JavaScript in page context.
551
796
 
552
- | Parameter | Description |
553
- | -------------------- | --------------------------------------------------------------------------------------------------- |
554
- | `script` | JavaScript code. Bare `return` statements are wrapped in IIFE |
555
- | `scriptFile` | Read code from a local file instead of `script` |
556
- | `args` | Function arguments; `[]` invokes a zero-argument function, omission evaluates the script as written |
557
- | `mode` | `precise` (default, debugger API) or `stealth` (JS injection) |
558
- | `staleContextRetry` | iframe stale-context policy: `never` (default) or `readOnly` |
559
- | `output` | Save the result to a file |
560
- | `targetId` / `tabId` | Select a page in either backend (`tabId` is an alias) |
561
- | `frame` | Target an iframe by CSS selector or index (Extension mode) |
562
- | `timeout` | End-to-end budget (ms) |
563
- | `diagnostics` | Return new console warnings/errors and failed requests after execution |
564
- | `postCondition` | Wait for text, selector, URL fragment, or script result after execution |
797
+ - `script`: JavaScript code. Bare `return` statements are wrapped in IIFE
798
+ - `scriptFile`: Read code from a local file instead of `script`
799
+ - `args`: Function arguments; `[]` invokes a zero-argument function, omission evaluates the script as written
800
+ - `mode`: `precise` (default, debugger API) or `stealth` (JS injection)
801
+ - `staleContextRetry`: iframe stale-context policy: `never` (default) or `readOnly`
802
+ - `output`: Save the result to a file
803
+ - `targetId` / `tabId`: Select a page in either backend (`tabId` is an alias)
804
+ - `frame`: Target a child iframe by CSS selector/index, or use a nested path such as `["#outer", 0]` in either backend
805
+ - `timeout`: End-to-end budget (ms)
806
+ - `diagnostics`: Return new console warnings/errors and failed requests after execution
807
+ - `postCondition`: Wait for text, selector, URL fragment, or script result after execution
565
808
 
566
809
  `script` and `scriptFile` are mutually exclusive; at least one must be provided. Relative `scriptFile` and `output`
567
810
  paths default to the OS temp directory managed by `mcp-chrome`. Use `cwd:relative/path` when the file must live in the
@@ -574,14 +817,17 @@ such as `textContent` or `outerHTML`. Result materialization and serialization f
574
817
  `actionStatus="completed"`, and `failureStage="output"` because the page script has already finished. Evaluate defaults
575
818
  to `precise` even when global `inputMode` is `stealth`, and its `postCondition` checks use the same evaluate mode as the
576
819
  action. `postCondition` is optional; when it is not provided, `success=true` only means the script executed and
577
- returned. When it is provided and does not match before timeout, the tool returns `POST_CONDITION_FAILED` with the last
578
- observed checks. Precise iframe evaluation does not replay a script after a stale execution context by default. Set
820
+ returned. With a post-condition, `verificationStatus` distinguishes `matched`, `not_matched`, `unavailable` and `error`, with the last observed checks. A completed script keeps `actionStatus="completed"` and top-level `retryable=false`; `postCondition.retryable` applies only to an independent verification read. Precise iframe evaluation does not replay a script after a stale execution context by default. Set
579
821
  `staleContextRetry="readOnly"` only when the script has no side effects; the Extension may then resolve a new context
580
822
  and replay it once within the remaining timeout budget. If Chrome still reports the removed document while resolving
581
823
  that retry, the Extension waits for the current document within the same budget; this does not add script executions.
582
- Permission failures stop immediately. A stale-context error after `Runtime.evaluate` reports `actionExecuted=true` and
583
- `actionStatus="unknown"`, because earlier side effects may already have happened even though the final result is
584
- unavailable.
824
+ Permission failures stop immediately. CDP iframe execution supports `never`; requesting `readOnly` returns
825
+ `DRIVER_CAPABILITY_ERROR` with `actionExecuted=false` and `actionStatus="not_started"` before script dispatch.
826
+ A stale-context error after `Runtime.evaluate` reports `actionExecuted=true`, `actionStatus="unknown"` and
827
+ `retryable=false` in both backends, because earlier side effects may already have happened even though the final
828
+ result is unavailable. CDP preserves its native `CDP_ERROR`.
829
+
830
+ The total evaluate timeout also limits post-condition checks. If it expires after the action completes, the action stays completed and verification returns unavailable. A queue timeout before script dispatch preserves `actionExecuted=false` and the queue stage; a dispatched script with an unknown acknowledgement stays unknown. Read the page independently to determine its effects.
585
831
 
586
832
  For object results in the main frame with Extension precise mode, an explicit `output` uses a 16 Mi (16777216) character
587
833
  budget. Without `output`, the 1000000-character budget still applies, including automatic saving. Both paths retain the
@@ -589,39 +835,52 @@ depth limit of 8, the 2000-node budget, and non-serializable result rejection. T
589
835
  units, not the output file's UTF-8 bytes; `tmp:` files also remain subject to the temporary output quota. Exceeding a
590
836
  result limit reports the current limit and the completed script's output failure without replaying it.
591
837
 
838
+ Absolute `scriptFile` and `output` paths must resolve inside the Server working directory or this Server session's controlled temporary directory. The operating system's whole temp directory and Downloads are not automatic allowed roots. `PATH_NOT_ALLOWED` reports the actual `error.context.allowedRoots`; use `cwd:` or `tmp:` paths within them.
839
+
840
+ Responses include the stale-context policy, `retryAttempted`, bounded `retryReason` and the final `frameContext`: Extension frame, parent frame, URL, CDP frame and execution-context IDs. Same-URL frames are rejected only when the selected DOM iframe cannot identify one target. Existing iframe targets remain usable after an Extension reload without refreshing or navigating the page. Invalidated probe contexts report a warning and stop listening.
841
+
842
+ Sibling frames still loading do not delay selection of an available iframe. Background-page timer throttling does not extend the frame-probe wait. Cancellation or timeout before script dispatch releases the probes and leaves that script unexecuted.
843
+
844
+ A trusted Function-compilation policy rejection reports `CSP_BLOCKED` with the script not executed. Page `throw` or Promise rejection keeps its original error and executed state even when the text contains `CSP`, `Content Security Policy` or `unsafe-eval`.
845
+
592
846
  ### manage - Page & Environment Management
593
847
 
594
- | Action | Description |
595
- | ------------------ | ----------------------------------------------------------------- |
596
- | `newPage` | Create new controlled page/tab |
597
- | `pageMetadata` | Read or update per-page `taskHint` and `note` |
598
- | `closePage` | Close controlled page and return `affected.before/after` |
599
- | `adoptPage` | Grant full controlled-page access without focusing it |
600
- | `releasePage` | Remove a controlled tab from management without closing it |
601
- | `grantReadAccess` | Grant ordinary reads for an explicit page to the calling instance |
602
- | `revokeReadAccess` | Revoke that instance's ordinary read grant |
603
- | `updatePage` | Update native tab properties and return actual state |
604
- | `movePage` | Move a controlled tab to another window or index |
605
- | `reorderPage` | Reorder a controlled tab inside its window |
606
- | `pinPage` | Pin a controlled tab |
607
- | `unpinPage` | Unpin a controlled tab |
608
- | `activatePage` | Activate an explicit page; Extension requires a controlled tab |
609
- | `focusWindow` | Focus an explicit window |
610
- | `resizeWindow` | Resize or change state for an explicit window |
611
- | `newWindow` | Create a new controlled window |
612
- | `closeWindow` | Close a window only when all tabs are managed |
613
- | `updateWindow` | Update native window position, state, focus or attention |
614
- | `groupPages` | Create a group or add controlled tabs to an existing group |
615
- | `ungroupPages` | Remove controlled tabs from groups without releasing them |
616
- | `updateGroup` | Update group title, color and collapsed state |
617
- | `moveGroup` | Move a group and its tabs to a window or index |
618
- | `clearCache` | Clear cache/storage (use `cookies` tool to clear cookies) |
619
- | `viewport` | Set viewport size |
620
- | `userAgent` | Set User-Agent |
621
- | `emulate` | Device emulation (iPhone, iPad, etc.) |
622
- | `inputMode` | Query or set input mode (`precise` / `stealth`) |
623
- | `stealth` | Inject anti-detection scripts |
624
- | `cdp` | Send raw CDP command (advanced, e.g. `Runtime.evaluate`) |
848
+ | Action | Description |
849
+ | ------------------ | ------------------------------------------------------------------------ |
850
+ | `newPage` | Create new controlled page/tab |
851
+ | `pageMetadata` | Read or update per-page `taskHint` and `note` |
852
+ | `closePage` | Close page and return `affected.before/after` in Extension and CDP modes |
853
+ | `adoptPage` | Grant full controlled-page access without focusing it |
854
+ | `releasePage` | Remove a controlled tab from management without closing it |
855
+ | `grantReadAccess` | Grant ordinary reads for an explicit page to the calling instance |
856
+ | `revokeReadAccess` | Revoke that instance's ordinary read grant |
857
+ | `updatePage` | Update native tab properties and return actual state |
858
+ | `movePage` | Move a controlled tab to another window or index |
859
+ | `reorderPage` | Reorder a controlled tab inside its window |
860
+ | `pinPage` | Pin a controlled tab |
861
+ | `unpinPage` | Unpin a controlled tab |
862
+ | `activatePage` | Activate an explicit page; Extension requires a controlled tab |
863
+ | `focusWindow` | Focus an explicit window |
864
+ | `resizeWindow` | Resize or change state for an explicit window |
865
+ | `newWindow` | Create a new controlled window |
866
+ | `closeWindow` | Close a window only when all tabs are managed |
867
+ | `updateWindow` | Update native window position, state, focus or attention |
868
+ | `groupPages` | Create a group or add controlled tabs to an existing group |
869
+ | `ungroupPages` | Remove controlled tabs from groups without releasing them |
870
+ | `updateGroup` | Update group title, color and collapsed state |
871
+ | `moveGroup` | Move a group and its tabs to a window or index |
872
+ | `clearCache` | Clear cache/storage (use `cookies` tool to clear cookies) |
873
+ | `viewport` | Set viewport size |
874
+ | `userAgent` | Set User-Agent |
875
+ | `emulate` | Device emulation (iPhone, iPad, etc.) |
876
+ | `inputMode` | Query or set input mode (`precise` / `stealth`) |
877
+ | `stealth` | Inject anti-detection scripts |
878
+ | `cdp` | Send raw CDP command (advanced, e.g. `Runtime.evaluate`) |
879
+ | `dialog` | Observe or handle dialogs |
880
+ | `networkCapture` | Start or stop original request/body/stream collection |
881
+ | `route` | Match and resolve paused requests |
882
+ | `httpAuth` | Set or clear scoped HTTP challenge credentials |
883
+ | `download` | Observe, wait for, and save an original download |
625
884
 
626
885
  Native tab/window/group configuration uses Extension mode; `activatePage` also supports CDP. Mutations identify their
627
886
  existing targets with `targetId`, `targetIds`, `windowId`, or `groupId` and return `affected.before/after`. Group
@@ -629,8 +888,9 @@ results also include `tabsBefore/tabsAfter`; `ungroupPages` removes an empty gro
629
888
  tabs' managed state. Window display changes and group title/color/collapse updates use the explicit `windowId` or
630
889
  `groupId`, including containers with unmanaged members. They do not grant page permissions. Group moves and window
631
890
  closure still require every affected member to be managed. Grouping or ungrouping selected pages checks those pages;
632
- unrelated sibling changes do not invalidate a valid selection. Default page creation reuses a valid cached MCP window
633
- even when it contains unmanaged tabs. `clearCache` is unavailable in Extension mode and returns `UNSUPPORTED_MODE`
891
+ unrelated sibling changes do not invalidate a valid selection. Default page creation uses an existing normal
892
+ window in the background, including windows with unmanaged tabs. `clearCache` is unavailable in Extension mode
893
+ and returns `UNSUPPORTED_MODE`
634
894
  without clearing anything. Use scoped `cookies(action="clear")` for cookies or CDP mode for storage and cache.
635
895
  `focusWindow` only returns success after the target window is observed as focused; otherwise it returns
636
896
  `WINDOW_FOCUS_NOT_OBSERVED`. `closeWindow` refuses mixed windows with unmanaged tabs and returns
@@ -645,22 +905,66 @@ restrictions. Querying `manage(action="emulate")` without `device` returns the l
645
905
  page; page conditions are rejected for this query. Setting a device continues to validate the selected page and
646
906
  conditions.
647
907
 
648
- | Action | Native parameters | Behavior |
649
- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
650
- | `newPage` | `url`, `windowId`, `index`, `active`, `pinned`, `openerTabId`, `groupId`, `timeout` | `active` defaults to false; `groupId=-1` disables grouping; explicit placement is not changed by the default visual group |
651
- | `updatePage` | `url`, `active`, `pinned`, `highlighted`, `muted`, `autoDiscardable`, `openerTabId` | Requires `targetId`; only `active=true` is supported and does not focus the window; `active=false` is rejected before any update |
652
- | `groupPages` | `targetIds`, `groupId`, `windowId`, `title`, `color`, `collapsed` | Omit `groupId` to create a group in the members' window; mixed-window members require `windowId`; joining an existing group accepts only `targetIds/groupId` |
653
- | `ungroupPages` | `targetIds` | Removes group membership and retains controlled-page access |
654
- | `updateGroup` | `groupId`, `title`, `color`, `collapsed` | An empty title and false collapsed value are applied as supplied |
655
- | `moveGroup` | `groupId`, `windowId`, `index` | Moves all members; `index=-1` means the end of the window |
656
- | `newWindow` | `url` or `urls`, `targetId`, `windowType`, `focused`, `incognito`, `left`, `top`, `width`, `height`, `windowState`, `setSelfAsOpener` | `normal` supports multiple URL tabs and an existing controlled tab; `popup` accepts only one page; created tabs are managed with distinct provenance |
657
- | `updateWindow` / `resizeWindow` | `windowId`, `left`, `top`, `width`, `height`, `windowState`, `focused`, `drawAttention` | Applies supported Chrome window properties and returns observed state |
908
+ #### `newPage`
909
+
910
+ Parameters: `url`, `windowId`, `index`, `active`, `pinned`, `openerTabId`, `groupId`, `timeout`, `taskHint`,
911
+ `note`
912
+
913
+ `active` defaults to false; `groupId=-1` disables grouping; explicit placement is not changed by the default
914
+ visual group
915
+
916
+ #### `updatePage`
917
+
918
+ Parameters: `url`, `active`, `pinned`, `highlighted`, `muted`, `autoDiscardable`, `openerTabId`
919
+
920
+ Requires `targetId`; only `active=true` is supported and does not focus the window; `active=false` is rejected
921
+ before any update
922
+
923
+ #### `groupPages`
924
+
925
+ Parameters: `targetIds`, `groupId`, `windowId`, `title`, `color`, `collapsed`
926
+
927
+ Omit `groupId` to create a group in the members' window; mixed-window members require `windowId`; joining an
928
+ existing group accepts only `targetIds/groupId`
929
+
930
+ #### `ungroupPages`
931
+
932
+ Parameters: `targetIds`
933
+
934
+ Removes group membership and retains controlled-page access
935
+
936
+ #### `updateGroup`
937
+
938
+ Parameters: `groupId`, `title`, `color`, `collapsed`
939
+
940
+ An empty title and false collapsed value are applied as supplied
941
+
942
+ #### `moveGroup`
943
+
944
+ Parameters: `groupId`, `windowId`, `index`
945
+
946
+ Moves all members; `index=-1` means the end of the window
947
+
948
+ #### `newWindow`
949
+
950
+ Parameters: `url` or `urls`, `targetId`, `windowType`, `focused`, `incognito`, `left`, `top`, `width`,
951
+ `height`, `windowState`, `setSelfAsOpener`
952
+
953
+ `normal` supports multiple URL tabs and an existing controlled tab; `popup` accepts only one page; created
954
+ tabs are managed with distinct provenance
955
+
956
+ #### `updateWindow` / `resizeWindow`
957
+
958
+ Parameters: `windowId`, `left`, `top`, `width`, `height`, `windowState`, `focused`, `drawAttention`
959
+
960
+ Applies supported Chrome window properties and returns observed state
658
961
 
659
962
  `updateWindow` and `resizeWindow` wait for a stable browser observation when changing state or geometry. Restoring a
660
963
  non-normal window with `windowState="normal"` and bounds completes the state transition before applying bounds once.
661
964
  OS-adjusted geometry is returned as observed. If observation does not stabilize within the bounded wait,
662
965
  `WINDOW_UPDATE_NOT_OBSERVED` reports partial execution and the last observed window state; inspect `browse list` before
663
- another update.
966
+ another update. If Chrome rejects bounds outside visible screen space, use coordinates and dimensions within the
967
+ screen's available area; the response preserves the bounds error without page-activation guidance.
664
968
 
665
969
  `browse list` defaults to `details="summary"`, returning target identity, URL/title, placement, managed/revision and
666
970
  metadata. Set `details="full"` for highlighted/muted/discardable state, opener IDs and available native readonly
@@ -672,9 +976,9 @@ state, window, first-member index and member IDs. Color belongs to a group, not
672
976
  when Chrome supplies them, not accepted as configuration writes. Listing does not read page content, navigate or focus.
673
977
 
674
978
  Older Extensions that return group summaries without member arrays use the same response's window/tab membership to
675
- populate group members and first-member index. Summary/full details and filters remain available without another RPC.
676
- If group information is absent entirely, `groups` is omitted with a warning that it is unavailable. A supplied
677
- `groups: []` means no groups. Malformed group data, including only one member array, returns an error.
979
+ populate group members and first-member index. Summary/full details and filters remain available without another RPC. If
980
+ group information is absent entirely, `groups` is omitted with a warning that it is unavailable. A supplied `groups: []`
981
+ means no groups. Malformed group data, including only one member array, returns an error.
678
982
 
679
983
  Moving tabs/groups accepts `index=-1`; page creation requires a nonnegative index. Opener and explicit group/window
680
984
  options must identify the same window. Pinned tabs cannot be created inside a group. Window state/bounds conflicts and
@@ -693,17 +997,115 @@ restores desktop metrics, page scale, and disabled touch emulation; restore the
693
997
  - `safe` (default) — minimal patches (remove `navigator.webdriver`, clean CDP traces)
694
998
  - `aggressive` — adds a few WebGL/plugin/language fingerprint patches (does NOT equal full masking)
695
999
 
1000
+ Management operations share a 30000 ms request deadline; `newPage` uses a supplied `timeout`. An expired queued change is rejected before dispatch. Unconditional `pageMetadata` reads, updates and clears use the explicit target independently of a long page action, including on the same page. Each request keeps its own URL/revision conditions. URL/revision-conditioned metadata keeps serialized condition checking.
1001
+
1002
+ Group operations serialize with page release and recheck native membership and managed authority under the affected page locks. Page creation uses `active`; `activate` is accepted only by `movePage`.
1003
+
1004
+ ### Browser events and original files
1005
+
1006
+ Prepare observation before clicking a download link, opening a dialog, or making a request. Use the returned `ref` to
1007
+ read or handle that exact event. These actions use the controlled page selected by `targetId` or the current default.
1008
+ A reference retains its original page even after the default target changes.
1009
+
1010
+ | `manage` action | Nested command | Result |
1011
+ | ---------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------- |
1012
+ | `dialog` | `dialog:{op:"watch"\|"stop"\|"accept"\|"dismiss",ref?,text?}` | Observe dialogs or handle one observed dialog; `text` supplies a prompt answer |
1013
+ | `networkCapture` | `capture:{op:"start"\|"stop",include?:["body","stream"]}` | Record original requests, optional bodies, and WebSocket/SSE messages |
1014
+ | `route` | `route:{op:"add"\|"remove"\|"continue"\|"fulfill"\|"fail",...}` | Match page requests or handle an observed paused request |
1015
+ | `httpAuth` | `auth:{op:"set"\|"clear",...}` | Configure credentials for an explicit Server/Proxy challenge scope |
1016
+ | `download` | `download:{op:"watch"\|"stop"\|"wait"\|"save",...}` | Identify a download, wait for its native state, and save available original bytes |
1017
+
1018
+ #### Handle a dialog
1019
+
1020
+ ```text
1021
+ manage(action="dialog", targetId="PAGE_ID", dialog={op:"watch"})
1022
+ input(targetId="PAGE_ID", events=[{type:"click", target:{css:"#show-prompt"}}])
1023
+ logs(type="dialog", targetId="PAGE_ID")
1024
+ manage(action="dialog", dialog={op:"accept", ref:"DIALOG_REF", text:"Answer"})
1025
+ ```
1026
+
1027
+ A blocking dialog returns `DIALOG_OPEN` and its reference. Handle it, then check the original action's result. Dialog
1028
+ reads and handling remain available while that original request is blocked. `dismiss` omits `text`; `stop` ends
1029
+ observation. Log reads leave the dialog unchanged.
1030
+
1031
+ #### Read the original response
1032
+
1033
+ ```text
1034
+ manage(action="networkCapture", targetId="PAGE_ID", capture={op:"start", include:["body","stream"]})
1035
+ logs(type="network", targetId="PAGE_ID", view="details")
1036
+ logs(type="network", view="responseBody", ref="REQUEST_REF", output="tmp:response.bin")
1037
+ ```
1038
+
1039
+ `details` retains request identity, redirect hop, base headers, ExtraInfo headers, and their completeness.
1040
+ `requestBody` reads original POST data; `responseBody` reads the protocol-provided entity body. An explicit `output`
1041
+ saves decoded bytes. Inline bodies use `{encoding:"utf8"|"base64",data}`. Unavailable or evicted bodies return an
1042
+ error; multipart file parts and redirect bodies depend on native protocol availability. A body must be below 16 MiB.
1043
+ Headers, Cookie metadata copies such as `cookieLine`, and credential URL fields are redacted. URL-bearing headers such as `Location`, `Content-Location` and `Referer` also redact user information and sensitive query values in structured metadata and raw handshake header text; explicitly requested body content retains its bytes.
1044
+
1045
+ `view="stream"` returns WebSocket directions/opcodes and SSE messages in observed order. Inspect truncation, `dropped`
1046
+ and `evicted` fields when consuming bounded buffers. Use `capture:{op:"stop"}` to end collection.
1047
+
1048
+ #### Continue or mock a matched request
1049
+
1050
+ Add a route with `urlPattern` and optional `stage:"Request"|"Response"`. Read `logs(type="network",view="paused")`,
1051
+ then handle the returned paused-request reference:
1052
+
1053
+ ```text
1054
+ manage(action="route", targetId="PAGE_ID", route={op:"add", urlPattern:"https://example.com/api/*"})
1055
+ logs(type="network", targetId="PAGE_ID", view="paused")
1056
+ manage(action="route", route={op:"fulfill", ref:"PAUSED_REF", response:{status:200, body:{encoding:"utf8",data:"mock"}}})
1057
+ ```
1058
+
1059
+ `continue` accepts optional `request:{url?,method?,headers?,body?}`; headers are `{name,value}` arrays. `fulfill`
1060
+ requires `response:{status,statusText?,headers?,body?}`. `fail` accepts a native `errorReason`, defaulting to `Aborted`.
1061
+ Remove a rule with `op:"remove"` and its rule reference. Unmatched requests continue immediately. Matched pauses expire
1062
+ after 30 seconds; cancellation, navigation, release or owner disconnection aborts unresolved requests. A native
1063
+ acknowledgement loss retains an unknown result and is not automatically resent. `clear` clears readable records while
1064
+ active pauses and dialogs keep their handling references. Raw `manage cdp` Fetch commands share this ownership and cleanup.
1065
+
1066
+ For HTTP authentication, set `auth:{op:"set",scope:{source:"Server"|"Proxy",origin,realm?},username,password}`.
1067
+ Credentials stay in memory for that page and exact challenge scope. Failed repeat challenges are canceled. Read
1068
+ `logs(type="network",view="auth")` for redacted status, and use `auth:{op:"clear"}` to remove credentials.
1069
+
1070
+ #### Save a download
1071
+
1072
+ ```text
1073
+ manage(action="download", targetId="PAGE_ID", download={op:"watch",urlPattern:"https://example.com/files/*"})
1074
+ input(targetId="PAGE_ID", events=[{type:"click",target:{css:"a.download"}}])
1075
+ logs(type="download", targetId="PAGE_ID")
1076
+ manage(action="download", download={op:"wait",ref:"DOWNLOAD_REF",timeout:30000})
1077
+ manage(action="download", download={op:"save",ref:"DOWNLOAD_REF",output:"tmp:attachment.bin"})
1078
+ ```
1079
+
1080
+ The native download GUID and state distinguish completion from file availability. `save` requires a completed download
1081
+ with `artifact="available"`; it writes the captured original response without making another HTTP request. Native Save
1082
+ As, blob downloads or browser security restrictions can leave the file unavailable, with the reason reported.
1083
+ Shared-browser download policy remains unchanged. This capture path uses the same below-16-MiB body budget.
1084
+ `download:{op:"stop"}` ends observation and releases its interception.
1085
+
1086
+ References are bound to the server instance, page and connection generation. Stale or foreign references are rejected.
1087
+ Cloudflare handling ends current Fetch control and suspends these observations before detaching the debugger; inspect
1088
+ the returned `browserEvents` status and explicitly start observation again after verification. New event actions require
1089
+ matching Server and Extension builds; missing native capabilities are reported before enabling interception.
1090
+ CDP authentication and response capture remain active after the connection request finishes. Each later tool call uses its own timeout and cancellation signal.
1091
+
1092
+ `cleanupFailures` retains the existing string array. The parallel `cleanupFailureDetails` records timestamp, phase, observed ref or request ID, target, owner and session generation. Each controller retains at most 20 failures and clears them when disposed. A new controller starts empty; details already returned retain their original ownership.
1093
+
696
1094
  ### logs - Browser Logs
697
1095
 
698
- | Type | Description |
699
- | --------- | -------------------------------------- |
700
- | `console` | Console logs (with level filter) |
701
- | `network` | Network request logs (with URL filter) |
1096
+ | Type | Description |
1097
+ | ---------- | -------------------------------------------------------------------------- |
1098
+ | `console` | Console logs (with level filter) |
1099
+ | `network` | Request summary, details, bodies, paused requests, auth or stream messages |
1100
+ | `dialog` | Observed dialog references and pending/closed state |
1101
+ | `download` | Native download state and original-file availability |
702
1102
 
703
1103
  Parameters: `output` saves result to file. Console entries use the public levels `error`, `warning`, `info`, and
704
1104
  `debug`; raw browser levels such as `warn` and `log` are normalized before filtering and return. Clearing fallback
705
1105
  console logs keeps the hook active. When debugger collection becomes available, fallback capture is disabled. Console
706
1106
  methods still pointing to the MCP wrapper are restored, while wrappers installed later by the page are preserved.
1107
+ Independent fallback console calls retain their levels and frequency even when their timestamp and text are identical;
1108
+ reading the same drained batch again does not append it again. Switching to debugger collection preserves pending calls once, without adding their Runtime history replay a second time or restoring cleared fallback calls. The buffer retains the latest 1000 entries.
707
1109
  Network logs are finalized on `loadingFinished` or `loadingFailed`, not when headers arrive, so body failures retain
708
1110
  both the HTTP status and `errorText`, and in-flight bodies continue to count against `networkidle`. Entries include
709
1111
  `method`, `url`, `status`, `timestamp`, and `duration` when available. URL query parameters commonly used for
@@ -712,6 +1114,7 @@ explicit `output` files. Redacted entries include `urlRedacted`, `urlOriginalLen
712
1114
  Inline network results limit each sanitized URL to 2048 characters and add `urlLength` plus `urlTruncated: true` when
713
1115
  shortened. `urlPattern` supports `*` for any number of characters and `?` for one character. `tabId` targets a specific
714
1116
  tab (Extension mode). `frame` is not applicable for logs.
1117
+ In network views, `urlPattern` filters each request's URL, including paused requests and authentication events, before applying `limit`. `clear` preserves requests that still need handling.
715
1118
 
716
1119
  When the Extension debugger is unavailable, network reads refresh performance entries and mark them with
717
1120
  `source="performance"`. Status uses the browser's `responseStatus` when available, or `0` otherwise; unknown request
@@ -719,6 +1122,8 @@ methods remain empty. Repeated reads preserve record sequences. `clear` clears M
719
1122
  document's read boundary without clearing the page's shared performance timeline. A new document starts a new boundary.
720
1123
  Read failures return an error rather than an empty log.
721
1124
 
1125
+ CDP network logs keep the HTTP status when a response body fails and record one terminal entry per request. Temporary page selection preserves each target's log buffer. Clearing logs removes buffered entries while keeping in-flight requests until their final event, so a request completed after clearing appears in the new log.
1126
+
722
1127
  ### cookies - Cookie Management
723
1128
 
724
1129
  | Action | Description |
@@ -728,54 +1133,22 @@ Read failures return an error rather than an empty log.
728
1133
  | `delete` | Delete cookie |
729
1134
  | `clear` | Delete cookies in a URL or domain scope, optionally narrowed by `name` |
730
1135
 
731
- **Note**: `clear` requires `url` or `domain`. `name` can only further narrow that scope, so a same-named cookie on
732
- another site cannot be removed accidentally. The returned `count` includes only cookies for which Chrome confirms a
733
- removal; cookies that disappear between listing and removal are not counted.
734
-
735
- ## Target: Unified Element Locator
736
-
737
- All tools use a unified `Target` type for element location:
738
-
739
- ```typescript
740
- // By accessibility (recommended - most stable)
741
- const byRole = { role: 'button', name: 'Submit' }
742
-
743
- // By accessibility with exact accessible name
744
- const byExactRole = { role: 'button', name: 'Submit', exact: true }
745
-
746
- // By text content
747
- const byText = { text: 'Click here', exact: true }
748
-
749
- // By form label
750
- const byLabel = { label: 'Email' }
751
-
752
- // By placeholder
753
- const byPlaceholder = { placeholder: 'Enter your name' }
1136
+ All actions accept `targetId`, `partitionKey:{topLevelSite?,hasCrossSiteAncestor?}`, and a backend-specific store scope:
1137
+ `storeId` for Extension or `browserContextId` for CDP. Extension resolves a supplied target to its native CookieStore
1138
+ and rejects a conflicting store. Unsupported backend scope fields return an error. Without these fields, existing
1139
+ URL/domain behavior remains unchanged. `get` requires at least one nonblank `name`, `domain`, or `url`; storage scopes and flags only narrow that explicit filter, including when exporting to a file.
754
1140
 
755
- // By title attribute
756
- const byTitle = { title: 'Close dialog' }
757
-
758
- // By alt text (images)
759
- const byAlt = { alt: 'Profile picture' }
1141
+ URL path matching uses Cookie path boundaries in target and browser-context scopes too: a Cookie at `/app` matches `/app/info` and is excluded for `/apple/info`.
760
1142
 
761
- // By test ID
762
- const byTestId = { testId: 'submit-button' }
1143
+ `clear` requires `url` or `domain`, with optional `name` to narrow the range. CDP preserves each selected Cookie's exact name, raw domain, path, partition and browser context for deletion. An omitted target is fixed to the current page's storage context when clear starts. An unserializable partition identity is rejected before deletion.
763
1144
 
764
- // By CSS selector
765
- const byCss = { css: '#login-form .submit-btn' }
1145
+ For CDP clear, `count` records identities present at the immediate precheck and absent after an acknowledged deletion request; `countSemantics="observed_present_then_absent"` identifies this state comparison. `acknowledged` counts native ACKs, `alreadyAbsent` counts identities missing at the precheck, and `matched` and `attempted` describe the selected candidates and started deletion steps. Concurrent page changes can occur between observations. Extension retains its native removal-confirmation count.
766
1146
 
767
- // Disambiguate multiple matches (0-based)
768
- const secondMatch = { css: '.ant-select-input', nth: 1 }
1147
+ CDP stops at the first deletion, verification or cleanup failure and returns `COOKIE_CLEAR_PARTIAL` with the known count, ACKs, failed or unknown steps, unprocessed candidates, phase and original cause. Its action state preserves earlier changes and `retryable=false`; a session-detach failure retains the preceding ACK and any verified disappearance.
769
1148
 
770
- // By CSS + text (filter by text content)
771
- const byCssText = { css: 'button', text: 'Submit', exact: true }
1149
+ A delete sent without an ACK counts as `unknown` when the connection closes, is explicitly closed, times out or is cancelled. The first unknown step reports `actionStatus="unknown"`; earlier ACKs keep the action `partial`. `failed` counts explicitly rejected or undispatched deletion steps and identities still present after an ACK. Unclassified errors after a deletion attempt remain unknown, and later deletions stop.
772
1150
 
773
- // By XPath
774
- const byXPath = { xpath: "//button[@type='submit']" }
775
-
776
- // By coordinates
777
- const byCoordinates = { x: 100, y: 200 }
778
- ```
1151
+ MCP cancellation stops queued Cookie actions, connection waits and later deletions in both backends. CDP retains prior confirmed progress and an unacknowledged deletion's unknown result. A cancelled or timed-out temporary attach retains responsibility for its native response: a late successful session is detached with an independent 1000 ms budget. Cleanup failure is logged with the command and session identity and remains tracked until the connection closes; no deletion is replayed. An Extension RPC cancelled before its reply reports an unknown RPC result; the Extension stops its remaining native removals once the in-flight call settles.
779
1152
 
780
1153
  ## Usage Examples
781
1154
 
@@ -869,7 +1242,9 @@ subsequent output.
869
1242
  extract(type="metadata")
870
1243
  ```
871
1244
 
872
- ### iframe Operations (Extension Mode)
1245
+ ### Nested frame operations
1246
+
1247
+ Both backends resolve iframe selectors and indices through open ShadowRoots. Cross-origin and OOPIF frame preparation uses the original request deadline; a timeout before script dispatch reports `actionExecuted=false` and `actionStatus="not_started"` and attempts to restore the previous target.
873
1248
 
874
1249
  ```
875
1250
  // Target iframe by CSS selector
@@ -878,6 +1253,9 @@ evaluate(script="document.title", frame="iframe#main")
878
1253
  // Target iframe by index
879
1254
  extract(type="text", frame=0)
880
1255
 
1256
+ // Resolve each step relative to the selected parent, including OOPIFs in CDP
1257
+ evaluate(script="document.title", frame=["iframe#outer", "iframe#inner"])
1258
+
881
1259
  // Input inside iframe
882
1260
  input(events=[
883
1261
  { type: "mousedown", target: { label: "Username" } },
@@ -1019,7 +1397,17 @@ The `stealth` mode (`safe` / `aggressive`) only patches a small set of fingerpri
1019
1397
  - **Chrome only**: Only supports Chrome/Chromium browsers (no Firefox/Safari)
1020
1398
  - **Single CDP session**: CDP mode supports one browser session at a time
1021
1399
  - **Extension mode requires Chrome**: Extension is Manifest V3, Chrome-specific
1022
- - **iframe**: Only single-level iframe targeting (no nested `>>` syntax); Extension mode only
1400
+ - **iframe**: Nested selection uses a selector/index array; XPath keeps its native document scope
1401
+
1402
+ ## Compatible Clients
1403
+
1404
+ | Client | Status |
1405
+ | ------------------------- | ------ |
1406
+ | Claude Code | ✅ |
1407
+ | Claude Desktop | ✅ |
1408
+ | Cursor | ✅ |
1409
+ | Windsurf | ✅ |
1410
+ | Any MCP-compatible client | ✅ |
1023
1411
 
1024
1412
  ## License
1025
1413
 
@@ -1029,54 +1417,3 @@ MIT License - see [LICENSE](LICENSE) for details.
1029
1417
 
1030
1418
  - [Model Context Protocol](https://modelcontextprotocol.io/) - MCP specification
1031
1419
  - [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) - CDP documentation
1032
-
1033
- ## Operation status and diagnostics
1034
-
1035
- Input and evaluate responses append `actionExecuted`, `actionStatus`, `verificationStatus`, `failureStage`, and
1036
- `retryable`. Verification uses `matched`, `not_matched`, `unavailable`, or `error`; debugger timeouts report the action
1037
- as `unknown` when completion cannot be proven. Page-thrown exceptions report `actionExecuted=true` with
1038
- `actionStatus="failed"`. Once native execution returns a result, local materialization or serialization failures report
1039
- `actionStatus="completed"` and `failureStage="output"`. Diagnostics are best-effort and return `diagnosticsStatus` without replacing the main action
1040
- result. On a page precondition mismatch, input and evaluate report `actionExecuted=false` and
1041
- `actionStatus="not_started"`. Browse and wait errors also retain any diagnostics collected before the action failed.
1042
- Target diagnostics query the current tab state instead of relying on cached attach metadata.
1043
-
1044
- Native script termination, `Internal error`, `Object couldn't be returned by value`, and `Object reference chain is too long`
1045
- responses from CDP `Runtime` script commands preserve the original error code. evaluate and `manage cdp` return `actionExecuted=true`,
1046
- `actionStatus="unknown"`, and `retryable=false` without replaying the command. evaluate also returns `retryable=false`
1047
- when an in-flight RPC timeout or stale execution context leaves the result unknown; timeouts before execution starts
1048
- remain retryable. Page-thrown exceptions with the same text remain non-retryable action failures.
1049
-
1050
- Recognized Extension CDP rejections return `CDP_ERROR` with the method, target, native message and available protocol
1051
- code. The context distinguishes a disabled Debugger domain, stale script ID, browser-level command restriction, missing
1052
- method, command permission refusal (`Not allowed`), and native result serialization failure. A resource or method lookup failure does not imply that the entire
1053
- domain is unsupported. These remain failed calls with warning diagnostics; unknown errors retain error-level reporting.
1054
- A closed tab found during a native snapshot or permission check remains a target failure, separate from page-thrown
1055
- exceptions with matching text.
1056
-
1057
- Extension accessibility state never reads `input[type=hidden]` or `input[type=password]` value getters for element names
1058
- or state text. This applies to the default `all` filter, target subtrees, and file output. Hidden controls may still
1059
- appear with `visible=false`; labels, placeholders, titles, and ordinary input values remain available. Explicit script,
1060
- HTML, and attribute reads retain their existing behavior.
1061
-
1062
- `replace` uses text selection only for `textarea` and input types `text`, `search`, `tel`, `url`, and `password`. Other
1063
- input types use a native full-value update and return the requested and actual browser-normalized values. A standalone
1064
- `select` on unsupported types returns `UNSUPPORTED_SELECTION`. CDP locator targets for `select` and `replace` are
1065
- focused through the CDP locator instead of Extension-only ref IDs. Password values are omitted from input failure
1066
- context and text post-condition observations; failed input responses also redact supplied `find` and replacement `text`
1067
- values. Password `select`/`replace` responses hide console and network diagnostic bodies on success and failure,
1068
- returning `diagnostics.redacted=true` with `reason="sensitive_input_or_unresolved_target"`. This also applies when a
1069
- selection target cannot be identified safely. Ordinary input retains its diagnostics; password protection lasts for the
1070
- current input request. Target timeouts include bounded locator, tab, frame, match, and candidate context. Explicit
1071
- `tabId` and `frame` scopes resolve the active backend before input, wait, logs, or extract work begins, so actions and
1072
- verification use the same target backend. Precise iframe evaluation defaults to `staleContextRetry="never"` and does not
1073
- replay stale scripts. `readOnly` permits one replay after the Extension verifies the frame identity and resolves a new
1074
- execution context. Responses include the policy, `retryAttempted`, bounded `retryReason`, and the final `frameContext`
1075
- with the Extension frame, parent frame, URL, CDP frame, and execution context IDs. Same-URL frames are rejected only
1076
- when the selected DOM iframe cannot identify one target. Existing iframe targets remain usable after an Extension reload
1077
- without refreshing or navigating the page. Invalidated probe contexts produce a warning and stop listening instead of
1078
- throwing an uncaught messaging error. Discovery reports the initial port set and subsequent changes, including transitions
1079
- to no servers; unchanged scans and automatic reconnects do not repeat that summary. Each scan still checks the entire
1080
- port range. Explicit disconnect starts a new reporting cycle. Ordinary pre-open failures remain debug-level;
1081
- authentication and protocol rejections from identified MCP servers produce one bounded warning when the rejection
1082
- summary changes.