cdp-toolkit 3.0.2 → 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.
- package/CHANGELOG.md +25 -0
- package/CONTRACT.md +2 -2
- package/README.md +85 -2
- package/dist/bidi/mux-daemon.js +316 -10
- package/dist/cli.js +615 -94
- package/dist/index.js +440 -41
- package/dist/mcp.js +667 -133
- package/package.json +1 -1
- package/src/cdp/driver.ts +71 -11
- package/src/cli.ts +17 -4
- package/src/client.ts +22 -6
- package/src/endpoints.ts +428 -0
- package/src/install/browser.ts +9 -3
- package/src/install/wizard.ts +8 -8
- package/src/leases-tools.ts +6 -3
- package/src/leases.ts +28 -4
- package/src/manifest.ts +54 -42
- package/src/mcp.ts +52 -8
- package/src/origins.ts +5 -2
- package/src/policy.ts +163 -0
- package/src/reap.ts +14 -0
- package/src/shared-tools.ts +72 -4
- package/src/toolDocs.ts +39 -36
- package/src/tools/browser-session.ts +26 -12
- package/src/tools/dispatch-mouse.ts +2 -1
- package/src/tools/focus-emulation.ts +5 -3
- package/src/tools/lighthouse.ts +4 -2
- package/src/version.ts +1 -1
package/src/manifest.ts
CHANGED
|
@@ -40,6 +40,14 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
40
40
|
"probe": {
|
|
41
41
|
"type": "boolean",
|
|
42
42
|
"description": "Probe renderer responsiveness."
|
|
43
|
+
},
|
|
44
|
+
"endpoint": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Named CDP endpoint to list (CDP_ENDPOINTS); default endpoint when omitted."
|
|
47
|
+
},
|
|
48
|
+
"allEndpoints": {
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"description": "List every configured endpoint; rows carry endpoint, a down one is reported, not thrown."
|
|
43
51
|
}
|
|
44
52
|
},
|
|
45
53
|
"required": [],
|
|
@@ -64,6 +72,10 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
64
72
|
"type": "boolean",
|
|
65
73
|
"description": "Claim the new tab."
|
|
66
74
|
},
|
|
75
|
+
"endpoint": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "Named CDP endpoint to open the tab on (CDP_ENDPOINTS); default endpoint when omitted."
|
|
78
|
+
},
|
|
67
79
|
"label": {
|
|
68
80
|
"type": "string",
|
|
69
81
|
"description": "Agent lease label."
|
|
@@ -89,7 +101,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
89
101
|
},
|
|
90
102
|
"target": {
|
|
91
103
|
"type": "string",
|
|
92
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
104
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
93
105
|
}
|
|
94
106
|
},
|
|
95
107
|
"required": [
|
|
@@ -110,7 +122,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
110
122
|
},
|
|
111
123
|
"target": {
|
|
112
124
|
"type": "string",
|
|
113
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
125
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
114
126
|
}
|
|
115
127
|
},
|
|
116
128
|
"required": [
|
|
@@ -131,7 +143,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
131
143
|
},
|
|
132
144
|
"target": {
|
|
133
145
|
"type": "string",
|
|
134
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
146
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
135
147
|
},
|
|
136
148
|
"url": {
|
|
137
149
|
"type": "string",
|
|
@@ -181,7 +193,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
181
193
|
},
|
|
182
194
|
"target": {
|
|
183
195
|
"type": "string",
|
|
184
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
196
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
185
197
|
},
|
|
186
198
|
"text": {
|
|
187
199
|
"type": "string",
|
|
@@ -214,7 +226,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
214
226
|
},
|
|
215
227
|
"target": {
|
|
216
228
|
"type": "string",
|
|
217
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
229
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
218
230
|
},
|
|
219
231
|
"wake": {
|
|
220
232
|
"type": "boolean",
|
|
@@ -256,7 +268,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
256
268
|
},
|
|
257
269
|
"target": {
|
|
258
270
|
"type": "string",
|
|
259
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
271
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
260
272
|
},
|
|
261
273
|
"domain": {
|
|
262
274
|
"type": "string",
|
|
@@ -287,7 +299,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
287
299
|
},
|
|
288
300
|
"target": {
|
|
289
301
|
"type": "string",
|
|
290
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
302
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
291
303
|
},
|
|
292
304
|
"name": {
|
|
293
305
|
"type": "string",
|
|
@@ -351,7 +363,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
351
363
|
},
|
|
352
364
|
"target": {
|
|
353
365
|
"type": "string",
|
|
354
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
366
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
355
367
|
},
|
|
356
368
|
"name": {
|
|
357
369
|
"type": "string",
|
|
@@ -388,7 +400,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
388
400
|
},
|
|
389
401
|
"target": {
|
|
390
402
|
"type": "string",
|
|
391
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
403
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
392
404
|
},
|
|
393
405
|
"interactiveOnly": {
|
|
394
406
|
"type": "boolean",
|
|
@@ -411,7 +423,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
411
423
|
},
|
|
412
424
|
"target": {
|
|
413
425
|
"type": "string",
|
|
414
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
426
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
415
427
|
},
|
|
416
428
|
"uid": {
|
|
417
429
|
"type": "number",
|
|
@@ -464,7 +476,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
464
476
|
},
|
|
465
477
|
"target": {
|
|
466
478
|
"type": "string",
|
|
467
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
479
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
468
480
|
},
|
|
469
481
|
"uid": {
|
|
470
482
|
"type": "number",
|
|
@@ -491,7 +503,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
491
503
|
},
|
|
492
504
|
"target": {
|
|
493
505
|
"type": "string",
|
|
494
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
506
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
495
507
|
},
|
|
496
508
|
"from": {
|
|
497
509
|
"type": "object",
|
|
@@ -577,7 +589,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
577
589
|
},
|
|
578
590
|
"target": {
|
|
579
591
|
"type": "string",
|
|
580
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
592
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
581
593
|
},
|
|
582
594
|
"uid": {
|
|
583
595
|
"type": "number",
|
|
@@ -620,7 +632,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
620
632
|
},
|
|
621
633
|
"target": {
|
|
622
634
|
"type": "string",
|
|
623
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
635
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
624
636
|
},
|
|
625
637
|
"action": {
|
|
626
638
|
"type": "string",
|
|
@@ -686,7 +698,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
686
698
|
},
|
|
687
699
|
"target": {
|
|
688
700
|
"type": "string",
|
|
689
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
701
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
690
702
|
},
|
|
691
703
|
"enabled": {
|
|
692
704
|
"type": "boolean",
|
|
@@ -711,7 +723,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
711
723
|
},
|
|
712
724
|
"target": {
|
|
713
725
|
"type": "string",
|
|
714
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
726
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
715
727
|
},
|
|
716
728
|
"selector": {
|
|
717
729
|
"type": "string",
|
|
@@ -750,7 +762,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
750
762
|
},
|
|
751
763
|
"target": {
|
|
752
764
|
"type": "string",
|
|
753
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
765
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
754
766
|
},
|
|
755
767
|
"arm": {
|
|
756
768
|
"type": "boolean",
|
|
@@ -777,7 +789,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
777
789
|
},
|
|
778
790
|
"target": {
|
|
779
791
|
"type": "string",
|
|
780
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
792
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
781
793
|
},
|
|
782
794
|
"permissions": {
|
|
783
795
|
"type": "array",
|
|
@@ -811,7 +823,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
811
823
|
},
|
|
812
824
|
"target": {
|
|
813
825
|
"type": "string",
|
|
814
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
826
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
815
827
|
},
|
|
816
828
|
"uid": {
|
|
817
829
|
"type": "number",
|
|
@@ -844,7 +856,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
844
856
|
},
|
|
845
857
|
"target": {
|
|
846
858
|
"type": "string",
|
|
847
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
859
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
848
860
|
},
|
|
849
861
|
"fields": {
|
|
850
862
|
"type": "array",
|
|
@@ -890,7 +902,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
890
902
|
},
|
|
891
903
|
"target": {
|
|
892
904
|
"type": "string",
|
|
893
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
905
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
894
906
|
},
|
|
895
907
|
"uid": {
|
|
896
908
|
"type": "number",
|
|
@@ -923,7 +935,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
923
935
|
},
|
|
924
936
|
"target": {
|
|
925
937
|
"type": "string",
|
|
926
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
938
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
927
939
|
},
|
|
928
940
|
"key": {
|
|
929
941
|
"type": "string",
|
|
@@ -955,7 +967,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
955
967
|
},
|
|
956
968
|
"target": {
|
|
957
969
|
"type": "string",
|
|
958
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
970
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
959
971
|
},
|
|
960
972
|
"uid": {
|
|
961
973
|
"type": "number",
|
|
@@ -991,7 +1003,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
991
1003
|
},
|
|
992
1004
|
"target": {
|
|
993
1005
|
"type": "string",
|
|
994
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1006
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
995
1007
|
},
|
|
996
1008
|
"format": {
|
|
997
1009
|
"type": "string",
|
|
@@ -1058,7 +1070,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1058
1070
|
},
|
|
1059
1071
|
"target": {
|
|
1060
1072
|
"type": "string",
|
|
1061
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1073
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1062
1074
|
},
|
|
1063
1075
|
"width": {
|
|
1064
1076
|
"type": "number",
|
|
@@ -1158,7 +1170,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1158
1170
|
},
|
|
1159
1171
|
"target": {
|
|
1160
1172
|
"type": "string",
|
|
1161
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1173
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1162
1174
|
},
|
|
1163
1175
|
"width": {
|
|
1164
1176
|
"type": "number",
|
|
@@ -1196,7 +1208,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1196
1208
|
},
|
|
1197
1209
|
"target": {
|
|
1198
1210
|
"type": "string",
|
|
1199
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1211
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1200
1212
|
},
|
|
1201
1213
|
"accept": {
|
|
1202
1214
|
"type": "boolean",
|
|
@@ -1233,7 +1245,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1233
1245
|
},
|
|
1234
1246
|
"target": {
|
|
1235
1247
|
"type": "string",
|
|
1236
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1248
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1237
1249
|
},
|
|
1238
1250
|
"reload": {
|
|
1239
1251
|
"type": "boolean",
|
|
@@ -1264,7 +1276,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1264
1276
|
},
|
|
1265
1277
|
"target": {
|
|
1266
1278
|
"type": "string",
|
|
1267
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1279
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1268
1280
|
},
|
|
1269
1281
|
"index": {
|
|
1270
1282
|
"type": "number",
|
|
@@ -1287,7 +1299,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1287
1299
|
},
|
|
1288
1300
|
"target": {
|
|
1289
1301
|
"type": "string",
|
|
1290
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1302
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1291
1303
|
},
|
|
1292
1304
|
"reload": {
|
|
1293
1305
|
"type": "boolean",
|
|
@@ -1322,7 +1334,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1322
1334
|
},
|
|
1323
1335
|
"target": {
|
|
1324
1336
|
"type": "string",
|
|
1325
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1337
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1326
1338
|
},
|
|
1327
1339
|
"requestId": {
|
|
1328
1340
|
"type": "string",
|
|
@@ -1361,7 +1373,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1361
1373
|
},
|
|
1362
1374
|
"target": {
|
|
1363
1375
|
"type": "string",
|
|
1364
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1376
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1365
1377
|
},
|
|
1366
1378
|
"categories": {
|
|
1367
1379
|
"type": "array",
|
|
@@ -1387,7 +1399,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1387
1399
|
},
|
|
1388
1400
|
"target": {
|
|
1389
1401
|
"type": "string",
|
|
1390
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1402
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1391
1403
|
}
|
|
1392
1404
|
},
|
|
1393
1405
|
"required": [],
|
|
@@ -1425,7 +1437,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1425
1437
|
},
|
|
1426
1438
|
"target": {
|
|
1427
1439
|
"type": "string",
|
|
1428
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1440
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1429
1441
|
},
|
|
1430
1442
|
"durationMs": {
|
|
1431
1443
|
"type": "number",
|
|
@@ -1463,7 +1475,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1463
1475
|
},
|
|
1464
1476
|
"target": {
|
|
1465
1477
|
"type": "string",
|
|
1466
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1478
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1467
1479
|
},
|
|
1468
1480
|
"format": {
|
|
1469
1481
|
"type": "string",
|
|
@@ -1510,7 +1522,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1510
1522
|
},
|
|
1511
1523
|
"target": {
|
|
1512
1524
|
"type": "string",
|
|
1513
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1525
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1514
1526
|
},
|
|
1515
1527
|
"savePath": {
|
|
1516
1528
|
"type": "string",
|
|
@@ -1533,7 +1545,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1533
1545
|
},
|
|
1534
1546
|
"target": {
|
|
1535
1547
|
"type": "string",
|
|
1536
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1548
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1537
1549
|
},
|
|
1538
1550
|
"savePath": {
|
|
1539
1551
|
"type": "string",
|
|
@@ -1600,7 +1612,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1600
1612
|
},
|
|
1601
1613
|
"target": {
|
|
1602
1614
|
"type": "string",
|
|
1603
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1615
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1604
1616
|
},
|
|
1605
1617
|
"urlPattern": {
|
|
1606
1618
|
"type": "string",
|
|
@@ -1689,7 +1701,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1689
1701
|
},
|
|
1690
1702
|
"target": {
|
|
1691
1703
|
"type": "string",
|
|
1692
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1704
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1693
1705
|
},
|
|
1694
1706
|
"all": {
|
|
1695
1707
|
"type": "boolean",
|
|
@@ -1708,7 +1720,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1708
1720
|
"properties": {
|
|
1709
1721
|
"target": {
|
|
1710
1722
|
"type": "string",
|
|
1711
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1723
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1712
1724
|
},
|
|
1713
1725
|
"targetId": {
|
|
1714
1726
|
"type": "string",
|
|
@@ -1743,7 +1755,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1743
1755
|
},
|
|
1744
1756
|
"target": {
|
|
1745
1757
|
"type": "string",
|
|
1746
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1758
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1747
1759
|
},
|
|
1748
1760
|
"close": {
|
|
1749
1761
|
"type": "boolean",
|
|
@@ -1776,7 +1788,7 @@ export const MANIFEST: ToolSpec[] = [
|
|
|
1776
1788
|
},
|
|
1777
1789
|
"target": {
|
|
1778
1790
|
"type": "string",
|
|
1779
|
-
"description": "Page selector (index:/url:/title:/label:/targetId, default active); grammar in server instructions."
|
|
1791
|
+
"description": "Page selector (index:/url:/title:/label:/targetId, endpoint:<name>/ prefix, default active); grammar in server instructions."
|
|
1780
1792
|
},
|
|
1781
1793
|
"schema": {
|
|
1782
1794
|
"type": "object",
|
package/src/mcp.ts
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
*
|
|
16
16
|
* Launch: `bunx -y cdp-toolkit` (or `bun run src/mcp.ts` from a checkout)
|
|
17
17
|
* HTTP: `bun run src/mcp.ts --transport streamable-http [--port 3000] [--host 127.0.0.1]`
|
|
18
|
-
* Config: CDP_BASE (default http://127.0.0.1:9222),
|
|
18
|
+
* Config: CDP_BASE (default http://127.0.0.1:9222), CDP_ENDPOINTS / CDP_ENDPOINTS_FILE (named
|
|
19
|
+
* endpoints, Chrome only; see src/endpoints.ts), CDP_TIMEOUT_MS, CDP_ARTIFACT_DIR,
|
|
19
20
|
* CDP_TOOL_PROFILE (`full` — the default — advertises every group; `core` advertises
|
|
20
21
|
* just the 12 everyday tools; or a comma-separated group list, e.g. `core,network`.
|
|
21
22
|
* Startup-only filter on what tools/list shows; unlisted tools stay callable by name),
|
|
@@ -43,8 +44,10 @@ import { disposeBrowserSession } from "./tools/browser-session.ts";
|
|
|
43
44
|
import { toolAvailability } from "./capabilities.ts";
|
|
44
45
|
import { FIREFOX_TOOLS } from "./firefox-tools.ts";
|
|
45
46
|
import { leaseFromArgs, markLongLivedProcess, withLeaseScope } from "./leases.ts";
|
|
47
|
+
import { allEndpoints, endpointConfig, ENDPOINTS_FIREFOX_MESSAGE, stripEndpointArgs, usesEndpointArgs, withEndpointScope } from "./endpoints.ts";
|
|
46
48
|
import { isListed, resolveProfile, TOOL_GROUP, TOOL_GROUPS, GROUP_TOOLS } from "./toolGroups.ts";
|
|
47
49
|
import { TOOL_DOCS } from "./toolDocs.ts";
|
|
50
|
+
import { assertAllowed, toolAnnotations } from "./policy.ts";
|
|
48
51
|
import { VERSION } from "./version.ts";
|
|
49
52
|
|
|
50
53
|
// Bun.serve is the HTTP transport's listener: a Bun-only global, typed here (not via bun-types,
|
|
@@ -158,7 +161,7 @@ function auditCoverage(): void {
|
|
|
158
161
|
const INSTRUCTIONS = [
|
|
159
162
|
"cdp-toolkit drives a real browser over CDP (or Firefox WebDriver-BiDi): pages, input, screenshots, snapshots, console, network, cookies, emulation, Lighthouse, traces, screencasts.",
|
|
160
163
|
"TOOLS: by default only 5 are listed (navigate_page, take_snapshot, click, fill, evaluate_script). ~45 more exist: find one with search_tools {query} (returns its schema; no query = catalog), run it with call_tool {name, arguments}. No tab yet? call_tool {name:'new_page'}. The listing is fixed for the process's life; CDP_TOOL_PROFILE=full lists everything.",
|
|
161
|
-
"TARGET SELECTOR (the `target` param, unless a tool says otherwise): 'active' (default = first page) | 'index:N' (0-based) | 'url:<substr>' | 'title:<substr>' | 'label:<name>' (exact, ledger or live lease) | a 32-hex '<targetId>' of any target type — an iframe id from list_pages{all:true} drives like a tab. Chrome tools also accept 'frame:<substr>' for OOPIF iframe targets. Four Chrome-only tools (evaluate_script, list_network_requests, get_network_request, list_console_messages) also accept 'worker:<substr>' to reach a service/shared worker (e.g.
|
|
164
|
+
"TARGET SELECTOR (the `target` param, unless a tool says otherwise): 'active' (default = first page) | 'index:N' (0-based) | 'url:<substr>' | 'title:<substr>' | 'label:<name>' (exact, ledger or live lease) | a 32-hex '<targetId>' of any target type — an iframe id from list_pages{all:true} drives like a tab. Chrome tools also accept 'frame:<substr>' for OOPIF iframe targets. Four Chrome-only tools (evaluate_script, list_network_requests, get_network_request, list_console_messages) also accept 'worker:<substr>' to reach a service/shared worker (e.g. MV3 background); an idle-evicted worker is started first (see `wake`). Prefix 'endpoint:<name>/' for a named CDP endpoint; an app endpoint (Teams) lists an empty host page first: use title:.",
|
|
162
165
|
"LEASES (the `lease` param): claim_page, and new_page{claim:true}, mint an opaque token. Omit it for a tab THIS process already holds. It is required for a tab held by ANOTHER process, or one claimed explicitly. Under CDP_REQUIRE_LEASE the gate auto-acquires a lease for any tab this process drives — no token is surfaced, so pass `target`, not `lease` — while an explicit claim:true still demands its token on every later call.",
|
|
163
166
|
"ORIGIN: list_pages and list_leases tag each tab's `origin` as 'agent' (this toolkit created it) or 'unknown' — never 'human', because the toolkit cannot prove a person opened a tab. An 'agent' tab stays findable after its creator releases the lease or dies.",
|
|
164
167
|
].join("\n\n");
|
|
@@ -218,6 +221,8 @@ const LISTING: Tool[] = Object.freeze([
|
|
|
218
221
|
},
|
|
219
222
|
additionalProperties: false,
|
|
220
223
|
} as Tool["inputSchema"],
|
|
224
|
+
// Reads static docs only.
|
|
225
|
+
annotations: { readOnlyHint: true },
|
|
221
226
|
},
|
|
222
227
|
{
|
|
223
228
|
name: "call_tool",
|
|
@@ -232,10 +237,13 @@ const LISTING: Tool[] = Object.freeze([
|
|
|
232
237
|
required: ["name"],
|
|
233
238
|
additionalProperties: false,
|
|
234
239
|
} as Tool["inputSchema"],
|
|
240
|
+
// Runs any tool, mutating ones included; the inner tool's own policy check still applies.
|
|
241
|
+
annotations: { readOnlyHint: false },
|
|
235
242
|
},
|
|
236
243
|
...MANIFEST
|
|
237
244
|
.filter((s) => AVAILABLE_NAMES.has(s.name) && isListed(PROFILE, s.name))
|
|
238
|
-
.
|
|
245
|
+
// readOnlyHint (src/policy.ts): true for READ tools, the ones a read-only endpoint allows.
|
|
246
|
+
.map((s) => ({ name: s.name, description: s.description, inputSchema: s.inputSchema as Tool["inputSchema"], annotations: toolAnnotations(s.name) })),
|
|
239
247
|
] satisfies Tool[]) as Tool[];
|
|
240
248
|
|
|
241
249
|
/** search_tools with no query: every group the backend supports, and what of it is listed. */
|
|
@@ -408,6 +416,15 @@ export function buildServer(): Server {
|
|
|
408
416
|
return server;
|
|
409
417
|
}
|
|
410
418
|
|
|
419
|
+
/** Stderr suffix naming the configured endpoints, empty unless more than one is configured
|
|
420
|
+
* (a CDP_BASE-only setup logs exactly what it always did). */
|
|
421
|
+
function endpointsLogSuffix(): string {
|
|
422
|
+
if (BROWSER !== "chrome") return "";
|
|
423
|
+
const eps = allEndpoints();
|
|
424
|
+
if (eps.length < 2) return "";
|
|
425
|
+
return `, endpoints=${eps.map((e) => `${e.name}=${e.base}${e.readOnly ? "(read)" : ""}`).join(",")}`;
|
|
426
|
+
}
|
|
427
|
+
|
|
411
428
|
/** Dispatch one browser tool by name: the path both a direct call and call_tool take. */
|
|
412
429
|
async function runTool(name: string, args: unknown) {
|
|
413
430
|
if (!AVAILABLE_NAMES.has(name)) {
|
|
@@ -428,14 +445,30 @@ async function runTool(name: string, args: unknown) {
|
|
|
428
445
|
const fn = dispatch[name];
|
|
429
446
|
if (!fn) return { content: [{ type: "text" as const, text: `unknown tool: ${name}` }], isError: true };
|
|
430
447
|
try {
|
|
431
|
-
|
|
432
|
-
|
|
448
|
+
// ONE endpoint scope per dispatch, the same way and for the same reason as the
|
|
449
|
+
// lease scope above: the `endpoint:<name>/` prefix (or an `endpoint` arg) is
|
|
450
|
+
// resolved and STRIPPED here, once, so none of the three selector pickers ever
|
|
451
|
+
// sees it, and every base URL below resolves through currentEndpoint(). Inside
|
|
452
|
+
// the try, so an unknown endpoint name is an isError result, not a throw.
|
|
453
|
+
const { endpoint, args: toolArgs } = stripEndpointArgs(args);
|
|
454
|
+
// Read-only endpoint policy (src/policy.ts), checked once the endpoint is known and
|
|
455
|
+
// BEFORE the tool runs, so a refused call sends no HTTP request and no CDP message.
|
|
456
|
+
// A call_tool reaches here with the INNER name, so it cannot launder a mutating tool.
|
|
457
|
+
assertAllowed(name, endpoint, toolArgs);
|
|
458
|
+
const result = await withEndpointScope(endpoint, () => fn(toolArgs));
|
|
459
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(result ?? null, null, 2) }] };
|
|
433
460
|
} catch (err) {
|
|
434
461
|
const message = err instanceof Error ? err.message : String(err);
|
|
435
462
|
return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true };
|
|
436
463
|
}
|
|
437
464
|
}
|
|
438
465
|
|
|
466
|
+
// Named endpoints are CDP-only (issue #15): refuse them on Firefox rather than
|
|
467
|
+
// silently driving the one BiDi session as if the prefix were not there.
|
|
468
|
+
if (usesEndpointArgs(args)) {
|
|
469
|
+
return { content: [{ type: "text" as const, text: `Error: ${ENDPOINTS_FIREFOX_MESSAGE}` }], isError: true };
|
|
470
|
+
}
|
|
471
|
+
|
|
439
472
|
// Firefox: one BiDi session memoized for the life of this server process (lifetime "session",
|
|
440
473
|
// ADR-001); launched lazily on the first Firefox tool call, torn down on shutdown below.
|
|
441
474
|
const neutralFn = neutralDispatch[name];
|
|
@@ -443,7 +476,7 @@ async function runTool(name: string, args: unknown) {
|
|
|
443
476
|
try {
|
|
444
477
|
const session = await getOrCreateFirefoxSession({ endpoint: FIREFOX_ENDPOINT });
|
|
445
478
|
const result = await neutralFn(session.driver, args);
|
|
446
|
-
return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] };
|
|
479
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(result ?? null, null, 2) }] };
|
|
447
480
|
} catch (err) {
|
|
448
481
|
const message = err instanceof Error ? err.message : String(err);
|
|
449
482
|
return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true };
|
|
@@ -461,6 +494,17 @@ async function run(argv: string[]): Promise<void> {
|
|
|
461
494
|
// This process is the long-lived MCP server, which is what makes strict mode
|
|
462
495
|
// (CDP_REQUIRE_LEASE) safe to honor here and unsafe in cli.ts. See requireLease.
|
|
463
496
|
markLongLivedProcess();
|
|
497
|
+
// A malformed CDP_ENDPOINTS / CDP_ENDPOINTS_FILE is a STARTUP error under Chrome, named
|
|
498
|
+
// and fatal, the same treatment startupProfile gives a bad CDP_TOOL_PROFILE. Firefox never
|
|
499
|
+
// reads the endpoint config, so it is not checked there.
|
|
500
|
+
if (BROWSER === "chrome") {
|
|
501
|
+
try {
|
|
502
|
+
endpointConfig();
|
|
503
|
+
} catch (err) {
|
|
504
|
+
console.error(`[cdp-toolkit] ${err instanceof Error ? err.message : String(err)}`);
|
|
505
|
+
process.exit(1);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
464
508
|
|
|
465
509
|
// Per-transport state the shutdown path closes (only one is ever set).
|
|
466
510
|
let stdioHandle: Awaited<ReturnType<typeof serveStdio>> | undefined;
|
|
@@ -508,7 +552,7 @@ async function run(argv: string[]): Promise<void> {
|
|
|
508
552
|
);
|
|
509
553
|
process.stdin.on("close", () => void shutdown());
|
|
510
554
|
console.error(
|
|
511
|
-
`[cdp-toolkit] MCP server v${VERSION} ready, browser=${BROWSER}${FIREFOX_ENDPOINT ? ` (attach ${FIREFOX_ENDPOINT})` : ""}, ${AVAILABILITY.available.length} tools available, ${LISTING.length} listed (CDP_TOOL_PROFILE=${PROFILE.label}), CDP_BASE=${BASE}`,
|
|
555
|
+
`[cdp-toolkit] MCP server v${VERSION} ready, browser=${BROWSER}${FIREFOX_ENDPOINT ? ` (attach ${FIREFOX_ENDPOINT})` : ""}, ${AVAILABILITY.available.length} tools available, ${LISTING.length} listed (CDP_TOOL_PROFILE=${PROFILE.label}), CDP_BASE=${BASE}${endpointsLogSuffix()}`,
|
|
512
556
|
);
|
|
513
557
|
return;
|
|
514
558
|
}
|
|
@@ -543,7 +587,7 @@ async function run(argv: string[]): Promise<void> {
|
|
|
543
587
|
// scanner finds the real listening port first (matters under --port 0, where N is the
|
|
544
588
|
// OS-assigned one and the only place it is knowable).
|
|
545
589
|
console.error(
|
|
546
|
-
`[cdp-toolkit] MCP server v${VERSION} listening on streamable-http port ${listener.port} (http://${serve.host}:${listener.port}/), browser=${BROWSER}${FIREFOX_ENDPOINT ? ` (attach ${FIREFOX_ENDPOINT})` : ""}, ${AVAILABILITY.available.length} tools available, ${LISTING.length} listed (CDP_TOOL_PROFILE=${PROFILE.label}), CDP_BASE=${BASE}`,
|
|
590
|
+
`[cdp-toolkit] MCP server v${VERSION} listening on streamable-http port ${listener.port} (http://${serve.host}:${listener.port}/), browser=${BROWSER}${FIREFOX_ENDPOINT ? ` (attach ${FIREFOX_ENDPOINT})` : ""}, ${AVAILABILITY.available.length} tools available, ${LISTING.length} listed (CDP_TOOL_PROFILE=${PROFILE.label}), CDP_BASE=${BASE}${endpointsLogSuffix()}`,
|
|
547
591
|
);
|
|
548
592
|
}
|
|
549
593
|
|
package/src/origins.ts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
import { mkdir, readFile, readdir, unlink, writeFile } from "node:fs/promises";
|
|
33
33
|
import { join } from "node:path";
|
|
34
34
|
import type { BrowserDriver, PageInfo } from "./driver.ts";
|
|
35
|
-
import { defaultLabel, leaseDir, listLeases, type LeaseBackend } from "./leases.ts";
|
|
35
|
+
import { BACKEND_KEY_SOURCE, defaultLabel, leaseDir, listLeases, type LeaseBackend } from "./leases.ts";
|
|
36
36
|
|
|
37
37
|
/** What list_pages can say about where a tab came from. There is deliberately
|
|
38
38
|
* no "human": see the file header. */
|
|
@@ -60,7 +60,10 @@ export function originFile(backend: LeaseBackend, targetId: string): string {
|
|
|
60
60
|
return join(leaseDir(), `origin-${backend}-${safeId(targetId)}.json`);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
// Same backend-key grammar as leases.ts: `origin-chrome@teams-<id>.json` for a named
|
|
64
|
+
// endpoint. listOrigins' liveBackend scoping then keeps one endpoint's target list from
|
|
65
|
+
// reaping another endpoint's records.
|
|
66
|
+
const ORIGIN_FILE_RE = new RegExp(`^origin-(${BACKEND_KEY_SOURCE})-(.+)\\.json$`);
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
69
|
* Record that this toolkit just created `targetId`.
|