@playwright/mcp 0.0.10 → 0.0.14

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 CHANGED
@@ -17,6 +17,8 @@ A Model Context Protocol (MCP) server that provides browser automation capabilit
17
17
 
18
18
  ### Example config
19
19
 
20
+ #### NPX
21
+
20
22
  ```js
21
23
  {
22
24
  "mcpServers": {
@@ -30,7 +32,6 @@ A Model Context Protocol (MCP) server that provides browser automation capabilit
30
32
  }
31
33
  ```
32
34
 
33
-
34
35
  #### Installation in VS Code
35
36
 
36
37
  Install the Playwright MCP server in VS Code using one of these buttons:
@@ -43,7 +44,7 @@ const urlForWebsites = `vscode:mcp/install?${encodeURIComponent(config)}`;
43
44
  const urlForGithub = `https://insiders.vscode.dev/redirect?url=${encodeURIComponent(urlForWebsites)}`;
44
45
  -->
45
46
 
46
- [<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-y%2522%252C%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D)
47
+ [<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-y%2522%252C%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-y%2522%252C%2522%2540playwright%252Fmcp%2540latest%2522%255D%257D)
47
48
 
48
49
  Alternatively, you can install the Playwright MCP server using the VS Code CLI:
49
50
 
@@ -128,6 +129,20 @@ And then in MCP client config, set the `url` to the SSE endpoint:
128
129
  }
