@pyrokine/mcp-chrome 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -20
- package/README_zh.md +578 -0
- package/dist/cdp/launcher.d.ts.map +1 -1
- package/dist/cdp/launcher.js +41 -19
- package/dist/cdp/launcher.js.map +1 -1
- package/dist/core/browser-driver.d.ts +3 -0
- package/dist/core/browser-driver.d.ts.map +1 -1
- package/dist/core/browser-driver.js.map +1 -1
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +41 -12
- package/dist/core/session.js.map +1 -1
- package/dist/core/types.d.ts +12 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +41 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/unified-session.d.ts +9 -0
- package/dist/core/unified-session.d.ts.map +1 -1
- package/dist/core/unified-session.js +105 -34
- package/dist/core/unified-session.js.map +1 -1
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/core/utils.js +21 -8
- package/dist/core/utils.js.map +1 -1
- package/dist/extension/http-server.d.ts +6 -0
- package/dist/extension/http-server.d.ts.map +1 -1
- package/dist/extension/http-server.js +86 -4
- package/dist/extension/http-server.js.map +1 -1
- package/dist/tools/evaluate.d.ts.map +1 -1
- package/dist/tools/evaluate.js +10 -0
- package/dist/tools/evaluate.js.map +1 -1
- package/dist/tools/input.d.ts.map +1 -1
- package/dist/tools/input.js +7 -0
- package/dist/tools/input.js.map +1 -1
- package/dist/tools/manage.js +1 -1
- package/dist/tools/manage.js.map +1 -1
- package/dist/tools/post-condition.d.ts +14 -0
- package/dist/tools/post-condition.d.ts.map +1 -0
- package/dist/tools/post-condition.js +154 -0
- package/dist/tools/post-condition.js.map +1 -0
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -95,6 +95,15 @@ browse(action="open", url="https://example.com")
|
|
|
95
95
|
extract(type="screenshot")
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
**Optional pairing token**
|
|
99
|
+
|
|
100
|
+
By default, local Extension mode does not require a token. To restrict the Extension connection, start the MCP server
|
|
101
|
+
with `MCP_CHROME_PAIRING_TOKEN`, then enter the same token in the Extension popup:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
MCP_CHROME_PAIRING_TOKEN="your-token" node /path/to/mcp-chrome/dist/index.js
|
|
105
|
+
```
|
|
106
|
+
|
|
98
107
|
### Mode 2: CDP Mode (Fallback)
|
|
99
108
|
|
|
100
109
|
CDP mode launches or connects to a dedicated Chrome instance. Used when the Extension is not installed, or for
|
|
@@ -167,8 +176,10 @@ Special-case parameters:
|
|
|
167
176
|
- `keydown` on a key already held emits `rawKeyDown` with `autoRepeat: true` (Puppeteer-compatible long-press).
|
|
168
177
|
|
|
169
178
|
Parameters: `humanize` enables Bézier curve movement and random delays. `diagnostics=true` returns new console
|
|
170
|
-
warnings/errors and failed network requests after the action. `
|
|
171
|
-
|
|
179
|
+
warnings/errors and failed network requests after the action. `postCondition` waits for a page state after the events so
|
|
180
|
+
callers can distinguish dispatched input from completed page behavior. `postCondition.timeout` defaults to 3000 ms and
|
|
181
|
+
is capped at 60000 ms; `postCondition.interval` defaults to 100 ms and accepts 50-5000 ms. `tabId` targets a specific
|
|
182
|
+
tab. `frame` targets an iframe (CSS selector or index). Both Extension mode only.
|
|
172
183
|
|
|
173
184
|
**`click`-specific**: `force: true` skips actionability checks (useful for testing or hidden elements). Actionability
|
|
174
185
|
failures return `ACTIONABILITY_FAILED` with `rect`, `clickPoint`, covering element details, candidate blockers, and
|
|
@@ -196,8 +207,10 @@ accepts `clip` for coordinate-region capture, `compareWith` for PNG baseline com
|
|
|
196
207
|
image. Screenshot responses include `metadata.format`, `width`, `height`, `dimensionSource`, `byteSize`, `fullPage`,
|
|
197
208
|
`scale`, `clip`, and `capabilities`. PNG comparison is capped before decode at 25 MiB per PNG and 12,000,000 pixels; use
|
|
198
209
|
`clip` or `scale` for larger captures. Hidden Extension tabs return `HIDDEN_TAB_SCREENSHOT` instead of auto-focusing the
|
|
199
|
-
browser.
|
|
200
|
-
|
|
210
|
+
browser. If another debugger blocks the precise screenshot path, viewport fallback reports `degraded`, `fallback`, and
|
|
211
|
+
`limitations`; unsupported fallback options return structured `SCREENSHOT_FALLBACK_UNSUPPORTED` errors. `state` returns
|
|
212
|
+
`interactiveElements`; `metadata` returns `frames` in both Extension and CDP modes. `tabId` targets a specific tab.
|
|
213
|
+
`frame` targets an iframe. Both Extension mode only.
|
|
201
214
|
|
|
202
215
|
**`attribute` special prefix**: `computed:<property>` returns the computed CSS style value (e.g. `computed:color`,
|
|
203
216
|
`computed:font-size`). Use `computed:*` to return all computed style properties as JSON (returns 300+ properties — use
|
|
@@ -226,17 +239,18 @@ the DOM settled, `domStable: false` if still mutating when the budget ran out.
|
|
|
226
239
|
|
|
227
240
|
Execute JavaScript in page context.
|
|
228
241
|
|
|
229
|
-
| Parameter
|
|
230
|
-
|
|
231
|
-
| `script`
|
|
232
|
-
| `scriptFile`
|
|
233
|
-
| `args`
|
|
234
|
-
| `mode`
|
|
235
|
-
| `output`
|
|
236
|
-
| `tabId`
|
|
237
|
-
| `frame`
|
|
238
|
-
| `timeout`
|
|
239
|
-
| `diagnostics`
|
|
242
|
+
| Parameter | Description |
|
|
243
|
+
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
|
244
|
+
| `script` | JavaScript code. Bare `return` statements auto-wrapped in IIFE |
|
|
245
|
+
| `scriptFile` | Read script from a local file (alternative to `script`, relative paths default to controlled temp dir, use `cwd:` for repo files) |
|
|
246
|
+
| `args` | Arguments passed to script (script must be a function expression) |
|
|
247
|
+
| `mode` | `precise` (default, debugger API) or `stealth` (JS injection) |
|
|
248
|
+
| `output` | Save result to file (relative paths default to controlled temp dir, use `cwd:` to persist in repo) |
|
|
249
|
+
| `tabId` | Target a specific tab (Extension mode) |
|
|
250
|
+
| `frame` | Target an iframe by CSS selector or index (Extension mode) |
|
|
251
|
+
| `timeout` | End-to-end budget (ms) |
|
|
252
|
+
| `diagnostics` | Return new console warnings/errors and failed network requests after execution |
|
|
253
|
+
| `postCondition` | Wait for text, selector, URL fragment, or script result after execution |
|
|
240
254
|
|
|
241
255
|
`script` and `scriptFile` are mutually exclusive; at least one must be provided. Relative `scriptFile` and `output`
|
|
242
256
|
paths default to the OS temp directory managed by `mcp-chrome`. Use `cwd:relative/path` when the file must live in the
|
|
@@ -245,7 +259,9 @@ streams.
|
|
|
245
259
|
|
|
246
260
|
Results >100KB are auto-saved to the controlled OS temp directory with a structured hint returned. DOM nodes,
|
|
247
261
|
`NodeList`, and `HTMLCollection` results return `NON_SERIALIZABLE_EVALUATE_RESULT` with a hint to return simple fields
|
|
248
|
-
such as `textContent` or `outerHTML`.
|
|
262
|
+
such as `textContent` or `outerHTML`. `postCondition` is optional; when it is not provided, `success=true` only means
|
|
263
|
+
the script executed and returned. When it is provided and does not match before timeout, the tool returns
|
|
264
|
+
`POST_CONDITION_FAILED` with the last observed checks.
|
|
249
265
|
|
|
250
266
|
### manage - Page & Environment Management
|
|
251
267
|
|
|
@@ -273,8 +289,9 @@ such as `textContent` or `outerHTML`.
|
|
|
273
289
|
| `cdp` | Send raw CDP command (advanced, e.g. `Runtime.evaluate`) |
|
|
274
290
|
|
|
275
291
|
Tab/window management actions are Extension-mode only. Actions that change visible browser state require explicit
|
|
276
|
-
`targetId` or `windowId` and return `affected.before/after`. `
|
|
277
|
-
returns `
|
|
292
|
+
`targetId` or `windowId` and return `affected.before/after`. `focusWindow` only returns success after the target window
|
|
293
|
+
is observed as focused; otherwise it returns `WINDOW_FOCUS_NOT_OBSERVED`. `closeWindow` refuses mixed windows with
|
|
294
|
+
unmanaged tabs and returns `WINDOW_HAS_UNMANAGED_TABS`.
|
|
278
295
|
|
|
279
296
|
**Stealth mode levels** (CDP launch parameter, set via `browse action=launch stealth=...`):
|
|
280
297
|
|
|
@@ -290,8 +307,9 @@ returns `WINDOW_HAS_UNMANAGED_TABS`.
|
|
|
290
307
|
| `network` | Network request logs (with URL filter) |
|
|
291
308
|
|
|
292
309
|
Parameters: `output` saves result to file. Network logs include completed requests, HTTP 4xx/5xx responses, and failed
|
|
293
|
-
loads with `errorText`, `method`, `url`, `status`, `timestamp`, and `duration` when available. `
|
|
294
|
-
specific tab (Extension mode). `frame` is
|
|
310
|
+
loads with `errorText`, `method`, `url`, `status`, `timestamp`, and `duration` when available. `urlPattern` supports
|
|
311
|
+
`*` for any number of characters and `?` for one character. `tabId` targets a specific tab (Extension mode). `frame` is
|
|
312
|
+
not applicable for logs.
|
|
295
313
|
|
|
296
314
|
### cookies - Cookie Management
|
|
297
315
|
|