@roxybrowser/playwright-mcp 0.0.1

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 (59) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +742 -0
  3. package/cli.js +18 -0
  4. package/config.d.ts +119 -0
  5. package/index.d.ts +23 -0
  6. package/index.js +19 -0
  7. package/lib/browserContextFactory.js +264 -0
  8. package/lib/browserServerBackend.js +77 -0
  9. package/lib/config.js +246 -0
  10. package/lib/context.js +242 -0
  11. package/lib/extension/cdpRelay.js +355 -0
  12. package/lib/extension/extensionContextFactory.js +54 -0
  13. package/lib/index.js +40 -0
  14. package/lib/loop/loop.js +69 -0
  15. package/lib/loop/loopClaude.js +152 -0
  16. package/lib/loop/loopOpenAI.js +141 -0
  17. package/lib/loop/main.js +60 -0
  18. package/lib/loopTools/context.js +67 -0
  19. package/lib/loopTools/main.js +54 -0
  20. package/lib/loopTools/perform.js +32 -0
  21. package/lib/loopTools/snapshot.js +29 -0
  22. package/lib/loopTools/tool.js +18 -0
  23. package/lib/mcp/http.js +120 -0
  24. package/lib/mcp/inProcessTransport.js +72 -0
  25. package/lib/mcp/proxyBackend.js +104 -0
  26. package/lib/mcp/server.js +123 -0
  27. package/lib/mcp/tool.js +29 -0
  28. package/lib/program.js +145 -0
  29. package/lib/response.js +165 -0
  30. package/lib/sessionLog.js +121 -0
  31. package/lib/tab.js +249 -0
  32. package/lib/tools/common.js +55 -0
  33. package/lib/tools/console.js +33 -0
  34. package/lib/tools/dialogs.js +47 -0
  35. package/lib/tools/evaluate.js +53 -0
  36. package/lib/tools/files.js +44 -0
  37. package/lib/tools/install.js +53 -0
  38. package/lib/tools/keyboard.js +78 -0
  39. package/lib/tools/mouse.js +99 -0
  40. package/lib/tools/navigate.js +70 -0
  41. package/lib/tools/network.js +41 -0
  42. package/lib/tools/pdf.js +40 -0
  43. package/lib/tools/roxy.js +50 -0
  44. package/lib/tools/screenshot.js +79 -0
  45. package/lib/tools/snapshot.js +139 -0
  46. package/lib/tools/tabs.js +87 -0
  47. package/lib/tools/tool.js +33 -0
  48. package/lib/tools/utils.js +74 -0
  49. package/lib/tools/wait.js +55 -0
  50. package/lib/tools.js +52 -0
  51. package/lib/utils/codegen.js +49 -0
  52. package/lib/utils/fileUtils.js +36 -0
  53. package/lib/utils/guid.js +22 -0
  54. package/lib/utils/log.js +21 -0
  55. package/lib/utils/manualPromise.js +111 -0
  56. package/lib/utils/package.js +20 -0
  57. package/lib/vscode/host.js +128 -0
  58. package/lib/vscode/main.js +62 -0
  59. package/package.json +79 -0