129
130
  ```
130
131
 
132
+ ### Docker
133
+
134
+ **NOTE:** The Docker implementation only supports headless chromium at the moment.
135
+ ```js
136
+ {
137
+ "mcpServers": {
138
+ "playwright": {
139
+ "command": "docker",
140
+ "args": ["run", "-i", "--rm", "--init", "mcp/playwright"]
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
131
146
  ### Tool Modes
132
147
 
133
148
  The tools are available in two modes:
@@ -154,42 +169,72 @@ To use Vision Mode, add the `--vision` flag when starting the server:
154
169
  Vision Mode works best with the computer use models that are able to interact with elements using
155
170
  X Y coordinate space, based on the provided screenshot.
156
171
 
172
+ ### Build with Docker
173
+
174
+ You can build the Docker image yourself.
175
+ ```
176
+ docker build -t mcp/playwright .
177
+ ```
178
+
157
179
  ### Programmatic usage with custom transports
158
180
 
159
181
  ```js
182
+ import http from 'http';
183
+
160
184
  import { createServer } from '@playwright/mcp';
185
+ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
161
186
 
162
- // ...
187
+ http.createServer(async (req, res) => {
188
+ // ...
163
189
 
164
- const server = createServer({
165
- launchOptions: { headless: true }
190
+ // Creates a headless Playwright MCP server with SSE transport
191
+ const mcpServer = await createServer({ headless: true });
192
+ const transport = new SSEServerTransport('/messages', res);
193
+ await mcpServer.connect(transport);
194
+
195
+ // ...
166
196
  });
167
- transport = new SSEServerTransport("/messages", res);
168
- server.connect(transport);
197
+
169
198
  ```
170
199
 
200
+ <!--- Generated by update-readme.js -->
201
+
171
202
  ### Snapshot-based Interactions
172
203
 
204
+ <!-- NOTE: This has been generated via update-readme.js -->
205
+
206
+ - **browser_snapshot**
207
+ - Description: Capture accessibility snapshot of the current page, this is better than screenshot
208
+ - Parameters: None
209
+
210
+ <!-- NOTE: This has been generated via update-readme.js -->
211
+
173
212
  - **browser_click**
174
213
  - Description: Perform click on a web page
175
214
  - Parameters:
176
215
  - `element` (string): Human-readable element description used to obtain permission to interact with the element
177
216
  - `ref` (string): Exact target element reference from the page snapshot
178
217
 
179
- - **browser_hover**
180
- - Description: Hover over element on page
181
- - Parameters:
182
- - `element` (string): Human-readable element description used to obtain permission to interact with the element
183
- - `ref` (string): Exact target element reference from the page snapshot
218
+ <!-- NOTE: This has been generated via update-readme.js -->
184
219
 
185
220
  - **browser_drag**
186
221
  - Description: Perform drag and drop between two elements
187
222
  - Parameters:
188
- - `startElement` (string): Human-readable source element description used to obtain permission to interact with the element
223
+ - `startElement` (string): Human-readable source element description used to obtain the permission to interact with the element
189
224
  - `startRef` (string): Exact source element reference from the page snapshot
190
- - `endElement` (string): Human-readable target element description used to obtain permission to interact with the element
225
+ - `endElement` (string): Human-readable target element description used to obtain the permission to interact with the element
191
226
  - `endRef` (string): Exact target element reference from the page snapshot
192
227
 
228
+ <!-- NOTE: This has been generated via update-readme.js -->
229
+
230
+ - **browser_hover**
231
+ - Description: Hover over element on page
232
+ - Parameters:
233
+ - `element` (string): Human-readable element description used to obtain permission to interact with the element
234
+ - `ref` (string): Exact target element reference from the page snapshot
235
+
236
+ <!-- NOTE: This has been generated via update-readme.js -->
237
+
193
238
  - **browser_type**
194
239
  - Description: Type text into editable element
195
240
  - Parameters:
@@ -199,6 +244,8 @@ server.connect(transport);
199
244
  - `submit` (boolean, optional): Whether to submit entered text (press Enter after)
200
245
  - `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.
201
246
 
247
+ <!-- NOTE: This has been generated via update-readme.js -->
248
+
202
249
  - **browser_select_option**
203
250
  - Description: Select an option in a dropdown
204
251
  - Parameters:
@@ -206,17 +253,25 @@ server.connect(transport);
206
253
  - `ref` (string): Exact target element reference from the page snapshot
207
254
  - `values` (array): Array of values to select in the dropdown. This can be a single value or multiple values.
208
255
 
209
- - **browser_snapshot**
210
- - Description: Capture accessibility snapshot of the current page, this is better than screenshot
211
- - Parameters: None
256
+ <!-- NOTE: This has been generated via update-readme.js -->
212
257
 
213
258
  - **browser_take_screenshot**
214
259
  - Description: Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.
215
260
  - Parameters:
216
261
  - `raw` (boolean, optional): Whether to return without compression (in PNG format). Default is false, which returns a JPEG image.
262
+ - `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.
263
+ - `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.
217
264
 
218
265
  ### Vision-based Interactions
219
266
 
267
+ <!-- NOTE: This has been generated via update-readme.js -->
268
+
269
+ - **browser_screen_capture**
270
+ - Description: Take a screenshot of the current page
271
+ - Parameters: None
272
+
273
+ <!-- NOTE: This has been generated via update-readme.js -->
274
+
220
275
  - **browser_screen_move_mouse**
221
276
  - Description: Move mouse to a given position
222
277
  - Parameters:
@@ -224,9 +279,7 @@ server.connect(transport);
224
279
  - `x` (number): X coordinate
225
280
  - `y` (number): Y coordinate
226
281
 
227
- - **browser_screen_capture**
228
- - Description: Take a screenshot of the current page
229
- - Parameters: None
282
+ <!-- NOTE: This has been generated via update-readme.js -->
230
283
 
231
284
  - **browser_screen_click**
232
285
  - Description: Click left mouse button
@@ -235,6 +288,8 @@ server.connect(transport);
235
288
  - `x` (number): X coordinate
236
289
  - `y` (number): Y coordinate
237
290
 
291
+ <!-- NOTE: This has been generated via update-readme.js -->
292
+
238
293
  - **browser_screen_drag**
239
294
  - Description: Drag left mouse button
240
295
  - Parameters:
@@ -244,33 +299,38 @@ server.connect(transport);
244
299
  - `endX` (number): End X coordinate
245
300
  - `endY` (number): End Y coordinate
246
301
 
302
+ <!-- NOTE: This has been generated via update-readme.js -->
303
+
247
304
  - **browser_screen_type**
248
305
  - Description: Type text
249
306
  - Parameters:
250
- - `text` (string): Text to type
307
+ - `text` (string): Text to type into the element
251
308
  - `submit` (boolean, optional): Whether to submit entered text (press Enter after)
252
309
 
253
- - **browser_press_key**
254
- - Description: Press a key on the keyboard
255
- - Parameters:
256
- - `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
257
-
258
310
  ### Tab Management
259
311
 
312
+ <!-- NOTE: This has been generated via update-readme.js -->
313
+
260
314
  - **browser_tab_list**
261
315
  - Description: List browser tabs
262
316
  - Parameters: None
263
317
 
318
+ <!-- NOTE: This has been generated via update-readme.js -->
319
+
264
320
  - **browser_tab_new**
265
321
  - Description: Open a new tab
266
322
  - Parameters:
267
323
  - `url` (string, optional): The URL to navigate to in the new tab. If not provided, the new tab will be blank.
268
324
 
325
+ <!-- NOTE: This has been generated via update-readme.js -->
326
+
269
327
  - **browser_tab_select**
270
328
  - Description: Select a tab by index
271
329
  - Parameters:
272
330
  - `index` (number): The index of the tab to select
273
331
 
332
+ <!-- NOTE: This has been generated via update-readme.js -->
333
+
274
334
  - **browser_tab_close**
275
335
  - Description: Close a tab
276
336
  - Parameters:
@@ -278,51 +338,92 @@ server.connect(transport);
278
338
 
279
339
  ### Navigation
280
340
 
341
+ <!-- NOTE: This has been generated via update-readme.js -->
342
+
281
343
  - **browser_navigate**
282
344
  - Description: Navigate to a URL
283
345
  - Parameters:
284
346
  - `url` (string): The URL to navigate to
285
347
 
348
+ <!-- NOTE: This has been generated via update-readme.js -->
349
+
286
350
  - **browser_navigate_back**
287
351
  - Description: Go back to the previous page
288
352
  - Parameters: None
289
353
 
354
+ <!-- NOTE: This has been generated via update-readme.js -->
355
+
290
356
  - **browser_navigate_forward**
291
357
  - Description: Go forward to the next page
292
358
  - Parameters: None
293
359
 
294
360
  ### Keyboard
295
361
 
362
+ <!-- NOTE: This has been generated via update-readme.js -->
363
+
296
364
  - **browser_press_key**
297
365
  - Description: Press a key on the keyboard
298
366
  - Parameters:
299
367
  - `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
300
368
 
369
+ ### Console
370
+
371
+ <!-- NOTE: This has been generated via update-readme.js -->
372
+
373
+ - **browser_console_messages**
374
+ - Description: Returns all console messages
375
+ - Parameters: None
376
+
301
377
  ### Files and Media
302
378
 
379
+ <!-- NOTE: This has been generated via update-readme.js -->
380
+
303
381
  - **browser_file_upload**
304
- - Description: Choose one or multiple files to upload
382
+ - Description: Upload one or multiple files
305
383
  - Parameters:
306
384
  - `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.
307
385
 
386
+ <!-- NOTE: This has been generated via update-readme.js -->
387
+
308
388
  - **browser_pdf_save**
309
389
  - Description: Save page as PDF
310
390
  - Parameters: None
311
391
 
312
392
  ### Utilities
313
393
 
314
- - **browser_wait**
315
- - Description: Wait for a specified time in seconds
316
- - Parameters:
317
- - `time` (number): The time to wait in seconds (capped at 10 seconds)
394
+ <!-- NOTE: This has been generated via update-readme.js -->
318
395
 
319
396
  - **browser_close**
320
397
  - Description: Close the page
321
398
  - Parameters: None
322
399
 
400
+ <!-- NOTE: This has been generated via update-readme.js -->
401
+
402
+ - **browser_wait**
403
+ - Description: Wait for a specified time in seconds
404
+ - Parameters:
405
+ - `time` (number): The time to wait in seconds
406
+
407
+ <!-- NOTE: This has been generated via update-readme.js -->
408
+
409
+ - **browser_resize**
410
+ - Description: Resize the browser window
411
+ - Parameters:
412
+ - `width` (number): Width of the browser window
413
+ - `height` (number): Height of the browser window
414
+
415
+ <!-- NOTE: This has been generated via update-readme.js -->
416
+
323
417
  - **browser_install**
324
418
  - Description: Install the browser specified in the config. Call this if you get an error about the browser not being installed.
325
419
  - Parameters: None
326
420
 
327
- ### Vision Mode
421
+ <!-- NOTE: This has been generated via update-readme.js -->
422
+
423
+ - **browser_handle_dialog**
424
+ - Description: Handle a dialog
425
+ - Parameters:
426
+ - `accept` (boolean): Whether to accept the dialog.
427
+ - `promptText` (string, optional): The text of the prompt in case of a prompt dialog.
328
428
 
429
+ <!--- End of generated section -->
package/index.d.ts CHANGED
@@ -15,33 +15,46 @@
15
15
  * limitations under the License.
16
16
  */
17
17
 
18
- import type { LaunchOptions } from 'playwright';
19
18
  import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
20
19
 
21
20
  type ToolCapability = 'core' | 'tabs' | 'pdf' | 'history' | 'wait' | 'files' | 'install';
22
21
 
23
22
  type Options = {
24
- /**
25
- * Path to the user data directory.
26
- */
27
- userDataDir?: string;
28
-
29
- /**
30
- * Launch options for the browser.
31
- */
32
- launchOptions?: LaunchOptions;
33
-
34
- /**
35
- * Use screenshots instead of snapshots. Less accurate, reliable and overall
36
- * slower, but contains visual representation of the page.
37
- * @default false
38
- */
39
- vision?: boolean;
40
-
41
- /**
42
- * Capabilities to enable.
43
- */
44
- capabilities?: ToolCapability[];
23
+ /**
24
+ * The browser to use (e.g., 'chrome', 'chromium', 'firefox', 'webkit', 'msedge').
25
+ */
26
+ browser?: string;
27
+ /**
28
+ * Path to a user data directory for browser profile persistence.
29
+ */
30
+ userDataDir?: string;
31
+ /**
32
+ * Whether to run the browser in headless mode (default: true).
33
+ */
34
+ headless?: boolean;
35
+ /**
36
+ * Path to a custom browser executable.
37
+ */
38
+ executablePath?: string;
39
+ /**
40
+ * Chrome DevTools Protocol endpoint to connect to an existing browser instance.
41
+ */
42
+ cdpEndpoint?: string;
43
+ /**
44
+ * Enable vision capabilities (e.g., visual automation or OCR).
45
+ */
46
+ vision?: boolean;
47
+ /**
48
+ * List of enabled tool capabilities. Possible values:
49
+ * - 'core': Core browser automation features.
50
+ * - 'tabs': Tab management features.
51
+ * - 'pdf': PDF generation and manipulation.
52
+ * - 'history': Browser history access.
53
+ * - 'wait': Wait and timing utilities.
54
+ * - 'files': File upload/download support.
55
+ * - 'install': Browser installation utilities.
56
+ */
57
+ capabilities?: ToolCapability[];
45
58
  };
46
-
47
- export function createServer(options?: Options): Server;
59
+ export declare function createServer(options?: Options): Promise<Server>;
60
+ export {};