You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-9Lines changed: 40 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -270,15 +270,6 @@ Playwright MCP server supports following arguments. They can be provided in the
270
270
server is allowed to serve from.
271
271
Defaults to the host the server is bound
272
272
to. Pass '*' to disable the host check.
273
-
--allowed-origins <origins> semicolon-separated list of origins to
274
-
allow the browser to request. Default is
275
-
to allow all.
276
-
--blocked-origins <origins> semicolon-separated list of origins to
277
-
block the browser from requesting.
278
-
Blocklist is evaluated before allowlist.
279
-
If used without the allowlist, requests
280
-
not matching the blocklist are still
281
-
allowed.
282
273
--block-service-workers block service workers
283
274
--browser <browser> browser or chrome channel to use,
284
275
possible values: chrome, firefox,
@@ -307,6 +298,8 @@ Playwright MCP server supports following arguments. They can be provided in the
307
298
localhost. Use 0.0.0.0 to bind to all
308
299
interfaces.
309
300
--ignore-https-errors ignore https errors
301
+
--init-page <path...> path to TypeScript file to evaluate on
302
+
Playwright page object
310
303
--init-script <path...> path to JavaScript file to add as an
311
304
initialization script. The script will
312
305
be evaluated in every page before any of
@@ -402,6 +395,35 @@ state [here](https://playwright.dev/docs/auth).
402
395
403
396
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.
404
397
398
+
### Initial state
399
+
400
+
There are multiple ways to provide the initial state to the browser context or a page.
401
+
402
+
For the storage state, you can either:
403
+
- Start with a user data directory using the `--user-data-dir` argument. This will persist all browser data between the sessions.
404
+
- 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.
405
+
406
+
For the page state, you can use:
407
+
408
+
-`--init-page` to point to a TypeScript file that will be evaluated on the Playwright page object. This allows you to run arbitrary code to set up the page.
-`--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.
420
+
This is useful for overriding browser APIs or setting up the environment.
421
+
422
+
```js
423
+
// init-script.js
424
+
window.isPlaywrightMCP=true;
425
+
```
426
+
405
427
### Configuration file
406
428
407
429
The Playwright MCP server can be configured using a JSON configuration file. You can specify the configuration file
<!-- NOTE: This has been generated via update-readme.js -->
710
732
733
+
-**browser_run_code**
734
+
- Title: Run Playwright code
735
+
- Description: Run Playwright code snippet
736
+
- Parameters:
737
+
-`code` (string): Playwright code snippet to run. The snippet should access the `page` object to interact with the page. Can make multiple statements. For example: `await page.getByRole('button', { name: 'Submit' }).click();`
738
+
- Read-only: **false**
739
+
740
+
<!-- NOTE: This has been generated via update-readme.js -->
0 commit comments