turbo-browser-mcp 0.7.3 → 0.7.4
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/package.json +1 -1
- package/server.json +2 -2
- package/skills/turbo-browser/SKILL.md +2 -2
- package/src/browser-manager.mjs +27 -1
- package/src/dom-engine.mjs +908 -133
- package/src/index.mjs +117 -310
- package/src/playwright-loader.mjs +55 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turbo-browser-mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "MCP server for browser automation on Playwright. It fills whole forms and runs action lists in one call, returns only changed elements, and blocks final Submit clicks by default.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
package/server.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
|
|
3
3
|
"name": "io.github.tthanh2k6/turbo-browser-mcp",
|
|
4
4
|
"description": "MCP server for browser automation on Playwright. It fills whole forms and runs action lists in one call, returns only changed elements, and blocks final Submit clicks by default.",
|
|
5
|
-
"version": "0.7.
|
|
5
|
+
"version": "0.7.4",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "https://github.com/Tthanh2k6/turbo-browser-mcp",
|
|
8
8
|
"source": "github"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "turbo-browser-mcp",
|
|
14
|
-
"version": "0.7.
|
|
14
|
+
"version": "0.7.4",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
}
|
|
@@ -18,7 +18,7 @@ inspect_compact {"onlyChanged":true}
|
|
|
18
18
|
inspect_compact {"mode":"article","selector":"main","maxChars":3000}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
For plain reading use `extract_clean_text` (`format` markdown or
|
|
21
|
+
For plain reading use `extract_clean_text` (`format` markdown, text or `table_json`).
|
|
22
22
|
|
|
23
23
|
## 2. Fill a whole form in one call
|
|
24
24
|
|
|
@@ -36,7 +36,7 @@ smart_fill_form {"fields":[{"selector":"#email","value":"a@b.co"},{"ref":"f0:e7"
|
|
|
36
36
|
batch_actions {"steps":[{"action":"click","text":"Next"},{"action":"wait","textNew":"Step 2"},{"action":"fill","selector":"#phone","value":"0900000000"}],"returnSnapshot":true,"snapshotQuery":"phone|Continue"}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Read feeds with `collect
|
|
39
|
+
Read feeds or paged lists with `collect` (`scrolls` or `nextText`/`nextSelector` + `maxPages`), which reads and de-duplicates:
|
|
40
40
|
|
|
41
41
|
```
|
|
42
42
|
batch_actions {"steps":[{"action":"navigate","url":"https://example.com/list"},{"action":"collect","selector":".row","scrolls":8,"maxItems":100}]}
|
package/src/browser-manager.mjs
CHANGED
|
@@ -123,6 +123,9 @@ export class BrowserManager {
|
|
|
123
123
|
this.tempDownloadFiles = new Set();
|
|
124
124
|
this.connectionNote = '';
|
|
125
125
|
this.degradedReason = '';
|
|
126
|
+
this.cdpPendingApproval = false;
|
|
127
|
+
this.cdpPendingHintMs = options.cdpPendingHintMs;
|
|
128
|
+
this.onCdpPendingApproval = options.onCdpPendingApproval;
|
|
126
129
|
this.bridgePort = options.bridgePort;
|
|
127
130
|
this.cdpAutoTimeoutMs = options.cdpAutoTimeoutMs;
|
|
128
131
|
this.bridgeRetryMs = options.bridgeRetryMs;
|
|
@@ -219,9 +222,27 @@ export class BrowserManager {
|
|
|
219
222
|
// Chrome 144+ shows an Allow prompt on the first connect: give a person time to click it.
|
|
220
223
|
const human = this.mode === 'auto' && Boolean(activeCdpEndpoint) && /^wss?:/.test(activeCdpEndpoint) &&
|
|
221
224
|
hasDevToolsActivePort(this.userDataDir, this.cdpUrl);
|
|
225
|
+
const isWsCdp = /^wss?:\/\//i.test(targetEndpoint) || human;
|
|
222
226
|
const waitMs = cdpConnectWaitMs({ optionMs: this.cdpAutoTimeoutMs, human });
|
|
223
227
|
if (human) process.stderr.write(`waiting for 'Allow' in Chrome (up to ${Math.round(waitMs / 1000)} s)
|
|
224
228
|
`);
|
|
229
|
+
const hintDelay = Number.isFinite(Number(this.cdpPendingHintMs))
|
|
230
|
+
? Math.max(50, Number(this.cdpPendingHintMs))
|
|
231
|
+
: Math.min(800, Math.max(200, Math.floor(waitMs / 3)));
|
|
232
|
+
const pendingTimer = isWsCdp
|
|
233
|
+
? setTimeout(() => {
|
|
234
|
+
this.cdpPendingApproval = true;
|
|
235
|
+
try {
|
|
236
|
+
this.onCdpPendingApproval?.({ endpoint: targetEndpoint, waitMs });
|
|
237
|
+
} catch {}
|
|
238
|
+
if (human) {
|
|
239
|
+
process.stderr.write(
|
|
240
|
+
`[turbo-browser-mcp] cdpPendingApproval: click "Allow" on Chrome's remote debugging prompt\n`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}, hintDelay)
|
|
244
|
+
: null;
|
|
245
|
+
pendingTimer?.unref?.();
|
|
225
246
|
lap('prep');
|
|
226
247
|
let bridgeTimedOut = false;
|
|
227
248
|
let usedBridge = false;
|
|
@@ -262,15 +283,20 @@ export class BrowserManager {
|
|
|
262
283
|
throw new Error(`The CDP bridge on port ${bridgePort} is running but attaching through it failed (step: connect to the bridge, tried ${Math.round(waitMs / 1000)} s then ${Math.round(retryMs / 1000)} s: ${String(retryErr?.message || retryErr).split(String.fromCharCode(10))[0].slice(0, 120)}). Not opening a separate signed-out browser. Try again, or set TURBO_BROWSER_MODE=launch to use a fresh browser on purpose.`);
|
|
263
284
|
}
|
|
264
285
|
}
|
|
286
|
+
clearTimeout(pendingTimer);
|
|
287
|
+
this.cdpPendingApproval = false;
|
|
265
288
|
lap('connect');
|
|
266
289
|
this.connectionNote = '';
|
|
267
290
|
this._cdpEndpoint = targetEndpoint;
|
|
268
291
|
this.context = this.browser.contexts()[0] ?? (await this.browser.newContext());
|
|
269
292
|
this.connectionType = 'cdp';
|
|
270
293
|
} catch (err) {
|
|
294
|
+
clearTimeout(pendingTimer);
|
|
271
295
|
if (/^The CDP bridge on port/.test(String(err?.message))) throw err;
|
|
296
|
+
const m = String(err?.message || err);
|
|
297
|
+
const isApprovalTimeout = isWsCdp && (/timeout/i.test(m) || bridgeTimedOut);
|
|
298
|
+
this.cdpPendingApproval = Boolean(isApprovalTimeout && (human || hasDevToolsActivePort(this.userDataDir, this.cdpUrl) || this.cdpPendingHintMs !== undefined));
|
|
272
299
|
if (this.mode === 'auto') {
|
|
273
|
-
const m = String(err?.message || err);
|
|
274
300
|
this._note(/timeout/i.test(m)
|
|
275
301
|
? `cdp: no response within ${Math.round(waitMs / 1000)}s (Chrome may be waiting for 'Allow remote debugging')`
|
|
276
302
|
: `cdp: ${m.slice(0, 120).split(String.fromCharCode(10))[0]}`);
|