patchright-mcp 0.0.58 → 0.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/config.d.ts +53 -10
  2. package/package.json +40 -49
  3. package/LICENSE +0 -202
  4. package/README.md +0 -1142
package/README.md DELETED
@@ -1,1142 +0,0 @@
1
- ## Patchright MCP
2
-
3
- > Note: This project is a minimal patch of the upstream playwright-mcp. It primarily swaps Playwright for Patchright and keeps the MCP API surface the same.
4
-
5
- A Model Context Protocol (MCP) server that provides browser automation capabilities using [Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright). 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 Patchright'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 Patchright MCP server with your client.
25
-
26
- **Standard config** works in most of the tools:
27
-
28
- ```js
29
- {
30
- "mcpServers": {
31
- "patchright": {
32
- "command": "npx",
33
- "args": [
34
- "patchright-mcp@latest"
35
- ]
36
- }
37
- }
38
- }
39
- ```
40
-
41
- [<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%2522patchright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522patchright-mcp%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%2522patchright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522patchright-mcp%2540latest%2522%255D%257D)
42
-
43
- <details>
44
- <summary>Amp</summary>
45
-
46
- Add via the Amp VS Code extension settings screen or by updating your settings.json file:
47
-
48
- ```json
49
- "amp.mcpServers": {
50
- "patchright": {
51
- "command": "npx",
52
- "args": [
53
- "patchright-mcp@latest"
54
- ]
55
- }
56
- }
57
- ```
58
-
59
- **Amp CLI Setup:**
60
-
61
- Add via the `amp mcp add`command below
62
-
63
- ```bash
64
- amp mcp add patchright -- npx patchright-mcp@latest
65
- ```
66
-
67
- </details>
68
-
69
- <details>
70
- <summary>Claude Code</summary>
71
-
72
- Use the Claude Code CLI to add the Patchright MCP server:
73
-
74
- ```bash
75
- claude mcp add patchright npx patchright-mcp@latest
76
- ```
77
- </details>
78
-
79
- <details>
80
- <summary>Claude Desktop</summary>
81
-
82
- Follow the MCP install [guide](https://modelcontextprotocol.io/quickstart/user), use the standard config above.
83
-
84
- </details>
85
-
86
- <details>
87
- <summary>Codex</summary>
88
-
89
- Use the Codex CLI to add the Patchright MCP server:
90
-
91
- ```bash
92
- codex mcp add patchright npx "patchright-mcp@latest"
93
- ```
94
-
95
- Alternatively, create or edit the configuration file `~/.codex/config.toml` and add:
96
-
97
- ```toml
98
- [mcp_servers.patchright]
99
- command = "npx"
100
- args = ["patchright-mcp@latest"]
101
- ```
102
-
103
- For more information, see the [Codex MCP documentation](https://github.com/openai/codex/blob/main/codex-rs/config.md#mcp_servers).
104
-
105
- </details>
106
-
107
- <details>
108
- <summary>Copilot</summary>
109
-
110
- Use the Copilot CLI to interactively add the Patchright MCP server:
111
-
112
- ```bash
113
- /mcp add
114
- ```
115
-
116
- Alternatively, create or edit the configuration file `~/.copilot/mcp-config.json` and add:
117
-
118
- ```json
119
- {
120
- "mcpServers": {
121
- "patchright": {
122
- "type": "local",
123
- "command": "npx",
124
- "tools": [
125
- "*"
126
- ],
127
- "args": [
128
- "patchright-mcp@latest"
129
- ]
130
- }
131
- }
132
- }
133
- ```
134
-
135
- For more information, see the [Copilot CLI documentation](https://docs.github.com/en/copilot/concepts/agents/about-copilot-cli).
136
-
137
- </details>
138
-
139
- <details>
140
- <summary>Cursor</summary>
141
-
142
- #### Click the button to install:
143
-
144
- [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=Patchright&config=eyJjb21tYW5kIjoibnB4IHBhdGNocmlnaHQtbWNwQGxhdGVzdCJ9)
145
-
146
- #### Or install manually:
147
-
148
- Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name to your liking, use `command` type with the command `npx patchright-mcp@latest`. You can also verify config or add command like arguments via clicking `Edit`.
149
-
150
- </details>
151
-
152
- <details>
153
- <summary>Factory</summary>
154
-
155
- Use the Factory CLI to add the Patchright MCP server:
156
-
157
- ```bash
158
- droid mcp add patchright "npx patchright-mcp@latest"
159
- ```
160
-
161
- Alternatively, type `/mcp` within Factory droid to open an interactive UI for managing MCP servers.
162
-
163
- For more information, see the [Factory MCP documentation](https://docs.factory.ai/cli/configuration/mcp).
164
-
165
- </details>
166
-
167
- <details>
168
- <summary>Gemini CLI</summary>
169
-
170
- 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.
171
-
172
- </details>
173
-
174
- <details>
175
- <summary>Goose</summary>
176
-
177
- #### Click the button to install:
178
-
179
- [![Install in Goose](https://block.github.io/goose/img/extension-install-dark.svg)](https://block.github.io/goose/extension?cmd=npx&arg=patchright-mcp%40latest&id=patchright&name=Patchright&description=Interact%20with%20web%20pages%20through%20structured%20accessibility%20snapshots%20using%20Patchright)
180
-
181
- #### Or install manually:
182
-
183
- Go to `Advanced settings` -> `Extensions` -> `Add custom extension`. Name to your liking, use type `STDIO`, and set the `command` to `npx patchright-mcp`. Click "Add Extension".
184
- </details>
185
-
186
- <details>
187
- <summary>Kiro</summary>
188
-
189
- Follow the MCP Servers [documentation](https://kiro.dev/docs/mcp/). For example in `.kiro/settings/mcp.json`:
190
-
191
- ```json
192
- {
193
- "mcpServers": {
194
- "patchright": {
195
- "command": "npx",
196
- "args": [
197
- "patchright-mcp@latest"
198
- ]
199
- }
200
- }
201
- }
202
- ```
203
- </details>
204
-
205
- <details>
206
- <summary>LM Studio</summary>
207
-
208
- #### Click the button to install:
209
-
210
- [![Add MCP Server patchright to LM Studio](https://files.lmstudio.ai/deeplink/mcp-install-light.svg)](https://lmstudio.ai/install-mcp?name=patchright&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJwYXRjaHJpZ2h0LW1jcEBsYXRlc3QiXX0=)
211
-
212
- #### Or install manually:
213
-
214
- Go to `Program` in the right sidebar -> `Install` -> `Edit mcp.json`. Use the standard config above.
215
- </details>
216
-
217
- <details>
218
- <summary>opencode</summary>
219
-
220
- Follow the MCP Servers [documentation](https://opencode.ai/docs/mcp-servers/). For example in `~/.config/opencode/opencode.json`:
221
-
222
- ```json
223
- {
224
- "$schema": "https://opencode.ai/config.json",
225
- "mcp": {
226
- "patchright": {
227
- "type": "local",
228
- "command": [
229
- "npx",
230
- "patchright-mcp@latest"
231
- ],
232
- "enabled": true
233
- }
234
- }
235
- }
236
-
237
- ```
238
- </details>
239
-
240
- <details>
241
- <summary>Qodo Gen</summary>
242
-
243
- 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.
244
-
245
- Click <code>Save</code>.
246
- </details>
247
-
248
- <details>
249
- <summary>VS Code</summary>
250
-
251
- #### Click the button to install:
252
-
253
- [<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%2522patchright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522patchright-mcp%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%2522patchright%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522patchright-mcp%2540latest%2522%255D%257D)
254
-
255
- #### Or install manually:
256
-
257
- 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 Patchright MCP server using the VS Code CLI:
258
-
259
- ```bash
260
- # For VS Code
261
- code --add-mcp '{"name":"patchright","command":"npx","args":["patchright-mcp@latest"]}'
262
- ```
263
-
264
- After installation, the Patchright MCP server will be available for use with your GitHub Copilot agent in VS Code.
265
- </details>
266
-
267
- <details>
268
- <summary>Warp</summary>
269
-
270
- Go to `Settings` -> `AI` -> `Manage MCP Servers` -> `+ Add` to [add an MCP Server](https://docs.warp.dev/knowledge-and-collaboration/mcp#adding-an-mcp-server). Use the standard config above.
271
-
272
- Alternatively, use the slash command `/add-mcp` in the Warp prompt and paste the standard config from above:
273
- ```js
274
- {
275
- "mcpServers": {
276
- "patchright": {
277
- "command": "npx",
278
- "args": [
279
- "patchright-mcp@latest"
280
- ]
281
- }
282
- }
283
- }
284
- ```
285
-
286
- </details>
287
-
288
- <details>
289
- <summary>Windsurf</summary>
290
-
291
- Follow Windsurf MCP [documentation](https://docs.windsurf.com/windsurf/cascade/mcp). Use the standard config above.
292
-
293
- </details>
294
-
295
- ### Configuration
296
-
297
- Patchright MCP server supports following arguments. They can be provided in the JSON configuration above, as a part of the `"args"` list:
298
-
299
- <!--- Options generated by update-readme.js -->
300
-
301
- ```
302
- > npx patchright-mcp@latest --help
303
- --allowed-hosts <hosts...> comma-separated list of hosts this
304
- server is allowed to serve from.
305
- Defaults to the host the server is bound
306
- to. Pass '*' to disable the host check.
307
- --allowed-origins <origins> semicolon-separated list of TRUSTED
308
- origins to allow the browser to request.
309
- Default is to allow all.
310
- Important: *does not* serve as a
311
- security boundary and *does not* affect
312
- redirects.
313
- --allow-unrestricted-file-access allow access to files outside of the
314
- workspace roots. Also allows
315
- unrestricted access to file:// URLs. By
316
- default access to file system is
317
- restricted to workspace root directories
318
- (or cwd if no roots are configured)
319
- only, and navigation to file:// URLs is
320
- blocked.
321
- --blocked-origins <origins> semicolon-separated list of origins to
322
- block the browser from requesting.
323
- Blocklist is evaluated before allowlist.
324
- If used without the allowlist, requests
325
- not matching the blocklist are still
326
- allowed.
327
- Important: *does not* serve as a
328
- security boundary and *does not* affect
329
- redirects.
330
- --block-service-workers block service workers
331
- --browser <browser> browser or chrome channel to use,
332
- possible values: chrome, firefox,
333
- webkit, msedge.
334
- --caps <caps> comma-separated list of additional
335
- capabilities to enable, possible values:
336
- vision, pdf.
337
- --cdp-endpoint <endpoint> CDP endpoint to connect to.
338
- --cdp-header <headers...> CDP headers to send with the connect
339
- request, multiple can be specified.
340
- --config <path> path to the configuration file.
341
- --console-level <level> level of console messages to return:
342
- "error", "warning", "info", "debug".
343
- Each level includes the messages of more
344
- severe levels.
345
- --device <device> device to emulate, for example: "iPhone
346
- 15"
347
- --executable-path <path> path to the browser executable.
348
- --extension Connect to a running browser instance
349
- (Edge/Chrome only). Requires the
350
- "Patchright MCP Bridge" browser
351
- extension to be installed.
352
- --grant-permissions <permissions...> List of permissions to grant to the
353
- browser context, for example
354
- "geolocation", "clipboard-read",
355
- "clipboard-write".
356
- --headless run browser in headless mode, headed by
357
- default
358
- --host <host> host to bind server to. Default is
359
- localhost. Use 0.0.0.0 to bind to all
360
- interfaces.
361
- --ignore-https-errors ignore https errors
362
- --init-page <path...> path to TypeScript file to evaluate on
363
- Patchright page object
364
- --init-script <path...> path to JavaScript file to add as an
365
- initialization script. The script will
366
- be evaluated in every page before any of
367
- the page's scripts. Can be specified
368
- multiple times.
369
- --isolated keep the browser profile in memory, do
370
- not save it to disk.
371
- --image-responses <mode> whether to send image responses to the
372
- client. Can be "allow" or "omit",
373
- Defaults to "allow".
374
- --no-sandbox disable the sandbox for all process
375
- types that are normally sandboxed.
376
- --output-dir <path> path to the directory for output files.
377
- --port <port> port to listen on for SSE transport.
378
- --proxy-bypass <bypass> comma-separated domains to bypass proxy,
379
- for example
380
- ".com,chromium.org,.domain.com"
381
- --proxy-server <proxy> specify proxy server, for example
382
- "http://myproxy:3128" or
383
- "socks5://myproxy:8080"
384
- --save-session Whether to save the Patchright MCP
385
- session into the output directory.
386
- --save-trace Whether to save the Patchright Trace of
387
- the session into the output directory.
388
- --save-video <size> Whether to save the video of the session
389
- into the output directory. For example
390
- "--save-video=800x600"
391
- --secrets <path> path to a file containing secrets in the
392
- dotenv format
393
- --shared-browser-context reuse the same browser context between
394
- all connected HTTP clients.
395
- --snapshot-mode <mode> when taking snapshots for responses,
396
- specifies the mode to use. Can be
397
- "incremental", "full", or "none".
398
- Default is incremental.
399
- --storage-state <path> path to the storage state file for
400
- isolated sessions.
401
- --test-id-attribute <attribute> specify the attribute to use for test
402
- ids, defaults to "data-testid"
403
- --timeout-action <timeout> specify action timeout in milliseconds,
404
- defaults to 5000ms
405
- --timeout-navigation <timeout> specify navigation timeout in
406
- milliseconds, defaults to 60000ms
407
- --user-agent <ua string> specify user agent string
408
- --user-data-dir <path> path to the user data directory. If not
409
- specified, a temporary directory will be
410
- created.
411
- --viewport-size <size> specify browser viewport size in pixels,
412
- for example "1280x720"
413
- ```
414
-
415
- <!--- End of options generated section -->
416
-
417
- ### User profile
418
-
419
- You can run Patchright 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.
420
-
421
- **Persistent profile**
422
-
423
- 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.
424
- Persistent profile is located at the following locations and you can override it with the `--user-data-dir` argument.
425
-
426
- ```bash
427
- # Windows
428
- %USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile
429
-
430
- # macOS
431
- - ~/Library/Caches/ms-playwright/mcp-{channel}-profile
432
-
433
- # Linux
434
- - ~/.cache/ms-playwright/mcp-{channel}-profile
435
- ```
436
-
437
- **Isolated**
438
-
439
- In the isolated mode, each session is started in the isolated profile. Every time you ask MCP to close the browser,
440
- the session is closed and all the storage state for this session is lost. You can provide initial storage state
441
- to the browser via the config's `contextOptions` or via the `--storage-state` argument. Learn more about the storage
442
- state [here](https://playwright.dev/docs/auth).
443
-
444
- ```js
445
- {
446
- "mcpServers": {
447
- "patchright": {
448
- "command": "npx",
449
- "args": [
450
- "patchright-mcp@latest",
451
- "--isolated",
452
- "--storage-state={path/to/storage.json}"
453
- ]
454
- }
455
- }
456
- }
457
- ```
458
-
459
- **Browser Extension**
460
-
461
- The Patchright 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.
462
-
463
- ### Initial state
464
-
465
- There are multiple ways to provide the initial state to the browser context or a page.
466
-
467
- For the storage state, you can either:
468
- - Start with a user data directory using the `--user-data-dir` argument. This will persist all browser data between the sessions.
469
- - Start with a storage state file using the `--storage-state` argument. This will load cookies and local storage from the file into an isolated browser context.
470
-
471
- For the page state, you can use:
472
-
473
- - `--init-page` to point to a TypeScript file that will be evaluated on the Patchright page object. This allows you to run arbitrary code to set up the page.
474
-
475
- ```ts
476
- // init-page.ts
477
- export default async ({ page }) => {
478
- await page.context().grantPermissions(['geolocation']);
479
- await page.context().setGeolocation({ latitude: 37.7749, longitude: -122.4194 });
480
- await page.setViewportSize({ width: 1280, height: 720 });
481
- };
482
- ```
483
-
484
- - `--init-script` to point to a JavaScript file that will be added as an initialization script. The script will be evaluated in every page before any of the page's scripts.
485
- This is useful for overriding browser APIs or setting up the environment.
486
-
487
- ```js
488
- // init-script.js
489
- window.isPatchrightMCP = true;
490
- ```
491
-
492
- ### Configuration file
493
-
494
- The Patchright MCP server can be configured using a JSON configuration file. You can specify the configuration file
495
- using the `--config` command line option:
496
-
497
- ```bash
498
- npx patchright-mcp@latest --config path/to/config.json
499
- ```
500
-
501
- <details>
502
- <summary>Configuration file schema</summary>
503
-
504
- <!--- Config generated by update-readme.js -->
505
-
506
- ```typescript
507
- {
508
- /**
509
- * The browser to use.
510
- */
511
- browser?: {
512
- /**
513
- * The type of browser to use.
514
- */
515
- browserName?: 'chromium' | 'firefox' | 'webkit';
516
-
517
- /**
518
- * Keep the browser profile in memory, do not save it to disk.
519
- */
520
- isolated?: boolean;
521
-
522
- /**
523
- * Path to a user data directory for browser profile persistence.
524
- * Temporary directory is created by default.
525
- */
526
- userDataDir?: string;
527
-
528
- /**
529
- * Launch options passed to
530
- * @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
531
- *
532
- * This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
533
- */
534
- launchOptions?: playwright.LaunchOptions;
535
-
536
- /**
537
- * Context options for the browser context.
538
- *
539
- * This is useful for settings options like `viewport`.
540
- */
541
- contextOptions?: playwright.BrowserContextOptions;
542
-
543
- /**
544
- * Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
545
- */
546
- cdpEndpoint?: string;
547
-
548
- /**
549
- * CDP headers to send with the connect request.
550
- */
551
- cdpHeaders?: Record<string, string>;
552
-
553
- /**
554
- * Remote endpoint to connect to an existing Patchright server.
555
- */
556
- remoteEndpoint?: string;
557
-
558
- /**
559
- * Paths to TypeScript files to add as initialization scripts for Patchright page.
560
- */
561
- initPage?: string[];
562
-
563
- /**
564
- * Paths to JavaScript files to add as initialization scripts.
565
- * The scripts will be evaluated in every page before any of the page's scripts.
566
- */
567
- initScript?: string[];
568
- },
569
-
570
- server?: {
571
- /**
572
- * The port to listen on for SSE or MCP transport.
573
- */
574
- port?: number;
575
-
576
- /**
577
- * The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
578
- */
579
- host?: string;
580
-
581
- /**
582
- * The hosts this server is allowed to serve from. Defaults to the host server is bound to.
583
- * This is not for CORS, but rather for the DNS rebinding protection.
584
- */
585
- allowedHosts?: string[];
586
- },
587
-
588
- /**
589
- * List of enabled tool capabilities. Possible values:
590
- * - 'core': Core browser automation features.
591
- * - 'pdf': PDF generation and manipulation.
592
- * - 'vision': Coordinate-based interactions.
593
- */
594
- capabilities?: ToolCapability[];
595
-
596
- /**
597
- * Whether to save the Patchright session into the output directory.
598
- */
599
- saveSession?: boolean;
600
-
601
- /**
602
- * Whether to save the Patchright trace of the session into the output directory.
603
- */
604
- saveTrace?: boolean;
605
-
606
- /**
607
- * If specified, saves the Patchright video of the session into the output directory.
608
- */
609
- saveVideo?: {
610
- width: number;
611
- height: number;
612
- };
613
-
614
- /**
615
- * Reuse the same browser context between all connected HTTP clients.
616
- */
617
- sharedBrowserContext?: boolean;
618
-
619
- /**
620
- * Secrets are used to prevent LLM from getting sensitive data while
621
- * automating scenarios such as authentication.
622
- * Prefer the browser.contextOptions.storageState over secrets file as a more secure alternative.
623
- */
624
- secrets?: Record<string, string>;
625
-
626
- /**
627
- * The directory to save output files.
628
- */
629
- outputDir?: string;
630
-
631
- console?: {
632
- /**
633
- * The level of console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
634
- */
635
- level?: 'error' | 'warning' | 'info' | 'debug';
636
- },
637
-
638
- network?: {
639
- /**
640
- * List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
641
- */
642
- allowedOrigins?: string[];
643
-
644
- /**
645
- * List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
646
- */
647
- blockedOrigins?: string[];
648
- };
649
-
650
- /**
651
- * Specify the attribute to use for test ids, defaults to "data-testid".
652
- */
653
- testIdAttribute?: string;
654
-
655
- timeouts?: {
656
- /*
657
- * Configures default action timeout: https://playwright.dev/docs/api/class-page#page-set-default-timeout. Defaults to 5000ms.
658
- */
659
- action?: number;
660
-
661
- /*
662
- * Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms.
663
- */
664
- navigation?: number;
665
- };
666
-
667
- /**
668
- * Whether to send image responses to the client. Can be "allow", "omit", or "auto". Defaults to "auto", which sends images if the client can display them.
669
- */
670
- imageResponses?: 'allow' | 'omit';
671
-
672
- snapshot?: {
673
- /**
674
- * When taking snapshots for responses, specifies the mode to use.
675
- */
676
- mode?: 'incremental' | 'full' | 'none';
677
- }
678
-
679
- /**
680
- * Whether to allow file uploads from anywhere on the file system.
681
- * By default (false), file uploads are restricted to paths within the MCP roots only.
682
- */
683
- allowUnrestrictedFileAccess?: boolean;
684
- }
685
- ```
686
-
687
- <!--- End of config generated section -->
688
-
689
- </details>
690
-
691
- ### Standalone MCP server
692
-
693
- When running headed browser on system w/o display or from worker processes of the IDEs,
694
- run the MCP server from environment with the DISPLAY and pass the `--port` flag to enable HTTP transport.
695
-
696
- ```bash
697
- npx patchright-mcp@latest --port 8931
698
- ```
699
-
700
- And then in MCP client config, set the `url` to the HTTP endpoint:
701
-
702
- ```js
703
- {
704
- "mcpServers": {
705
- "patchright": {
706
- "url": "http://localhost:8931/mcp"
707
- }
708
- }
709
- }
710
- ```
711
-
712
- <details>
713
- <summary><b>Docker</b></summary>
714
-
715
- **NOTE:** The Docker implementation only supports headless chromium at the moment.
716
-
717
- ```js
718
- {
719
- "mcpServers": {
720
- "patchright": {
721
- "command": "docker",
722
- "args": ["run", "-i", "--rm", "--init", "--pull=always", "patchright-mcp"]
723
- }
724
- }
725
- }
726
- ```
727
-
728
- Or If you prefer to run the container as a long-lived service instead of letting the MCP client spawn it, use:
729
-
730
- ```
731
- docker run -d -i --rm --init --pull=always \
732
- --entrypoint node \
733
- --name patchright \
734
- -p 8931:8931 \
735
- patchright-mcp \
736
- cli.js --headless --browser chromium --no-sandbox --port 8931
737
- ```
738
-
739
- The server will listen on host port **8931** and can be reached by any MCP client.
740
-
741
- You can build the Docker image yourself.
742
-
743
- ```
744
- docker build -t patchright-mcp .
745
- ```
746
- </details>
747
-
748
- <details>
749
- <summary><b>Programmatic usage</b></summary>
750
-
751
- ```js
752
- import http from 'http';
753
-
754
- import { createConnection } from 'patchright-mcp';
755
- import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
756
-
757
- http.createServer(async (req, res) => {
758
- // ...
759
-
760
- // Creates a headless Patchright MCP server with SSE transport
761
- const connection = await createConnection({ browser: { launchOptions: { headless: true } } });
762
- const transport = new SSEServerTransport('/messages', res);
763
- await connection.connect(transport);
764
-
765
- // ...
766
- });
767
- ```
768
- </details>
769
-
770
- ### Tools
771
-
772
- <!--- Tools generated by update-readme.js -->
773
-
774
- <details>
775
- <summary><b>Core automation</b></summary>
776
-
777
- <!-- NOTE: This has been generated via update-readme.js -->
778
-
779
- - **browser_click**
780
- - Title: Click
781
- - Description: Perform click on a web page
782
- - Parameters:
783
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
784
- - `ref` (string): Exact target element reference from the page snapshot
785
- - `doubleClick` (boolean, optional): Whether to perform a double click instead of a single click
786
- - `button` (string, optional): Button to click, defaults to left
787
- - `modifiers` (array, optional): Modifier keys to press
788
- - Read-only: **false**
789
-
790
- <!-- NOTE: This has been generated via update-readme.js -->
791
-
792
- - **browser_close**
793
- - Title: Close browser
794
- - Description: Close the page
795
- - Parameters: None
796
- - Read-only: **false**
797
-
798
- <!-- NOTE: This has been generated via update-readme.js -->
799
-
800
- - **browser_console_messages**
801
- - Title: Get console messages
802
- - Description: Returns all console messages
803
- - Parameters:
804
- - `level` (string, optional): Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
805
- - Read-only: **true**
806
-
807
- <!-- NOTE: This has been generated via update-readme.js -->
808
-
809
- - **browser_drag**
810
- - Title: Drag mouse
811
- - Description: Perform drag and drop between two elements
812
- - Parameters:
813
- - `startElement` (string): Human-readable source element description used to obtain the permission to interact with the element
814
- - `startRef` (string): Exact source element reference from the page snapshot
815
- - `endElement` (string): Human-readable target element description used to obtain the permission to interact with the element
816
- - `endRef` (string): Exact target element reference from the page snapshot
817
- - Read-only: **false**
818
-
819
- <!-- NOTE: This has been generated via update-readme.js -->
820
-
821
- - **browser_evaluate**
822
- - Title: Evaluate JavaScript
823
- - Description: Evaluate JavaScript expression on page or element
824
- - Parameters:
825
- - `function` (string): () => { /* code */ } or (element) => { /* code */ } when element is provided
826
- - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element
827
- - `ref` (string, optional): Exact target element reference from the page snapshot
828
- - Read-only: **false**
829
-
830
- <!-- NOTE: This has been generated via update-readme.js -->
831
-
832
- - **browser_file_upload**
833
- - Title: Upload files
834
- - Description: Upload one or multiple files
835
- - Parameters:
836
- - `paths` (array, optional): The absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled.
837
- - Read-only: **false**
838
-
839
- <!-- NOTE: This has been generated via update-readme.js -->
840
-
841
- - **browser_fill_form**
842
- - Title: Fill form
843
- - Description: Fill multiple form fields
844
- - Parameters:
845
- - `fields` (array): Fields to fill in
846
- - Read-only: **false**
847
-
848
- <!-- NOTE: This has been generated via update-readme.js -->
849
-
850
- - **browser_handle_dialog**
851
- - Title: Handle a dialog
852
- - Description: Handle a dialog
853
- - Parameters:
854
- - `accept` (boolean): Whether to accept the dialog.
855
- - `promptText` (string, optional): The text of the prompt in case of a prompt dialog.
856
- - Read-only: **false**
857
-
858
- <!-- NOTE: This has been generated via update-readme.js -->
859
-
860
- - **browser_hover**
861
- - Title: Hover mouse
862
- - Description: Hover over element on page
863
- - Parameters:
864
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
865
- - `ref` (string): Exact target element reference from the page snapshot
866
- - Read-only: **false**
867
-
868
- <!-- NOTE: This has been generated via update-readme.js -->
869
-
870
- - **browser_navigate**
871
- - Title: Navigate to a URL
872
- - Description: Navigate to a URL
873
- - Parameters:
874
- - `url` (string): The URL to navigate to
875
- - Read-only: **false**
876
-
877
- <!-- NOTE: This has been generated via update-readme.js -->
878
-
879
- - **browser_navigate_back**
880
- - Title: Go back
881
- - Description: Go back to the previous page
882
- - Parameters: None
883
- - Read-only: **false**
884
-
885
- <!-- NOTE: This has been generated via update-readme.js -->
886
-
887
- - **browser_network_requests**
888
- - Title: List network requests
889
- - Description: Returns all network requests since loading the page
890
- - Parameters:
891
- - `includeStatic` (boolean, optional): Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false.
892
- - Read-only: **true**
893
-
894
- <!-- NOTE: This has been generated via update-readme.js -->
895
-
896
- - **browser_press_key**
897
- - Title: Press a key
898
- - Description: Press a key on the keyboard
899
- - Parameters:
900
- - `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
901
- - Read-only: **false**
902
-
903
- <!-- NOTE: This has been generated via update-readme.js -->
904
-
905
- - **browser_resize**
906
- - Title: Resize browser window
907
- - Description: Resize the browser window
908
- - Parameters:
909
- - `width` (number): Width of the browser window
910
- - `height` (number): Height of the browser window
911
- - Read-only: **false**
912
-
913
- <!-- NOTE: This has been generated via update-readme.js -->
914
-
915
- - **browser_run_code**
916
- - Title: Run Patchright code
917
- - Description: Run Patchright code snippet
918
- - Parameters:
919
- - `code` (string): A JavaScript function containing Patchright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: `async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }`
920
- - Read-only: **false**
921
-
922
- <!-- NOTE: This has been generated via update-readme.js -->
923
-
924
- - **browser_select_option**
925
- - Title: Select option
926
- - Description: Select an option in a dropdown
927
- - Parameters:
928
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
929
- - `ref` (string): Exact target element reference from the page snapshot
930
- - `values` (array): Array of values to select in the dropdown. This can be a single value or multiple values.
931
- - Read-only: **false**
932
-
933
- <!-- NOTE: This has been generated via update-readme.js -->
934
-
935
- - **browser_snapshot**
936
- - Title: Page snapshot
937
- - Description: Capture accessibility snapshot of the current page, this is better than screenshot
938
- - Parameters:
939
- - `filename` (string, optional): Save snapshot to markdown file instead of returning it in the response.
940
- - Read-only: **true**
941
-
942
- <!-- NOTE: This has been generated via update-readme.js -->
943
-
944
- - **browser_take_screenshot**
945
- - Title: Take a screenshot
946
- - Description: Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.
947
- - Parameters:
948
- - `type` (string, optional): Image format for the screenshot. Default is png.
949
- - `filename` (string, optional): File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory.
950
- - `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.
951
- - `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.
952
- - `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.
953
- - Read-only: **true**
954
-
955
- <!-- NOTE: This has been generated via update-readme.js -->
956
-
957
- - **browser_type**
958
- - Title: Type text
959
- - Description: Type text into editable element
960
- - Parameters:
961
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
962
- - `ref` (string): Exact target element reference from the page snapshot
963
- - `text` (string): Text to type into the element
964
- - `submit` (boolean, optional): Whether to submit entered text (press Enter after)
965
- - `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.
966
- - Read-only: **false**
967
-
968
- <!-- NOTE: This has been generated via update-readme.js -->
969
-
970
- - **browser_wait_for**
971
- - Title: Wait for
972
- - Description: Wait for text to appear or disappear or a specified time to pass
973
- - Parameters:
974
- - `time` (number, optional): The time to wait in seconds
975
- - `text` (string, optional): The text to wait for
976
- - `textGone` (string, optional): The text to wait for to disappear
977
- - Read-only: **false**
978
-
979
- </details>
980
-
981
- <details>
982
- <summary><b>Tab management</b></summary>
983
-
984
- <!-- NOTE: This has been generated via update-readme.js -->
985
-
986
- - **browser_tabs**
987
- - Title: Manage tabs
988
- - Description: List, create, close, or select a browser tab.
989
- - Parameters:
990
- - `action` (string): Operation to perform
991
- - `index` (number, optional): Tab index, used for close/select. If omitted for close, current tab is closed.
992
- - Read-only: **false**
993
-
994
- </details>
995
-
996
- <details>
997
- <summary><b>Browser installation</b></summary>
998
-
999
- <!-- NOTE: This has been generated via update-readme.js -->
1000
-
1001
- - **browser_install**
1002
- - Title: Install the browser specified in the config
1003
- - Description: Install the browser specified in the config. Call this if you get an error about the browser not being installed.
1004
- - Parameters: None
1005
- - Read-only: **false**
1006
-
1007
- </details>
1008
-
1009
- <details>
1010
- <summary><b>Coordinate-based (opt-in via --caps=vision)</b></summary>
1011
-
1012
- <!-- NOTE: This has been generated via update-readme.js -->
1013
-
1014
- - **browser_mouse_click_xy**
1015
- - Title: Click
1016
- - Description: Click left mouse button at a given position
1017
- - Parameters:
1018
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
1019
- - `x` (number): X coordinate
1020
- - `y` (number): Y coordinate
1021
- - Read-only: **false**
1022
-
1023
- <!-- NOTE: This has been generated via update-readme.js -->
1024
-
1025
- - **browser_mouse_drag_xy**
1026
- - Title: Drag mouse
1027
- - Description: Drag left mouse button to a given position
1028
- - Parameters:
1029
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
1030
- - `startX` (number): Start X coordinate
1031
- - `startY` (number): Start Y coordinate
1032
- - `endX` (number): End X coordinate
1033
- - `endY` (number): End Y coordinate
1034
- - Read-only: **false**
1035
-
1036
- <!-- NOTE: This has been generated via update-readme.js -->
1037
-
1038
- - **browser_mouse_move_xy**
1039
- - Title: Move mouse
1040
- - Description: Move mouse to a given position
1041
- - Parameters:
1042
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
1043
- - `x` (number): X coordinate
1044
- - `y` (number): Y coordinate
1045
- - Read-only: **false**
1046
-
1047
- </details>
1048
-
1049
- <details>
1050
- <summary><b>PDF generation (opt-in via --caps=pdf)</b></summary>
1051
-
1052
- <!-- NOTE: This has been generated via update-readme.js -->
1053
-
1054
- - **browser_pdf_save**
1055
- - Title: Save as PDF
1056
- - Description: Save page as PDF
1057
- - Parameters:
1058
- - `filename` (string, optional): File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.
1059
- - Read-only: **true**
1060
-
1061
- </details>
1062
-
1063
- <details>
1064
- <summary><b>Test assertions (opt-in via --caps=testing)</b></summary>
1065
-
1066
- <!-- NOTE: This has been generated via update-readme.js -->
1067
-
1068
- - **browser_generate_locator**
1069
- - Title: Create locator for element
1070
- - Description: Generate locator for the given element to use in tests
1071
- - Parameters:
1072
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
1073
- - `ref` (string): Exact target element reference from the page snapshot
1074
- - Read-only: **true**
1075
-
1076
- <!-- NOTE: This has been generated via update-readme.js -->
1077
-
1078
- - **browser_verify_element_visible**
1079
- - Title: Verify element visible
1080
- - Description: Verify element is visible on the page
1081
- - Parameters:
1082
- - `role` (string): ROLE of the element. Can be found in the snapshot like this: `- {ROLE} "Accessible Name":`
1083
- - `accessibleName` (string): ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: `- role "{ACCESSIBLE_NAME}"`
1084
- - Read-only: **false**
1085
-
1086
- <!-- NOTE: This has been generated via update-readme.js -->
1087
-
1088
- - **browser_verify_list_visible**
1089
- - Title: Verify list visible
1090
- - Description: Verify list is visible on the page
1091
- - Parameters:
1092
- - `element` (string): Human-readable list description
1093
- - `ref` (string): Exact target element reference that points to the list
1094
- - `items` (array): Items to verify
1095
- - Read-only: **false**
1096
-
1097
- <!-- NOTE: This has been generated via update-readme.js -->
1098
-
1099
- - **browser_verify_text_visible**
1100
- - Title: Verify text visible
1101
- - Description: Verify text is visible on the page. Prefer browser_verify_element_visible if possible.
1102
- - Parameters:
1103
- - `text` (string): TEXT to verify. Can be found in the snapshot like this: `- role "Accessible Name": {TEXT}` or like this: `- text: {TEXT}`
1104
- - Read-only: **false**
1105
-
1106
- <!-- NOTE: This has been generated via update-readme.js -->
1107
-
1108
- - **browser_verify_value**
1109
- - Title: Verify value
1110
- - Description: Verify element value
1111
- - Parameters:
1112
- - `type` (string): Type of the element
1113
- - `element` (string): Human-readable element description
1114
- - `ref` (string): Exact target element reference that points to the element
1115
- - `value` (string): Value to verify. For checkbox, use "true" or "false".
1116
- - Read-only: **false**
1117
-
1118
- </details>
1119
-
1120
- <details>
1121
- <summary><b>Tracing (opt-in via --caps=tracing)</b></summary>
1122
-
1123
- <!-- NOTE: This has been generated via update-readme.js -->
1124
-
1125
- - **browser_start_tracing**
1126
- - Title: Start tracing
1127
- - Description: Start trace recording
1128
- - Parameters: None
1129
- - Read-only: **true**
1130
-
1131
- <!-- NOTE: This has been generated via update-readme.js -->
1132
-
1133
- - **browser_stop_tracing**
1134
- - Title: Stop tracing
1135
- - Description: Stop trace recording
1136
- - Parameters: None
1137
- - Read-only: **true**
1138
-
1139
- </details>
1140
-
1141
-
1142
- <!--- End of tools generated section -->