package/README.md ADDED
@@ -0,0 +1,742 @@
1
+ ## Playwright MCP
2
+
3
+ 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.
4
+
5
+ ### Key Features
6
+
7
+ - **Fast and lightweight**. Uses Playwright's accessibility tree, not pixel-based input.
8
+ - **LLM-friendly**. No vision models needed, operates purely on structured data.
9
+ - **Deterministic tool application**. Avoids ambiguity common with screenshot-based approaches.
10
+
11
+ ### Requirements
12
+ - Node.js 18 or newer
13
+ - VS Code, Cursor, Windsurf, Claude Desktop, Goose or any other MCP client
14
+
15
+ <!--
16
+ // Generate using:
17
+ node utils/generate-links.js
18
+ -->
19
+
20
+ ### Getting started
21
+
22
+ First, install the Playwright MCP server with your client.
23
+
24
+ **Standard config** works in most of the tools:
25
+
26
+ ```js
27
+ {
28
+ "mcpServers": {
29
+ "playwright": {
30
+ "command": "npx",
31
+ "args": [
32
+ "@playwright/mcp@latest"
33
+ ]
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ [<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)
40
+
41
+
42
+ <details>
43
+ <summary>Claude Code</summary>
44
+
45
+ Use the Claude Code CLI to add the Playwright MCP server:
46
+
47
+ ```bash
48
+ claude mcp add playwright npx @playwright/mcp@latest
49
+ ```
50
+ </details>
51
+
52
+ <details>
53
+ <summary>Claude Desktop</summary>
54
+
55
+ Follow the MCP install [guide](https://modelcontextprotocol.io/quickstart/user), use the standard config above.
56
+
57
+ </details>
58
+
59
+ <details>
60
+ <summary>Codex</summary>
61
+
62
+ Create or edit the configuration file `~/.codex/config.toml` and add:
63
+
64
+ ```toml
65
+ [mcp_servers.playwright]
66
+ command = "npx"
67
+ args = ["@playwright/mcp@latest"]
68
+ ```
69
+
70
+ For more information, see the [Codex MCP documentation](https://github.com/openai/codex/blob/main/codex-rs/config.md#mcp_servers).
71
+
72
+ </details>
73
+
74
+ <details>
75
+ <summary>Cursor</summary>
76
+
77
+ #### Click the button to install:
78
+
79
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](cursor://anysphere.cursor-deeplink/mcp/install?name=Playwright&config=eyJjb21tYW5kIjoibnB4IEBwbGF5d3JpZ2h0L21jcEBsYXRlc3QifQ%3D%3D)
80
+
81
+ #### Or install manually:
82
+
83
+ 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`.
84
+
85
+ </details>
86
+
87
+ <details>
88
+ <summary>Gemini CLI</summary>
89
+
90
+ 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.
91
+
92
+ </details>
93
+
94
+ <details>
95
+ <summary>Goose</summary>
96
+
97
+ #### Click the button to install:
98
+
99
+ [![Install in Goose](https://block.github.io/goose/img/extension-install-dark.svg)](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)
100
+
101
+ #### Or install manually:
102
+
103
+ 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".
104
+ </details>
105
+
106
+ <details>
107
+ <summary>LM Studio</summary>
108
+
109
+ #### Click the button to install:
110
+
111
+ [![Add MCP Server playwright to LM Studio](https://files.lmstudio.ai/deeplink/mcp-install-light.svg)](https://lmstudio.ai/install-mcp?name=playwright&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAcGxheXdyaWdodC9tY3BAbGF0ZXN0Il19)
112
+
113
+ #### Or install manually:
114
+
115
+ Go to `Program` in the right sidebar -> `Install` -> `Edit mcp.json`. Use the standard config above.
116
+ </details>
117
+
118
+ <details>
119
+ <summary>opencode</summary>
120
+
121
+ Follow the MCP Servers [documentation](https://opencode.ai/docs/mcp-servers/). For example in `~/.config/opencode/opencode.json`:
122
+
123
+ ```json
124
+ {
125
+ "$schema": "https://opencode.ai/config.json",
126
+ "mcp": {
127
+ "playwright": {
128
+ "type": "local",
129
+ "command": [
130
+ "npx",
131
+ "@playwright/mcp@latest"
132
+ ],
133
+ "enabled": true
134
+ }
135
+ }
136
+ }
137
+
138
+ ```
139
+ </details>
140
+
141
+ <details>
142
+ <summary>Qodo Gen</summary>
143
+
144
+ 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.
145
+
146
+ Click <code>Save</code>.
147
+ </details>
148
+
149
+ <details>
150
+ <summary>VS Code</summary>
151
+
152
+ #### Click the button to install:
153
+
154
+ [<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)
155
+
156
+ #### Or install manually:
157
+
158
+ 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:
159
+
160
+ ```bash
161
+ # For VS Code
162
+ code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
163
+ ```
164
+
165
+ After installation, the Playwright MCP server will be available for use with your GitHub Copilot agent in VS Code.
166
+ </details>
167
+
168
+ <details>
169
+ <summary>Windsurf</summary>
170
+
171
+ Follow Windsurf MCP [documentation](https://docs.windsurf.com/windsurf/cascade/mcp). Use the standard config above.
172
+
173
+ </details>
174
+
175
+ ### Configuration
176
+
177
+ Playwright MCP server supports following arguments. They can be provided in the JSON configuration above, as a part of the `"args"` list:
178
+
179
+ <!--- Options generated by update-readme.js -->
180
+
181
+ ```
182
+ > npx @playwright/mcp@latest --help
183
+ --allowed-origins <origins> semicolon-separated list of origins to allow the
184
+ browser to request. Default is to allow all.
185
+ --blocked-origins <origins> semicolon-separated list of origins to block the
186
+ browser from requesting. Blocklist is evaluated
187
+ before allowlist. If used without the allowlist,
188
+ requests not matching the blocklist are still
189
+ allowed.
190
+ --block-service-workers block service workers
191
+ --browser <browser> browser or chrome channel to use, possible
192
+ values: chrome, firefox, webkit, msedge.
193
+ --caps <caps> comma-separated list of additional capabilities
194
+ to enable, possible values: vision, pdf.
195
+ --cdp-endpoint <endpoint> CDP endpoint to connect to.
196
+ --config <path> path to the configuration file.
197
+ --device <device> device to emulate, for example: "iPhone 15"
198
+ --executable-path <path> path to the browser executable.
199
+ --extension Connect to a running browser instance
200
+ (Edge/Chrome only). Requires the "Playwright MCP
201
+ Bridge" browser extension to be installed.
202
+ --headless run browser in headless mode, headed by default
203
+ --host <host> host to bind server to. Default is localhost. Use
204
+ 0.0.0.0 to bind to all interfaces.
205
+ --ignore-https-errors ignore https errors
206
+ --isolated keep the browser profile in memory, do not save
207
+ it to disk.
208
+ --image-responses <mode> whether to send image responses to the client.
209
+ Can be "allow" or "omit", Defaults to "allow".
210
+ --no-sandbox disable the sandbox for all process types that
211
+ are normally sandboxed.
212
+ --output-dir <path> path to the directory for output files.
213
+ --port <port> port to listen on for SSE transport.
214
+ --proxy-bypass <bypass> comma-separated domains to bypass proxy, for
215
+ example ".com,chromium.org,.domain.com"
216
+ --proxy-server <proxy> specify proxy server, for example
217
+ "http://myproxy:3128" or "socks5://myproxy:8080"
218
+ --save-session Whether to save the Playwright MCP session into
219
+ the output directory.
220
+ --save-trace Whether to save the Playwright Trace of the
221
+ session into the output directory.
222
+ --storage-state <path> path to the storage state file for isolated
223
+ sessions.
224
+ --user-agent <ua string> specify user agent string
225
+ --user-data-dir <path> path to the user data directory. If not
226
+ specified, a temporary directory will be created.
227
+ --viewport-size <size> specify browser viewport size in pixels, for
228
+ example "1280, 720"
229
+ ```
230
+
231
+ <!--- End of options generated section -->
232
+
233
+ ### User profile
234
+
235
+ 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.
236
+
237
+ **Persistent profile**
238
+
239
+ 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.
240
+ Persistent profile is located at the following locations and you can override it with the `--user-data-dir` argument.
241
+
242
+ ```bash
243
+ # Windows
244
+ %USERPROFILE%\AppData\Local\ms-playwright\mcp-{channel}-profile
245
+
246
+ # macOS
247
+ - ~/Library/Caches/ms-playwright/mcp-{channel}-profile
248
+
249
+ # Linux
250
+ - ~/.cache/ms-playwright/mcp-{channel}-profile
251
+ ```
252
+
253
+ **Isolated**
254
+
255
+ In the isolated mode, each session is started in the isolated profile. Every time you ask MCP to close the browser,
256
+ the session is closed and all the storage state for this session is lost. You can provide initial storage state
257
+ to the browser via the config's `contextOptions` or via the `--storage-state` argument. Learn more about the storage
258
+ state [here](https://playwright.dev/docs/auth).
259
+
260
+ ```js
261
+ {
262
+ "mcpServers": {
263
+ "playwright": {
264
+ "command": "npx",
265
+ "args": [
266
+ "@playwright/mcp@latest",
267
+ "--isolated",
268
+ "--storage-state={path/to/storage.json}"
269
+ ]
270
+ }
271
+ }
272
+ }
273
+ ```
274
+
275
+ **Browser Extension**
276
+
277
+ 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.
278
+
279
+ ### Configuration file
280
+
281
+ The Playwright MCP server can be configured using a JSON configuration file. You can specify the configuration file
282
+ using the `--config` command line option:
283
+
284
+ ```bash
285
+ npx @playwright/mcp@latest --config path/to/config.json
286
+ ```
287
+
288
+ <details>
289
+ <summary>Configuration file schema</summary>
290
+
291
+ ```typescript
292
+ {
293
+ // Browser configuration
294
+ browser?: {
295
+ // Browser type to use (chromium, firefox, or webkit)
296
+ browserName?: 'chromium' | 'firefox' | 'webkit';
297
+
298
+ // Keep the browser profile in memory, do not save it to disk.
299
+ isolated?: boolean;
300
+
301
+ // Path to user data directory for browser profile persistence
302
+ userDataDir?: string;
303
+
304
+ // Browser launch options (see Playwright docs)
305
+ // @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch
306
+ launchOptions?: {
307
+ channel?: string; // Browser channel (e.g. 'chrome')
308
+ headless?: boolean; // Run in headless mode
309
+ executablePath?: string; // Path to browser executable
310
+ // ... other Playwright launch options
311
+ };
312
+
313
+ // Browser context options
314
+ // @see https://playwright.dev/docs/api/class-browser#browser-new-context
315
+ contextOptions?: {
316
+ viewport?: { width: number, height: number };
317
+ // ... other Playwright context options
318
+ };
319
+
320
+ // CDP endpoint for connecting to existing browser
321
+ cdpEndpoint?: string;
322
+
323
+ // Remote Playwright server endpoint
324
+ remoteEndpoint?: string;
325
+ },
326
+
327
+ // Server configuration
328
+ server?: {
329
+ port?: number; // Port to listen on
330
+ host?: string; // Host to bind to (default: localhost)
331
+ },
332
+
333
+ // List of additional capabilities
334
+ capabilities?: Array<
335
+ 'tabs' | // Tab management
336
+ 'install' | // Browser installation
337
+ 'pdf' | // PDF generation
338
+ 'vision' | // Coordinate-based interactions
339
+ >;
340
+
341
+ // Directory for output files
342
+ outputDir?: string;
343
+
344
+ // Network configuration
345
+ network?: {
346
+ // List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
347
+ allowedOrigins?: string[];
348
+
349
+ // List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
350
+ blockedOrigins?: string[];
351
+ };
352
+
353
+ /**
354
+ * Whether to send image responses to the client. Can be "allow" or "omit".
355
+ * Defaults to "allow".
356
+ */
357
+ imageResponses?: 'allow' | 'omit';
358
+ }
359
+ ```
360
+ </details>
361
+
362
+ ### Standalone MCP server
363
+
364
+ When running headed browser on system w/o display or from worker processes of the IDEs,
365
+ run the MCP server from environment with the DISPLAY and pass the `--port` flag to enable HTTP transport.
366
+
367
+ ```bash
368
+ npx @playwright/mcp@latest --port 8931
369
+ ```
370
+
371
+ And then in MCP client config, set the `url` to the HTTP endpoint:
372
+
373
+ ```js
374
+ {
375
+ "mcpServers": {
376
+ "playwright": {
377
+ "url": "http://localhost:8931/mcp"
378
+ }
379
+ }
380
+ }
381
+ ```
382
+
383
+ <details>
384
+ <summary><b>Docker</b></summary>
385
+
386
+ **NOTE:** The Docker implementation only supports headless chromium at the moment.
387
+
388
+ ```js
389
+ {
390
+ "mcpServers": {
391
+ "playwright": {
392
+ "command": "docker",
393
+ "args": ["run", "-i", "--rm", "--init", "--pull=always", "mcr.microsoft.com/playwright/mcp"]
394
+ }
395
+ }
396
+ }
397
+ ```
398
+
399
+ You can build the Docker image yourself.
400
+
401
+ ```
402
+ docker build -t mcr.microsoft.com/playwright/mcp .
403
+ ```
404
+ </details>
405
+
406
+ <details>
407
+ <summary><b>Programmatic usage</b></summary>
408
+
409
+ ```js
410
+ import http from 'http';
411
+
412
+ import { createConnection } from '@playwright/mcp';
413
+ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
414
+
415
+ http.createServer(async (req, res) => {
416
+ // ...
417
+
418
+ // Creates a headless Playwright MCP server with SSE transport
419
+ const connection = await createConnection({ browser: { launchOptions: { headless: true } } });
420
+ const transport = new SSEServerTransport('/messages', res);
421
+ await connection.sever.connect(transport);
422
+
423
+ // ...
424
+ });
425
+ ```
426
+ </details>
427
+
428
+ ### Tools
429
+
430
+ <!--- Tools generated by update-readme.js -->
431
+
432
+ <details>
433
+ <summary><b>Core automation</b></summary>
434
+
435
+ <!-- NOTE: This has been generated via update-readme.js -->
436
+
437
+ - **browser_click**
438
+ - Title: Click
439
+ - Description: Perform click on a web page
440
+ - Parameters:
441
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
442
+ - `ref` (string): Exact target element reference from the page snapshot
443
+ - `doubleClick` (boolean, optional): Whether to perform a double click instead of a single click
444
+ - `button` (string, optional): Button to click, defaults to left
445
+ - Read-only: **false**
446
+
447
+ <!-- NOTE: This has been generated via update-readme.js -->
448
+
449
+ - **browser_close**
450
+ - Title: Close browser
451
+ - Description: Close the page
452
+ - Parameters: None
453
+ - Read-only: **true**
454
+
455
+ <!-- NOTE: This has been generated via update-readme.js -->
456
+
457
+ - **browser_connect_roxy**
458
+ - Title: Connect to RoxyBrowser
459
+ - Description: Connect to RoxyBrowser using CDP WebSocket endpoint
460
+ - Parameters:
461
+ - `cdpEndpoint` (string): The CDP WebSocket endpoint URL from RoxyBrowser (e.g., ws://127.0.0.1:59305/devtools/browser/4d876b0b-6adc-4e9f-b572-bb68ff02a199)
462
+ - Read-only: **false**
463
+
464
+ <!-- NOTE: This has been generated via update-readme.js -->
465
+
466
+ - **browser_console_messages**
467
+ - Title: Get console messages
468
+ - Description: Returns all console messages
469
+ - Parameters: None
470
+ - Read-only: **true**
471
+
472
+ <!-- NOTE: This has been generated via update-readme.js -->
473
+
474
+ - **browser_drag**
475
+ - Title: Drag mouse
476
+ - Description: Perform drag and drop between two elements
477
+ - Parameters:
478
+ - `startElement` (string): Human-readable source element description used to obtain the permission to interact with the element
479
+ - `startRef` (string): Exact source element reference from the page snapshot
480
+ - `endElement` (string): Human-readable target element description used to obtain the permission to interact with the element
481
+ - `endRef` (string): Exact target element reference from the page snapshot
482
+ - Read-only: **false**
483
+
484
+ <!-- NOTE: This has been generated via update-readme.js -->
485
+
486
+ - **browser_evaluate**
487
+ - Title: Evaluate JavaScript
488
+ - Description: Evaluate JavaScript expression on page or element
489
+ - Parameters:
490
+ - `function` (string): () => { /* code */ } or (element) => { /* code */ } when element is provided
491
+ - `element` (string, optional): Human-readable element description used to obtain permission to interact with the element
492
+ - `ref` (string, optional): Exact target element reference from the page snapshot
493
+ - Read-only: **false**
494
+
495
+ <!-- NOTE: This has been generated via update-readme.js -->
496
+
497
+ - **browser_file_upload**
498
+ - Title: Upload files
499
+ - Description: Upload one or multiple files
500
+ - Parameters:
501
+ - `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.
502
+ - Read-only: **false**
503
+
504
+ <!-- NOTE: This has been generated via update-readme.js -->
505
+
506
+ - **browser_handle_dialog**
507
+ - Title: Handle a dialog
508
+ - Description: Handle a dialog
509
+ - Parameters:
510
+ - `accept` (boolean): Whether to accept the dialog.
511
+ - `promptText` (string, optional): The text of the prompt in case of a prompt dialog.
512
+ - Read-only: **false**
513
+
514
+ <!-- NOTE: This has been generated via update-readme.js -->
515
+
516
+ - **browser_hover**
517
+ - Title: Hover mouse
518
+ - Description: Hover over element on page
519
+ - Parameters:
520
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
521
+ - `ref` (string): Exact target element reference from the page snapshot
522
+ - Read-only: **true**
523
+
524
+ <!-- NOTE: This has been generated via update-readme.js -->
525
+
526
+ - **browser_navigate**
527
+ - Title: Navigate to a URL
528
+ - Description: Navigate to a URL
529
+ - Parameters:
530
+ - `url` (string): The URL to navigate to
531
+ - Read-only: **false**
532
+
533
+ <!-- NOTE: This has been generated via update-readme.js -->
534
+
535
+ - **browser_navigate_back**
536
+ - Title: Go back
537
+ - Description: Go back to the previous page
538
+ - Parameters: None
539
+ - Read-only: **true**
540
+
541
+ <!-- NOTE: This has been generated via update-readme.js -->
542
+
543
+ - **browser_navigate_forward**
544
+ - Title: Go forward
545
+ - Description: Go forward to the next page
546
+ - Parameters: None
547
+ - Read-only: **true**
548
+
549
+ <!-- NOTE: This has been generated via update-readme.js -->
550
+
551
+ - **browser_network_requests**
552
+ - Title: List network requests
553
+ - Description: Returns all network requests since loading the page
554
+ - Parameters: None
555
+ - Read-only: **true**
556
+
557
+ <!-- NOTE: This has been generated via update-readme.js -->
558
+
559
+ - **browser_press_key**
560
+ - Title: Press a key
561
+ - Description: Press a key on the keyboard
562
+ - Parameters:
563
+ - `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
564
+ - Read-only: **false**
565
+
566
+ <!-- NOTE: This has been generated via update-readme.js -->
567
+
568
+ - **browser_resize**
569
+ - Title: Resize browser window
570
+ - Description: Resize the browser window
571
+ - Parameters:
572
+ - `width` (number): Width of the browser window
573
+ - `height` (number): Height of the browser window
574
+ - Read-only: **true**
575
+
576
+ <!-- NOTE: This has been generated via update-readme.js -->
577
+
578
+ - **browser_select_option**
579
+ - Title: Select option
580
+ - Description: Select an option in a dropdown
581
+ - Parameters:
582
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
583
+ - `ref` (string): Exact target element reference from the page snapshot
584
+ - `values` (array): Array of values to select in the dropdown. This can be a single value or multiple values.
585
+ - Read-only: **false**
586
+
587
+ <!-- NOTE: This has been generated via update-readme.js -->
588
+
589
+ - **browser_snapshot**
590
+ - Title: Page snapshot
591
+ - Description: Capture accessibility snapshot of the current page, this is better than screenshot
592
+ - Parameters: None
593
+ - Read-only: **true**
594
+
595
+ <!-- NOTE: This has been generated via update-readme.js -->
596
+
597
+ - **browser_take_screenshot**
598
+ - Title: Take a screenshot
599
+ - Description: Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.
600
+ - Parameters:
601
+ - `type` (string, optional): Image format for the screenshot. Default is png.
602
+ - `filename` (string, optional): File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.
603
+ - `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.
604
+ - `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.
605
+ - `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.
606
+ - Read-only: **true**
607
+
608
+ <!-- NOTE: This has been generated via update-readme.js -->
609
+
610
+ - **browser_type**
611
+ - Title: Type text
612
+ - Description: Type text into editable element
613
+ - Parameters:
614
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
615
+ - `ref` (string): Exact target element reference from the page snapshot
616
+ - `text` (string): Text to type into the element
617
+ - `submit` (boolean, optional): Whether to submit entered text (press Enter after)
618
+ - `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.
619
+ - Read-only: **false**
620
+
621
+ <!-- NOTE: This has been generated via update-readme.js -->
622
+
623
+ - **browser_wait_for**
624
+ - Title: Wait for
625
+ - Description: Wait for text to appear or disappear or a specified time to pass
626
+ - Parameters:
627
+ - `time` (number, optional): The time to wait in seconds
628
+ - `text` (string, optional): The text to wait for
629
+ - `textGone` (string, optional): The text to wait for to disappear
630
+ - Read-only: **true**
631
+
632
+ </details>
633
+
634
+ <details>
635
+ <summary><b>Tab management</b></summary>
636
+
637
+ <!-- NOTE: This has been generated via update-readme.js -->
638
+
639
+ - **browser_tab_close**
640
+ - Title: Close a tab
641
+ - Description: Close a tab
642
+ - Parameters:
643
+ - `index` (number, optional): The index of the tab to close. Closes current tab if not provided.
644
+ - Read-only: **false**
645
+
646
+ <!-- NOTE: This has been generated via update-readme.js -->
647
+
648
+ - **browser_tab_list**
649
+ - Title: List tabs
650
+ - Description: List browser tabs
651
+ - Parameters: None
652
+ - Read-only: **true**
653
+
654
+ <!-- NOTE: This has been generated via update-readme.js -->
655
+
656
+ - **browser_tab_new**
657
+ - Title: Open a new tab
658
+ - Description: Open a new tab
659
+ - Parameters:
660
+ - `url` (string, optional): The URL to navigate to in the new tab. If not provided, the new tab will be blank.
661
+ - Read-only: **true**
662
+
663
+ <!-- NOTE: This has been generated via update-readme.js -->
664
+
665
+ - **browser_tab_select**
666
+ - Title: Select a tab
667
+ - Description: Select a tab by index
668
+ - Parameters:
669
+ - `index` (number): The index of the tab to select
670
+ - Read-only: **true**
671
+
672
+ </details>
673
+
674
+ <details>
675
+ <summary><b>Browser installation</b></summary>
676
+
677
+ <!-- NOTE: This has been generated via update-readme.js -->
678
+
679
+ - **browser_install**
680
+ - Title: Install the browser specified in the config
681
+ - Description: Install the browser specified in the config. Call this if you get an error about the browser not being installed.
682
+ - Parameters: None
683
+ - Read-only: **false**
684
+
685
+ </details>
686
+
687
+ <details>
688
+ <summary><b>Coordinate-based (opt-in via --caps=vision)</b></summary>
689
+
690
+ <!-- NOTE: This has been generated via update-readme.js -->
691
+
692
+ - **browser_mouse_click_xy**
693
+ - Title: Click
694
+ - Description: Click left mouse button at a given position
695
+ - Parameters:
696
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
697
+ - `x` (number): X coordinate
698
+ - `y` (number): Y coordinate
699
+ - Read-only: **false**
700
+
701
+ <!-- NOTE: This has been generated via update-readme.js -->
702
+
703
+ - **browser_mouse_drag_xy**
704
+ - Title: Drag mouse
705
+ - Description: Drag left mouse button to a given position
706
+ - Parameters:
707
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
708
+ - `startX` (number): Start X coordinate
709
+ - `startY` (number): Start Y coordinate
710
+ - `endX` (number): End X coordinate
711
+ - `endY` (number): End Y coordinate
712
+ - Read-only: **false**
713
+
714
+ <!-- NOTE: This has been generated via update-readme.js -->
715
+
716
+ - **browser_mouse_move_xy**
717
+ - Title: Move mouse
718
+ - Description: Move mouse to a given position
719
+ - Parameters:
720
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
721
+ - `x` (number): X coordinate
722
+ - `y` (number): Y coordinate
723
+ - Read-only: **true**
724
+
725
+ </details>
726
+
727
+ <details>
728
+ <summary><b>PDF generation (opt-in via --caps=pdf)</b></summary>
729
+
730
+ <!-- NOTE: This has been generated via update-readme.js -->
731
+
732
+ - **browser_pdf_save**
733
+ - Title: Save as PDF
734
+ - Description: Save page as PDF
735
+ - Parameters:
736
+ - `filename` (string, optional): File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.
737
+ - Read-only: **true**
738
+
739
+ </details>
740
+
741
+
742
+ <!--- End of tools generated section -->