@roxybrowser/playwright-mcp 0.0.5 → 0.0.6-beta.7
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 +832 -742
- package/dist/cli.mjs +250 -0
- package/dist/cli.mjs.LICENSE.txt +42 -0
- package/dist/index.mjs +250 -0
- package/dist/index.mjs.LICENSE.txt +42 -0
- package/dist/index.mjs.map +1 -0
- package/index.d.ts +86 -23
- package/package.json +27 -41
- package/cli.js +0 -18
- package/config.d.ts +0 -119
- package/index.js +0 -19
- package/lib/browserContextFactory.js +0 -264
- package/lib/browserServerBackend.js +0 -77
- package/lib/config.js +0 -246
- package/lib/context.js +0 -242
- package/lib/extension/cdpRelay.js +0 -355
- package/lib/extension/extensionContextFactory.js +0 -54
- package/lib/index.js +0 -40
- package/lib/loop/loop.js +0 -69
- package/lib/loop/loopClaude.js +0 -152
- package/lib/loop/loopOpenAI.js +0 -141
- package/lib/loop/main.js +0 -60
- package/lib/loopTools/context.js +0 -67
- package/lib/loopTools/main.js +0 -54
- package/lib/loopTools/perform.js +0 -32
- package/lib/loopTools/snapshot.js +0 -29
- package/lib/loopTools/tool.js +0 -18
- package/lib/mcp/http.js +0 -120
- package/lib/mcp/inProcessTransport.js +0 -72
- package/lib/mcp/proxyBackend.js +0 -104
- package/lib/mcp/server.js +0 -123
- package/lib/mcp/tool.js +0 -29
- package/lib/program.js +0 -145
- package/lib/response.js +0 -165
- package/lib/sessionLog.js +0 -121
- package/lib/tab.js +0 -249
- package/lib/tools/common.js +0 -55
- package/lib/tools/console.js +0 -33
- package/lib/tools/dialogs.js +0 -47
- package/lib/tools/evaluate.js +0 -53
- package/lib/tools/files.js +0 -44
- package/lib/tools/install.js +0 -53
- package/lib/tools/keyboard.js +0 -78
- package/lib/tools/mouse.js +0 -99
- package/lib/tools/navigate.js +0 -70
- package/lib/tools/network.js +0 -41
- package/lib/tools/pdf.js +0 -40
- package/lib/tools/roxy.js +0 -50
- package/lib/tools/screenshot.js +0 -79
- package/lib/tools/snapshot.js +0 -139
- package/lib/tools/tabs.js +0 -87
- package/lib/tools/tool.js +0 -33
- package/lib/tools/utils.js +0 -74
- package/lib/tools/wait.js +0 -55
- package/lib/tools.js +0 -52
- package/lib/utils/codegen.js +0 -49
- package/lib/utils/fileUtils.js +0 -36
- package/lib/utils/guid.js +0 -22
- package/lib/utils/log.js +0 -21
- package/lib/utils/manualPromise.js +0 -111
- package/lib/utils/package.js +0 -20
- package/lib/vscode/host.js +0 -128
- package/lib/vscode/main.js +0 -62
package/README.md
CHANGED
|
@@ -1,742 +1,832 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
--
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
--
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
--
|
|
214
|
-
--
|
|
215
|
-
|
|
216
|
-
--
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
--
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
--
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// Browser
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
//
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
```
|
|
389
|
-
{
|
|
390
|
-
"mcpServers": {
|
|
391
|
-
"playwright": {
|
|
392
|
-
"command": "
|
|
393
|
-
"args": ["
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
- **
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
-
|
|
529
|
-
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
- **
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
- **
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
-
|
|
552
|
-
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
-
|
|
560
|
-
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
-
|
|
579
|
-
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
- `
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
-
|
|
590
|
-
-
|
|
591
|
-
|
|
592
|
-
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
-
|
|
598
|
-
-
|
|
599
|
-
-
|
|
600
|
-
|
|
601
|
-
- `
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
-
|
|
611
|
-
|
|
612
|
-
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
-
|
|
643
|
-
|
|
644
|
-
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
-
|
|
651
|
-
-
|
|
652
|
-
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
-
|
|
660
|
-
|
|
661
|
-
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
<!-- NOTE: This has been generated via update-readme.js -->
|
|
678
|
-
|
|
679
|
-
- **
|
|
680
|
-
- Title:
|
|
681
|
-
- Description:
|
|
682
|
-
- Parameters: None
|
|
683
|
-
- Read-only: **
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
- `
|
|
708
|
-
- `
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
</
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
-
|
|
733
|
-
|
|
734
|
-
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
1
|
+
> This repository contains a customized Playwright MCP for RoxyBrowser, designed to enable RoxyBrowser users to control RoxyChrome-based browsers through AI. For more details, please refer to: [RoxyBrowser Now Supports MCP — AI Can Finally Do the Work for You](https://roxybrowser.com/blog/roxybrowser-mcp-integration)
|
|
2
|
+
|
|
3
|
+
## Playwright MCP
|
|
4
|
+
|
|
5
|
+
A Model Context Protocol (MCP) server that provides browser automation capabilities using [Playwright](https://playwright.dev). This server enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models.
|
|
6
|
+
|
|
7
|
+
### Key Features
|
|
8
|
+
|
|
9
|
+
- **Fast and lightweight**. Uses Playwright's accessibility tree, not pixel-based input.
|
|
10
|
+
- **LLM-friendly**. No vision models needed, operates purely on structured data.
|
|
11
|
+
- **Deterministic tool application**. Avoids ambiguity common with screenshot-based approaches.
|
|
12
|
+
|
|
13
|
+
### Requirements
|
|
14
|
+
- Node.js 18 or newer
|
|
15
|
+
- VS Code, Cursor, Windsurf, Claude Desktop, Goose or any other MCP client
|
|
16
|
+
|
|
17
|
+
<!--
|
|
18
|
+
// Generate using:
|
|
19
|
+
node utils/generate-links.js
|
|
20
|
+
-->
|
|
21
|
+
|
|
22
|
+
### Getting started
|
|
23
|
+
|
|
24
|
+
First, install the Playwright MCP server with your client.
|
|
25
|
+
|
|
26
|
+
**推荐:使用本包(含 Roxy 连接等扩展)**
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"roxybrowser-playwright-mcp": {
|
|
32
|
+
"command": "npx",
|
|
33
|
+
"args": [
|
|
34
|
+
"@roxybrowser/playwright-mcp@latest"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
如需 HTTP(Studio 协议)连接,可先启动服务再在配置里填 URL:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx @roxybrowser/playwright-mcp --port 9324
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"roxybrowser-playwright-mcp": {
|
|
51
|
+
"url": "http://localhost:9324/mcp"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
[<img src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Server&color=0098FF" alt="Install in VS Code">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D) [<img alt="Install in VS Code Insiders" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Server&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
<details>
|
|
61
|
+
<summary>Claude Code</summary>
|
|
62
|
+
|
|
63
|
+
Use the Claude Code CLI to add the Playwright MCP server:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
claude mcp add playwright npx @playwright/mcp@latest
|
|
67
|
+
```
|
|
68
|
+
</details>
|
|
69
|
+
|
|
70
|
+
<details>
|
|
71
|
+
<summary>Claude Desktop</summary>
|
|
72
|
+
|
|
73
|
+
Follow the MCP install [guide](https://modelcontextprotocol.io/quickstart/user), use the standard config above.
|
|
74
|
+
|
|
75
|
+
</details>
|
|
76
|
+
|
|
77
|
+
<details>
|
|
78
|
+
<summary>Codex</summary>
|
|
79
|
+
|
|
80
|
+
Create or edit the configuration file `~/.codex/config.toml` and add:
|
|
81
|
+
|
|
82
|
+
```toml
|
|
83
|
+
[mcp_servers.playwright]
|
|
84
|
+
command = "npx"
|
|
85
|
+
args = ["@playwright/mcp@latest"]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
For more information, see the [Codex MCP documentation](https://github.com/openai/codex/blob/main/codex-rs/config.md#mcp_servers).
|
|
89
|
+
|
|
90
|
+
</details>
|
|
91
|
+
|
|
92
|
+
<details>
|
|
93
|
+
<summary>Cursor</summary>
|
|
94
|
+
|
|
95
|
+
#### Click the button to install:
|
|
96
|
+
|
|
97
|
+
[](cursor://anysphere.cursor-deeplink/mcp/install?name=Playwright&config=eyJjb21tYW5kIjoibnB4IEBwbGF5d3JpZ2h0L21jcEBsYXRlc3QifQ%3D%3D)
|
|
98
|
+
|
|
99
|
+
#### Or install manually:
|
|
100
|
+
|
|
101
|
+
Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name to your liking, use `command` type with the command `npx @playwright/mcp`. You can also verify config or add command like arguments via clicking `Edit`.
|
|
102
|
+
|
|
103
|
+
</details>
|
|
104
|
+
|
|
105
|
+
<details>
|
|
106
|
+
<summary>Gemini CLI</summary>
|
|
107
|
+
|
|
108
|
+
Follow the MCP install [guide](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md#configure-the-mcp-server-in-settingsjson), use the standard config above.
|
|
109
|
+
|
|
110
|
+
</details>
|
|
111
|
+
|
|
112
|
+
<details>
|
|
113
|
+
<summary>Goose</summary>
|
|
114
|
+
|
|
115
|
+
#### Click the button to install:
|
|
116
|
+
|
|
117
|
+
[](https://block.github.io/goose/extension?cmd=npx&arg=%40playwright%2Fmcp%40latest&id=playwright&name=Playwright&description=Interact%20with%20web%20pages%20through%20structured%20accessibility%20snapshots%20using%20Playwright)
|
|
118
|
+
|
|
119
|
+
#### Or install manually:
|
|
120
|
+
|
|
121
|
+
Go to `Advanced settings` -> `Extensions` -> `Add custom extension`. Name to your liking, use type `STDIO`, and set the `command` to `npx @playwright/mcp`. Click "Add Extension".
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
<details>
|
|
125
|
+
<summary>LM Studio</summary>
|
|
126
|
+
|
|
127
|
+
#### Click the button to install:
|
|
128
|
+
|
|
129
|
+
[](https://lmstudio.ai/install-mcp?name=playwright&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAcGxheXdyaWdodC9tY3BAbGF0ZXN0Il19)
|
|
130
|
+
|
|
131
|
+
#### Or install manually:
|
|
132
|
+
|
|
133
|
+
Go to `Program` in the right sidebar -> `Install` -> `Edit mcp.json`. Use the standard config above.
|
|
134
|
+
</details>
|
|
135
|
+
|
|
136
|
+
<details>
|
|
137
|
+
<summary>opencode</summary>
|
|
138
|
+
|
|
139
|
+
Follow the MCP Servers [documentation](https://opencode.ai/docs/mcp-servers/). For example in `~/.config/opencode/opencode.json`:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"$schema": "https://opencode.ai/config.json",
|
|
144
|
+
"mcp": {
|
|
145
|
+
"playwright": {
|
|
146
|
+
"type": "local",
|
|
147
|
+
"command": [
|
|
148
|
+
"npx",
|
|
149
|
+
"@playwright/mcp@latest"
|
|
150
|
+
],
|
|
151
|
+
"enabled": true
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
</details>
|
|
158
|
+
|
|
159
|
+
<details>
|
|
160
|
+
<summary>Qodo Gen</summary>
|
|
161
|
+
|
|
162
|
+
Open [Qodo Gen](https://docs.qodo.ai/qodo-documentation/qodo-gen) chat panel in VSCode or IntelliJ → Connect more tools → + Add new MCP → Paste the standard config above.
|
|
163
|
+
|
|
164
|
+
Click <code>Save</code>.
|
|
165
|
+
</details>
|
|
166
|
+
|
|
167
|
+
<details>
|
|
168
|
+
<summary>VS Code</summary>
|
|
169
|
+
|
|
170
|
+
#### Click the button to install:
|
|
171
|
+
|
|
172
|
+
[<img src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Server&color=0098FF" alt="Install in VS Code">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D) [<img alt="Install in VS Code Insiders" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Server&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522playwright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D)
|
|
173
|
+
|
|
174
|
+
#### Or install manually:
|
|
175
|
+
|
|
176
|
+
Follow the MCP install [guide](https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server), use the standard config above. You can also install the Playwright MCP server using the VS Code CLI:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# For VS Code
|
|
180
|
+
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
After installation, the Playwright MCP server will be available for use with your GitHub Copilot agent in VS Code.
|
|
184
|
+
</details>
|
|
185
|
+
|
|
186
|
+
<details>
|
|
187
|
+
<summary>Windsurf</summary>
|
|
188
|
+
|
|
189
|
+
Follow Windsurf MCP [documentation](https://docs.windsurf.com/windsurf/cascade/mcp). Use the standard config above.
|
|
190
|
+
|
|
191
|
+
</details>
|
|
192
|
+
|
|
193
|
+
### Configuration
|
|
194
|
+
|
|
195
|
+
Playwright MCP server supports following arguments. They can be provided in the JSON configuration above, as a part of the `"args"` list:
|
|
196
|
+
|
|
197
|
+
<!--- Options generated by update-readme.js -->
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
> npx @playwright/mcp@latest --help
|
|
201
|
+
--allowed-origins <origins> semicolon-separated list of origins to allow the
|
|
202
|
+
browser to request. Default is to allow all.
|
|
203
|
+
--blocked-origins <origins> semicolon-separated list of origins to block the
|
|
204
|
+
browser from requesting. Blocklist is evaluated
|
|
205
|
+
before allowlist. If used without the allowlist,
|
|
206
|
+
requests not matching the blocklist are still
|
|
207
|
+
allowed.
|
|
208
|
+
--block-service-workers block service workers
|
|
209
|
+
--browser <browser> browser or chrome channel to use, possible
|
|
210
|
+
values: chrome, firefox, webkit, msedge.
|
|
211
|
+
--caps <caps> comma-separated list of additional capabilities
|
|
212
|
+
to enable, possible values: vision, pdf.
|
|
213
|
+
--cdp-endpoint <endpoint> CDP endpoint to connect to.
|
|
214
|
+
--config <path> path to the configuration file.
|
|
215
|
+
--device <device> device to emulate, for example: "iPhone 15"
|
|
216
|
+
--executable-path <path> path to the browser executable.
|
|
217
|
+
--extension Connect to a running browser instance
|
|
218
|
+
(Edge/Chrome only). Requires the "Playwright MCP
|
|
219
|
+
Bridge" browser extension to be installed.
|
|
220
|
+
--headless run browser in headless mode, headed by default
|
|
221
|
+
--host <host> host to bind server to. Default is localhost. Use
|
|
222
|
+
0.0.0.0 to bind to all interfaces.
|
|
223
|
+
--ignore-https-errors ignore https errors
|
|
224
|
+
--isolated keep the browser profile in memory, do not save
|
|
225
|
+
it to disk.
|
|
226
|
+
--image-responses <mode> whether to send image responses to the client.
|
|
227
|
+
Can be "allow" or "omit", Defaults to "allow".
|
|
228
|
+
--no-sandbox disable the sandbox for all process types that
|
|
229
|
+
are normally sandboxed.
|
|
230
|
+
--output-dir <path> path to the directory for output files.
|
|
231
|
+
--port <port> port to listen on for SSE transport.
|
|
232
|
+
--proxy-bypass <bypass> comma-separated domains to bypass proxy, for
|
|
233
|
+
example ".com,chromium.org,.domain.com"
|
|
234
|
+
--proxy-server <proxy> specify proxy server, for example
|
|
235
|
+
"http://myproxy:3128" or "socks5://myproxy:8080"
|
|
236
|
+
--save-session Whether to save the Playwright MCP session into
|
|
237
|
+
the output directory.
|
|
238
|
+
--save-trace Whether to save the Playwright Trace of the
|
|
239
|
+
session into the output directory.
|
|
240
|
+
--storage-state <path> path to the storage state file for isolated
|
|
241
|
+
sessions.
|
|
242
|
+
--user-agent <ua string> specify user agent string
|
|
243
|
+
--user-data-dir <path> path to the user data directory. If not
|
|
244
|
+
specified, a temporary directory will be created.
|
|
245
|
+
--viewport-size <size> specify browser viewport size in pixels, for
|
|
246
|
+
example "1280, 720"
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
<!--- End of options generated section -->
|
|
250
|
+
|
|
251
|
+
### User profile
|
|
252
|
+
|
|
253
|
+
You can run Playwright MCP with persistent profile like a regular browser (default), in isolated contexts for testing sessions, or connect to your existing browser using the browser extension.
|
|
254
|
+
|
|
255
|
+
**Persistent profile**
|
|
256
|
+
|
|
257
|
+
All the logged in information will be stored in the persistent profile, you can delete it between sessions if you'd like to clear the offline state.
|
|
258
|
+
Persistent profile is located at the following locations and you can override it with the `--user-data-dir` argument.
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Windows
|
|
262
|
+
%USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile
|
|
263
|
+
|
|
264
|
+
# macOS
|
|
265
|
+
- ~/Library/Caches/ms-playwright/mcp-{channel}-profile
|
|
266
|
+
|
|
267
|
+
# Linux
|
|
268
|
+
- ~/.cache/ms-playwright/mcp-{channel}-profile
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Isolated**
|
|
272
|
+
|
|
273
|
+
In the isolated mode, each session is started in the isolated profile. Every time you ask MCP to close the browser,
|
|
274
|
+
the session is closed and all the storage state for this session is lost. You can provide initial storage state
|
|
275
|
+
to the browser via the config's `contextOptions` or via the `--storage-state` argument. Learn more about the storage
|
|
276
|
+
state [here](https://playwright.dev/docs/auth).
|
|
277
|
+
|
|
278
|
+
```js
|
|
279
|
+
{
|
|
280
|
+
"mcpServers": {
|
|
281
|
+
"playwright": {
|
|
282
|
+
"command": "npx",
|
|
283
|
+
"args": [
|
|
284
|
+
"@playwright/mcp@latest",
|
|
285
|
+
"--isolated",
|
|
286
|
+
"--storage-state={path/to/storage.json}"
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Browser Extension**
|
|
294
|
+
|
|
295
|
+
The Playwright MCP Chrome Extension allows you to connect to existing browser tabs and leverage your logged-in sessions and browser state. See [extension/README.md](extension/README.md) for installation and setup instructions.
|
|
296
|
+
|
|
297
|
+
### Configuration file
|
|
298
|
+
|
|
299
|
+
The Playwright MCP server can be configured using a JSON configuration file. You can specify the configuration file
|
|
300
|
+
using the `--config` command line option:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
npx @playwright/mcp@latest --config path/to/config.json
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
<details>
|
|
307
|
+
<summary>Configuration file schema</summary>
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
{
|
|
311
|
+
// Browser configuration
|
|
312
|
+
browser?: {
|
|
313
|
+
// Browser type to use (chromium, firefox, or webkit)
|
|
314
|
+
browserName?: 'chromium' | 'firefox' | 'webkit';
|
|
315
|
+
|
|
316
|
+
// Keep the browser profile in memory, do not save it to disk.
|
|
317
|
+
isolated?: boolean;
|
|
318
|
+
|
|
319
|
+
// Path to user data directory for browser profile persistence
|
|
320
|
+
userDataDir?: string;
|
|
321
|
+
|
|
322
|
+
// Browser launch options (see Playwright docs)
|
|
323
|
+
// @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch
|
|
324
|
+
launchOptions?: {
|
|
325
|
+
channel?: string; // Browser channel (e.g. 'chrome')
|
|
326
|
+
headless?: boolean; // Run in headless mode
|
|
327
|
+
executablePath?: string; // Path to browser executable
|
|
328
|
+
// ... other Playwright launch options
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// Browser context options
|
|
332
|
+
// @see https://playwright.dev/docs/api/class-browser#browser-new-context
|
|
333
|
+
contextOptions?: {
|
|
334
|
+
viewport?: { width: number, height: number };
|
|
335
|
+
// ... other Playwright context options
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// CDP endpoint for connecting to existing browser
|
|
339
|
+
cdpEndpoint?: string;
|
|
340
|
+
|
|
341
|
+
// Remote Playwright server endpoint
|
|
342
|
+
remoteEndpoint?: string;
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
// Server configuration
|
|
346
|
+
server?: {
|
|
347
|
+
port?: number; // Port to listen on
|
|
348
|
+
host?: string; // Host to bind to (default: localhost)
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
// List of additional capabilities
|
|
352
|
+
capabilities?: Array<
|
|
353
|
+
'tabs' | // Tab management
|
|
354
|
+
'install' | // Browser installation
|
|
355
|
+
'pdf' | // PDF generation
|
|
356
|
+
'vision' | // Coordinate-based interactions
|
|
357
|
+
>;
|
|
358
|
+
|
|
359
|
+
// Directory for output files
|
|
360
|
+
outputDir?: string;
|
|
361
|
+
|
|
362
|
+
// Network configuration
|
|
363
|
+
network?: {
|
|
364
|
+
// List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
365
|
+
allowedOrigins?: string[];
|
|
366
|
+
|
|
367
|
+
// List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
368
|
+
blockedOrigins?: string[];
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Whether to send image responses to the client. Can be "allow" or "omit".
|
|
373
|
+
* Defaults to "allow".
|
|
374
|
+
*/
|
|
375
|
+
imageResponses?: 'allow' | 'omit';
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
</details>
|
|
379
|
+
|
|
380
|
+
### 第三方集成与程序化调用
|
|
381
|
+
|
|
382
|
+
本包支持三种使用方式,便于接入 Cursor/IDE 或自建应用。
|
|
383
|
+
|
|
384
|
+
#### 1. CLI 快速启动(stdio)
|
|
385
|
+
|
|
386
|
+
在 MCP 客户端配置中指定 command,由客户端拉起进程、通过 stdio 通信:
|
|
387
|
+
|
|
388
|
+
```json
|
|
389
|
+
{
|
|
390
|
+
"mcpServers": {
|
|
391
|
+
"roxybrowser-playwright-mcp": {
|
|
392
|
+
"command": "npx",
|
|
393
|
+
"args": ["@roxybrowser/playwright-mcp@latest"]
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### 2. Studio 协议(HTTP/SSE)
|
|
400
|
+
|
|
401
|
+
通过代码启动 HTTP 服务,第三方应用用 URL 连接(如 Studio、自研前端):
|
|
402
|
+
|
|
403
|
+
```js
|
|
404
|
+
import { startServer } from '@roxybrowser/playwright-mcp';
|
|
405
|
+
|
|
406
|
+
const { url } = await startServer({ port: 9324, host: 'localhost' });
|
|
407
|
+
console.log('MCP URL:', url); // http://localhost:9324/mcp
|
|
408
|
+
// 进程持续运行,客户端连接 url 即可
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
也可直接用 CLI 起 HTTP 服务,再在客户端填 URL:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
npx @roxybrowser/playwright-mcp --port 9324
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
```json
|
|
418
|
+
{ "mcpServers": { "roxybrowser-playwright-mcp": { "url": "http://localhost:9324/mcp" } } }
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### 3. 程序化 createConnection(自管 transport)
|
|
422
|
+
|
|
423
|
+
在进程内创建 MCP Server,自行连接 stdio 或自定义 transport,便于嵌入到其他应用:
|
|
424
|
+
|
|
425
|
+
```js
|
|
426
|
+
import { createConnection } from '@roxybrowser/playwright-mcp';
|
|
427
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
428
|
+
|
|
429
|
+
const server = await createConnection(); // 可选:传入 config 或 contextGetter
|
|
430
|
+
await server.connect(new StdioServerTransport());
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
#### 4. 导出工具类(扩展或二次封装)
|
|
434
|
+
|
|
435
|
+
如需继承 Backend、增加自定义工具或复用 Roxy 连接逻辑,可从主入口引用:
|
|
436
|
+
|
|
437
|
+
```js
|
|
438
|
+
import {
|
|
439
|
+
createConnection,
|
|
440
|
+
startServer,
|
|
441
|
+
CustomBackend,
|
|
442
|
+
DynamicCdpContextFactory,
|
|
443
|
+
defineExtraTool,
|
|
444
|
+
extraToolToMcp,
|
|
445
|
+
} from '@roxybrowser/playwright-mcp';
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
- **CustomBackend**:在 Playwright 官方工具基础上增加 `browser_connect_roxy` 等,可子类化继续加工具。
|
|
449
|
+
- **DynamicCdpContextFactory**:支持 `reconnectToCDP(endpoint)` 的 context 工厂,用于 Roxy/CDP 连接。
|
|
450
|
+
- **defineExtraTool** / **extraToolToMcp**:定义额外 MCP 工具并转为 listTools 格式的辅助函数。
|
|
451
|
+
|
|
452
|
+
### Standalone MCP server
|
|
453
|
+
|
|
454
|
+
When running headed browser on system w/o display or from worker processes of the IDEs,
|
|
455
|
+
run the MCP server from environment with the DISPLAY and pass the `--port` flag to enable HTTP transport.
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
npx @playwright/mcp@latest --port 8931
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
And then in MCP client config, set the `url` to the HTTP endpoint:
|
|
462
|
+
|
|
463
|
+
```js
|
|
464
|
+
{
|
|
465
|
+
"mcpServers": {
|
|
466
|
+
"playwright": {
|
|
467
|
+
"url": "http://localhost:8931/mcp"
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
<details>
|
|
474
|
+
<summary><b>Docker</b></summary>
|
|
475
|
+
|
|
476
|
+
**NOTE:** The Docker implementation only supports headless chromium at the moment.
|
|
477
|
+
|
|
478
|
+
```js
|
|
479
|
+
{
|
|
480
|
+
"mcpServers": {
|
|
481
|
+
"playwright": {
|
|
482
|
+
"command": "docker",
|
|
483
|
+
"args": ["run", "-i", "--rm", "--init", "--pull=always", "mcr.microsoft.com/playwright/mcp"]
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
You can build the Docker image yourself.
|
|
490
|
+
|
|
491
|
+
```
|
|
492
|
+
docker build -t mcr.microsoft.com/playwright/mcp .
|
|
493
|
+
```
|
|
494
|
+
</details>
|
|
495
|
+
|
|
496
|
+
<details>
|
|
497
|
+
<summary><b>Programmatic usage</b></summary>
|
|
498
|
+
|
|
499
|
+
```js
|
|
500
|
+
import http from 'http';
|
|
501
|
+
|
|
502
|
+
import { createConnection } from '@playwright/mcp';
|
|
503
|
+
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
|
504
|
+
|
|
505
|
+
http.createServer(async (req, res) => {
|
|
506
|
+
// ...
|
|
507
|
+
|
|
508
|
+
// Creates a headless Playwright MCP server with SSE transport
|
|
509
|
+
const connection = await createConnection({ browser: { launchOptions: { headless: true } } });
|
|
510
|
+
const transport = new SSEServerTransport('/messages', res);
|
|
511
|
+
await connection.sever.connect(transport);
|
|
512
|
+
|
|
513
|
+
// ...
|
|
514
|
+
});
|
|
515
|
+
```
|
|
516
|
+
</details>
|
|
517
|
+
|
|
518
|
+
### Tools
|
|
519
|
+
|
|
520
|
+
<!--- Tools generated by update-readme.js -->
|
|
521
|
+
|
|
522
|
+
<details>
|
|
523
|
+
<summary><b>Core automation</b></summary>
|
|
524
|
+
|
|
525
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
526
|
+
|
|
527
|
+
- **browser_click**
|
|
528
|
+
- Title: Click
|
|
529
|
+
- Description: Perform click on a web page
|
|
530
|
+
- Parameters:
|
|
531
|
+
- `element` (string): Human-readable element description used to obtain permission to interact with the element
|
|
532
|
+
- `ref` (string): Exact target element reference from the page snapshot
|
|
533
|
+
- `doubleClick` (boolean, optional): Whether to perform a double click instead of a single click
|
|
534
|
+
- `button` (string, optional): Button to click, defaults to left
|
|
535
|
+
- Read-only: **false**
|
|
536
|
+
|
|
537
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
538
|
+
|
|
539
|
+
- **browser_close**
|
|
540
|
+
- Title: Close browser
|
|
541
|
+
- Description: Close the page
|
|
542
|
+
- Parameters: None
|
|
543
|
+
- Read-only: **true**
|
|
544
|
+
|
|
545
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
546
|
+
|
|
547
|
+
- **browser_connect_roxy**
|
|
548
|
+
- Title: Connect to RoxyBrowser
|
|
549
|
+
- Description: Connect to RoxyBrowser using CDP WebSocket endpoint
|
|
550
|
+
- Parameters:
|
|
551
|
+
- `cdpEndpoint` (string): The CDP WebSocket endpoint URL from RoxyBrowser (e.g., ws://127.0.0.1:59305/devtools/browser/4d876b0b-6adc-4e9f-b572-bb68ff02a199)
|
|
552
|
+
- Read-only: **false**
|
|
553
|
+
|
|
554
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
555
|
+
|
|
556
|
+
- **browser_console_messages**
|
|
557
|
+
- Title: Get console messages
|
|
558
|
+
- Description: Returns all console messages
|
|
559
|
+
- Parameters: None
|
|
560
|
+
- Read-only: **true**
|
|
561
|
+
|
|
562
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
563
|
+
|
|
564
|
+
- **browser_drag**
|
|
565
|
+
- Title: Drag mouse
|
|
566
|
+
- Description: Perform drag and drop between two elements
|
|
567
|
+
- Parameters:
|
|
568
|
+
- `startElement` (string): Human-readable source element description used to obtain the permission to interact with the element
|
|
569
|
+
- `startRef` (string): Exact source element reference from the page snapshot
|
|
570
|
+
- `endElement` (string): Human-readable target element description used to obtain the permission to interact with the element
|
|
571
|
+
- `endRef` (string): Exact target element reference from the page snapshot
|
|
572
|
+
- Read-only: **false**
|
|
573
|
+
|
|
574
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
575
|
+
|
|
576
|
+
- **browser_evaluate**
|
|
577
|
+
- Title: Evaluate JavaScript
|
|
578
|
+
- Description: Evaluate JavaScript expression on page or element
|
|
579
|
+
- Parameters:
|
|
580
|
+
- `function` (string): () => { /* code */ } or (element) => { /* code */ } when element is provided
|
|
581
|
+
- `element` (string, optional): Human-readable element description used to obtain permission to interact with the element
|
|
582
|
+
- `ref` (string, optional): Exact target element reference from the page snapshot
|
|
583
|
+
- Read-only: **false**
|
|
584
|
+
|
|
585
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
586
|
+
|
|
587
|
+
- **browser_file_upload**
|
|
588
|
+
- Title: Upload files
|
|
589
|
+
- Description: Upload one or multiple files
|
|
590
|
+
- Parameters:
|
|
591
|
+
- `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.
|
|
592
|
+
- Read-only: **false**
|
|
593
|
+
|
|
594
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
595
|
+
|
|
596
|
+
- **browser_handle_dialog**
|
|
597
|
+
- Title: Handle a dialog
|
|
598
|
+
- Description: Handle a dialog
|
|
599
|
+
- Parameters:
|
|
600
|
+
- `accept` (boolean): Whether to accept the dialog.
|
|
601
|
+
- `promptText` (string, optional): The text of the prompt in case of a prompt dialog.
|
|
602
|
+
- Read-only: **false**
|
|
603
|
+
|
|
604
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
605
|
+
|
|
606
|
+
- **browser_hover**
|
|
607
|
+
- Title: Hover mouse
|
|
608
|
+
- Description: Hover over element on page
|
|
609
|
+
- Parameters:
|
|
610
|
+
- `element` (string): Human-readable element description used to obtain permission to interact with the element
|
|
611
|
+
- `ref` (string): Exact target element reference from the page snapshot
|
|
612
|
+
- Read-only: **true**
|
|
613
|
+
|
|
614
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
615
|
+
|
|
616
|
+
- **browser_navigate**
|
|
617
|
+
- Title: Navigate to a URL
|
|
618
|
+
- Description: Navigate to a URL
|
|
619
|
+
- Parameters:
|
|
620
|
+
- `url` (string): The URL to navigate to
|
|
621
|
+
- Read-only: **false**
|
|
622
|
+
|
|
623
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
624
|
+
|
|
625
|
+
- **browser_navigate_back**
|
|
626
|
+
- Title: Go back
|
|
627
|
+
- Description: Go back to the previous page
|
|
628
|
+
- Parameters: None
|
|
629
|
+
- Read-only: **true**
|
|
630
|
+
|
|
631
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
632
|
+
|
|
633
|
+
- **browser_navigate_forward**
|
|
634
|
+
- Title: Go forward
|
|
635
|
+
- Description: Go forward to the next page
|
|
636
|
+
- Parameters: None
|
|
637
|
+
- Read-only: **true**
|
|
638
|
+
|
|
639
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
640
|
+
|
|
641
|
+
- **browser_network_requests**
|
|
642
|
+
- Title: List network requests
|
|
643
|
+
- Description: Returns all network requests since loading the page
|
|
644
|
+
- Parameters: None
|
|
645
|
+
- Read-only: **true**
|
|
646
|
+
|
|
647
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
648
|
+
|
|
649
|
+
- **browser_press_key**
|
|
650
|
+
- Title: Press a key
|
|
651
|
+
- Description: Press a key on the keyboard
|
|
652
|
+
- Parameters:
|
|
653
|
+
- `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
|
|
654
|
+
- Read-only: **false**
|
|
655
|
+
|
|
656
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
657
|
+
|
|
658
|
+
- **browser_resize**
|
|
659
|
+
- Title: Resize browser window
|
|
660
|
+
- Description: Resize the browser window
|
|
661
|
+
- Parameters:
|
|
662
|
+
- `width` (number): Width of the browser window
|
|
663
|
+
- `height` (number): Height of the browser window
|
|
664
|
+
- Read-only: **true**
|
|
665
|
+
|
|
666
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
667
|
+
|
|
668
|
+
- **browser_select_option**
|
|
669
|
+
- Title: Select option
|
|
670
|
+
- Description: Select an option in a dropdown
|
|
671
|
+
- Parameters:
|
|
672
|
+
- `element` (string): Human-readable element description used to obtain permission to interact with the element
|
|
673
|
+
- `ref` (string): Exact target element reference from the page snapshot
|
|
674
|
+
- `values` (array): Array of values to select in the dropdown. This can be a single value or multiple values.
|
|
675
|
+
- Read-only: **false**
|
|
676
|
+
|
|
677
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
678
|
+
|
|
679
|
+
- **browser_snapshot**
|
|
680
|
+
- Title: Page snapshot
|
|
681
|
+
- Description: Capture accessibility snapshot of the current page, this is better than screenshot
|
|
682
|
+
- Parameters: None
|
|
683
|
+
- Read-only: **true**
|
|
684
|
+
|
|
685
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
686
|
+
|
|
687
|
+
- **browser_take_screenshot**
|
|
688
|
+
- Title: Take a screenshot
|
|
689
|
+
- Description: Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.
|
|
690
|
+
- Parameters:
|
|
691
|
+
- `type` (string, optional): Image format for the screenshot. Default is png.
|
|
692
|
+
- `filename` (string, optional): File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.
|
|
693
|
+
- `element` (string, optional): Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too.
|
|
694
|
+
- `ref` (string, optional): Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too.
|
|
695
|
+
- `fullPage` (boolean, optional): When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.
|
|
696
|
+
- Read-only: **true**
|
|
697
|
+
|
|
698
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
699
|
+
|
|
700
|
+
- **browser_type**
|
|
701
|
+
- Title: Type text
|
|
702
|
+
- Description: Type text into editable element
|
|
703
|
+
- Parameters:
|
|
704
|
+
- `element` (string): Human-readable element description used to obtain permission to interact with the element
|
|
705
|
+
- `ref` (string): Exact target element reference from the page snapshot
|
|
706
|
+
- `text` (string): Text to type into the element
|
|
707
|
+
- `submit` (boolean, optional): Whether to submit entered text (press Enter after)
|
|
708
|
+
- `slowly` (boolean, optional): Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.
|
|
709
|
+
- Read-only: **false**
|
|
710
|
+
|
|
711
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
712
|
+
|
|
713
|
+
- **browser_wait_for**
|
|
714
|
+
- Title: Wait for
|
|
715
|
+
- Description: Wait for text to appear or disappear or a specified time to pass
|
|
716
|
+
- Parameters:
|
|
717
|
+
- `time` (number, optional): The time to wait in seconds
|
|
718
|
+
- `text` (string, optional): The text to wait for
|
|
719
|
+
- `textGone` (string, optional): The text to wait for to disappear
|
|
720
|
+
- Read-only: **true**
|
|
721
|
+
|
|
722
|
+
</details>
|
|
723
|
+
|
|
724
|
+
<details>
|
|
725
|
+
<summary><b>Tab management</b></summary>
|
|
726
|
+
|
|
727
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
728
|
+
|
|
729
|
+
- **browser_tab_close**
|
|
730
|
+
- Title: Close a tab
|
|
731
|
+
- Description: Close a tab
|
|
732
|
+
- Parameters:
|
|
733
|
+
- `index` (number, optional): The index of the tab to close. Closes current tab if not provided.
|
|
734
|
+
- Read-only: **false**
|
|
735
|
+
|
|
736
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
737
|
+
|
|
738
|
+
- **browser_tab_list**
|
|
739
|
+
- Title: List tabs
|
|
740
|
+
- Description: List browser tabs
|
|
741
|
+
- Parameters: None
|
|
742
|
+
- Read-only: **true**
|
|
743
|
+
|
|
744
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
745
|
+
|
|
746
|
+
- **browser_tab_new**
|
|
747
|
+
- Title: Open a new tab
|
|
748
|
+
- Description: Open a new tab
|
|
749
|
+
- Parameters:
|
|
750
|
+
- `url` (string, optional): The URL to navigate to in the new tab. If not provided, the new tab will be blank.
|
|
751
|
+
- Read-only: **true**
|
|
752
|
+
|
|
753
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
754
|
+
|
|
755
|
+
- **browser_tab_select**
|
|
756
|
+
- Title: Select a tab
|
|
757
|
+
- Description: Select a tab by index
|
|
758
|
+
- Parameters:
|
|
759
|
+
- `index` (number): The index of the tab to select
|
|
760
|
+
- Read-only: **true**
|
|
761
|
+
|
|
762
|
+
</details>
|
|
763
|
+
|
|
764
|
+
<details>
|
|
765
|
+
<summary><b>Browser installation</b></summary>
|
|
766
|
+
|
|
767
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
768
|
+
|
|
769
|
+
- **browser_install**
|
|
770
|
+
- Title: Install the browser specified in the config
|
|
771
|
+
- Description: Install the browser specified in the config. Call this if you get an error about the browser not being installed.
|
|
772
|
+
- Parameters: None
|
|
773
|
+
- Read-only: **false**
|
|
774
|
+
|
|
775
|
+
</details>
|
|
776
|
+
|
|
777
|
+
<details>
|
|
778
|
+
<summary><b>Coordinate-based (opt-in via --caps=vision)</b></summary>
|
|
779
|
+
|
|
780
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
781
|
+
|
|
782
|
+
- **browser_mouse_click_xy**
|
|
783
|
+
- Title: Click
|
|
784
|
+
- Description: Click left mouse button at a given position
|
|
785
|
+
- Parameters:
|
|
786
|
+
- `element` (string): Human-readable element description used to obtain permission to interact with the element
|
|
787
|
+
- `x` (number): X coordinate
|
|
788
|
+
- `y` (number): Y coordinate
|
|
789
|
+
- Read-only: **false**
|
|
790
|
+
|
|
791
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
792
|
+
|
|
793
|
+
- **browser_mouse_drag_xy**
|
|
794
|
+
- Title: Drag mouse
|
|
795
|
+
- Description: Drag left mouse button to a given position
|
|
796
|
+
- Parameters:
|
|
797
|
+
- `element` (string): Human-readable element description used to obtain permission to interact with the element
|
|
798
|
+
- `startX` (number): Start X coordinate
|
|
799
|
+
- `startY` (number): Start Y coordinate
|
|
800
|
+
- `endX` (number): End X coordinate
|
|
801
|
+
- `endY` (number): End Y coordinate
|
|
802
|
+
- Read-only: **false**
|
|
803
|
+
|
|
804
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
805
|
+
|
|
806
|
+
- **browser_mouse_move_xy**
|
|
807
|
+
- Title: Move mouse
|
|
808
|
+
- Description: Move mouse to a given position
|
|
809
|
+
- Parameters:
|
|
810
|
+
- `element` (string): Human-readable element description used to obtain permission to interact with the element
|
|
811
|
+
- `x` (number): X coordinate
|
|
812
|
+
- `y` (number): Y coordinate
|
|
813
|
+
- Read-only: **true**
|
|
814
|
+
|
|
815
|
+
</details>
|
|
816
|
+
|
|
817
|
+
<details>
|
|
818
|
+
<summary><b>PDF generation (opt-in via --caps=pdf)</b></summary>
|
|
819
|
+
|
|
820
|
+
<!-- NOTE: This has been generated via update-readme.js -->
|
|
821
|
+
|
|
822
|
+
- **browser_pdf_save**
|
|
823
|
+
- Title: Save as PDF
|
|
824
|
+
- Description: Save page as PDF
|
|
825
|
+
- Parameters:
|
|
826
|
+
- `filename` (string, optional): File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.
|
|
827
|
+
- Read-only: **true**
|
|
828
|
+
|
|
829
|
+
</details>
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
<!--- End of tools generated section -->
|