mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2026-01-30 06:22:03 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c016643bf9 | ||
|
|
8cc557d677 | ||
|
|
15d382b940 | ||
|
|
e72701b21c | ||
|
|
8ee8445342 | ||
|
|
ac6e678135 | ||
|
|
b945ace746 | ||
|
|
b3dce4097e | ||
|
|
67ed859c2a | ||
|
|
7da5e7273c | ||
|
|
fe59d4b35f |
91
README.md
91
README.md
@@ -84,7 +84,13 @@ Follow the MCP install [guide](https://modelcontextprotocol.io/quickstart/user),
|
||||
<details>
|
||||
<summary>Codex</summary>
|
||||
|
||||
Create or edit the configuration file `~/.codex/config.toml` and add:
|
||||
Use the Codex CLI to add the Playwright MCP server:
|
||||
|
||||
```bash
|
||||
codex mcp add playwright npx "@playwright/mcp@latest"
|
||||
```
|
||||
|
||||
Alternatively, create or edit the configuration file `~/.codex/config.toml` and add:
|
||||
|
||||
```toml
|
||||
[mcp_servers.playwright]
|
||||
@@ -109,6 +115,21 @@ Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name to your liking, u
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Factory</summary>
|
||||
|
||||
Use the Factory CLI to add the Playwright MCP server:
|
||||
|
||||
```bash
|
||||
droid mcp add playwright "npx @playwright/mcp@latest"
|
||||
```
|
||||
|
||||
Alternatively, type `/mcp` within Factory droid to open an interactive UI for managing MCP servers.
|
||||
|
||||
For more information, see the [Factory MCP documentation](https://docs.factory.ai/cli/configuration/mcp).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Gemini CLI</summary>
|
||||
|
||||
@@ -128,6 +149,25 @@ Follow the MCP install [guide](https://github.com/google-gemini/gemini-cli/blob/
|
||||
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".
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Kiro</summary>
|
||||
|
||||
Follow the MCP Servers [documentation](https://kiro.dev/docs/mcp/). For example in `.kiro/settings/mcp.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"playwright": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"@playwright/mcp@latest"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>LM Studio</summary>
|
||||
|
||||
@@ -230,15 +270,6 @@ Playwright MCP server supports following arguments. They can be provided in the
|
||||
server is allowed to serve from.
|
||||
Defaults to the host the server is bound
|
||||
to. Pass '*' to disable the host check.
|
||||
--allowed-origins <origins> semicolon-separated list of origins to
|
||||
allow the browser to request. Default is
|
||||
to allow all.
|
||||
--blocked-origins <origins> semicolon-separated list of origins to
|
||||
block the browser from requesting.
|
||||
Blocklist is evaluated before allowlist.
|
||||
If used without the allowlist, requests
|
||||
not matching the blocklist are still
|
||||
allowed.
|
||||
--block-service-workers block service workers
|
||||
--browser <browser> browser or chrome channel to use,
|
||||
possible values: chrome, firefox,
|
||||
@@ -267,6 +298,8 @@ Playwright MCP server supports following arguments. They can be provided in the
|
||||
localhost. Use 0.0.0.0 to bind to all
|
||||
interfaces.
|
||||
--ignore-https-errors ignore https errors
|
||||
--init-page <path...> path to TypeScript file to evaluate on
|
||||
Playwright page object
|
||||
--init-script <path...> path to JavaScript file to add as an
|
||||
initialization script. The script will
|
||||
be evaluated in every page before any of
|
||||
@@ -362,6 +395,35 @@ state [here](https://playwright.dev/docs/auth).
|
||||
|
||||
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.
|
||||
|
||||
### Initial state
|
||||
|
||||
There are multiple ways to provide the initial state to the browser context or a page.
|
||||
|
||||
For the storage state, you can either:
|
||||
- Start with a user data directory using the `--user-data-dir` argument. This will persist all browser data between the sessions.
|
||||
- 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.
|
||||
|
||||
For the page state, you can use:
|
||||
|
||||
- `--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.
|
||||
|
||||
```ts
|
||||
// init-page.ts
|
||||
export default async ({ page }) => {
|
||||
await page.context().grantPermissions(['geolocation']);
|
||||
await page.context().setGeolocation({ latitude: 37.7749, longitude: -122.4194 });
|
||||
await page.setViewportSize({ width: 1280, height: 720 });
|
||||
};
|
||||
```
|
||||
|
||||
- `--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.
|
||||
This is useful for overriding browser APIs or setting up the environment.
|
||||
|
||||
```js
|
||||
// init-script.js
|
||||
window.isPlaywrightMCP = true;
|
||||
```
|
||||
|
||||
### Configuration file
|
||||
|
||||
The Playwright MCP server can be configured using a JSON configuration file. You can specify the configuration file
|
||||
@@ -668,6 +730,15 @@ http.createServer(async (req, res) => {
|
||||
|
||||
<!-- NOTE: This has been generated via update-readme.js -->
|
||||
|
||||
- **browser_run_code**
|
||||
- Title: Run Playwright code
|
||||
- Description: Run Playwright code snippet
|
||||
- Parameters:
|
||||
- `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();`
|
||||
- Read-only: **false**
|
||||
|
||||
<!-- NOTE: This has been generated via update-readme.js -->
|
||||
|
||||
- **browser_select_option**
|
||||
- Title: Select option
|
||||
- Description: Select an option in a dropdown
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Playwright MCP Bridge",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.47",
|
||||
"description": "Share browser tabs with Playwright MCP server",
|
||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9nMS2b0WCohjVHPGb8D9qAdkbIngDqoAjTeSccHJijgcONejge+OJxOQOMLu7b0ovt1c9BiEJa5JcpM+EHFVGL1vluBxK71zmBy1m2f9vZF3HG0LSCp7YRkum9rAIEthDwbkxx6XTvpmAY5rjFa/NON6b9Hlbo+8peUSkoOK7HTwYnnI36asZ9eUTiveIf+DMPLojW2UX33vDWG2UKvMVDewzclb4+uLxAYshY7Mx8we/b44xu+Anb/EBLKjOPk9Yh541xJ5Ozc8EiP/5yxOp9c/lRiYUHaRW+4r0HKZyFt0eZ52ti2iM4Nfk7jRXR7an3JPsUIf5deC/1cVM/+1ZQIDAQAB",
|
||||
"permissions": [
|
||||
|
||||
12
extension/package-lock.json
generated
12
extension/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@playwright/mcp-extension",
|
||||
"version": "0.0.37",
|
||||
"version": "0.0.47",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@playwright/mcp-extension",
|
||||
"version": "0.0.37",
|
||||
"version": "0.0.47",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/chrome": "^0.0.315",
|
||||
@@ -16,7 +16,7 @@
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"typescript": "^5.8.2",
|
||||
"vite": "^5.4.20",
|
||||
"vite": "^5.4.21",
|
||||
"vite-plugin-static-copy": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1796,9 +1796,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.4.20",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.20.tgz",
|
||||
"integrity": "sha512-j3lYzGC3P+B5Yfy/pfKNgVEg4+UtcIJcVRt2cDjIOmhLourAqPqf8P7acgxeiSgUB7E3p2P8/3gNIgDLpwzs4g==",
|
||||
"version": "5.4.21",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",
|
||||
"integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@playwright/mcp-extension",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.47",
|
||||
"description": "Playwright MCP Browser Extension",
|
||||
"private": true,
|
||||
"repository": {
|
||||
@@ -29,7 +29,7 @@
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"typescript": "^5.8.2",
|
||||
"vite": "^5.4.20",
|
||||
"vite": "^5.4.21",
|
||||
"vite-plugin-static-copy": "^3.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
32
package-lock.json
generated
32
package-lock.json
generated
@@ -1,23 +1,23 @@
|
||||
{
|
||||
"name": "@playwright/mcp",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.47",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@playwright/mcp",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.47",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.57.0-alpha-2025-10-16",
|
||||
"playwright-core": "1.57.0-alpha-2025-10-16"
|
||||
"playwright": "1.57.0-alpha-2025-11-14",
|
||||
"playwright-core": "1.57.0-alpha-2025-11-14"
|
||||
},
|
||||
"bin": {
|
||||
"mcp-server-playwright": "cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.17.5",
|
||||
"@playwright/test": "1.57.0-alpha-2025-10-16",
|
||||
"@playwright/test": "1.57.0-alpha-2025-11-14",
|
||||
"@types/node": "^24.3.0",
|
||||
"zod-to-json-schema": "^3.24.6"
|
||||
},
|
||||
@@ -50,13 +50,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.57.0-alpha-2025-10-16",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.57.0-alpha-2025-10-16.tgz",
|
||||
"integrity": "sha512-WeQm4QMmW78sKNSPrkMCkhm5jrmDYJushuuDX434EsG8l0+1yW/CxDKaUsy+URZay162SByoFbclaoJ5ElN1yg==",
|
||||
"version": "1.57.0-alpha-2025-11-14",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.57.0-alpha-2025-11-14.tgz",
|
||||
"integrity": "sha512-CtIvv2qi3Wji3G2Oiwj26QeGosdj6z6IgzQyw3Jp2t8uVWDTQtNekdHi8Q8ONJqlJID8Lf45DMl4o31uOMzVOw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.57.0-alpha-2025-10-16"
|
||||
"playwright": "1.57.0-alpha-2025-11-14"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
@@ -825,12 +825,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.57.0-alpha-2025-10-16",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.57.0-alpha-2025-10-16.tgz",
|
||||
"integrity": "sha512-a1527pq+d/EQRwfoUpnTfjZqA04qs5y3A3HedQZiU6Vicc35VcIIpYin99pklFQdyBd1M9oj9oKFsHbilflo6g==",
|
||||
"version": "1.57.0-alpha-2025-11-14",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.57.0-alpha-2025-11-14.tgz",
|
||||
"integrity": "sha512-B91cAwJw+dlsPi6GnJD6bAUfso/ygmrxsXHnbFqOd5UmGo8bZzFf7WvSkB/47lOSYIP+9szVXwMwIsZ4Fj+rAQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.57.0-alpha-2025-10-16"
|
||||
"playwright-core": "1.57.0-alpha-2025-11-14"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
@@ -843,9 +843,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.57.0-alpha-2025-10-16",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.57.0-alpha-2025-10-16.tgz",
|
||||
"integrity": "sha512-QfB4sdxqkxN3mrBii/Fqh65qSggrPbcDMJcsqjwsShn1lxbX48P8WuNNSdF05lwDfgS3BsQBkay3SdY3caueAg==",
|
||||
"version": "1.57.0-alpha-2025-11-14",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.57.0-alpha-2025-11-14.tgz",
|
||||
"integrity": "sha512-Elz1kUiW8naXjunmfgaYh9inaqxT04FjR/CDOi2IH7ZBDTov6tTcNV4bObNeHSBV76YVPHsRK/96v3kG9F+5sQ==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@playwright/mcp",
|
||||
"version": "0.0.43",
|
||||
"version": "0.0.47",
|
||||
"description": "Playwright Tools for MCP",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -18,6 +18,8 @@
|
||||
"lint": "npm run update-readme",
|
||||
"update-readme": "node update-readme.js",
|
||||
"docker-build": "docker build --no-cache -t playwright-mcp-dev:latest .",
|
||||
"docker-rm": "docker rm playwright-mcp-dev",
|
||||
"docker-run": "docker run -it -p 8080:8080 --name playwright-mcp-dev playwright-mcp-dev:latest",
|
||||
"test": "playwright test",
|
||||
"ctest": "playwright test --project=chrome",
|
||||
"ftest": "playwright test --project=firefox",
|
||||
@@ -35,15 +37,15 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"playwright": "1.57.0-alpha-2025-10-16",
|
||||
"playwright-core": "1.57.0-alpha-2025-10-16"
|
||||
"playwright": "1.57.0-alpha-2025-11-14",
|
||||
"playwright-core": "1.57.0-alpha-2025-11-14"
|
||||
},
|
||||
"bin": {
|
||||
"mcp-server-playwright": "cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.17.5",
|
||||
"@playwright/test": "1.57.0-alpha-2025-10-16",
|
||||
"@playwright/test": "1.57.0-alpha-2025-11-14",
|
||||
"@types/node": "^24.3.0",
|
||||
"zod-to-json-schema": "^3.24.6"
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ test('test snapshot tool list', async ({ client }) => {
|
||||
'browser_network_requests',
|
||||
'browser_press_key',
|
||||
'browser_resize',
|
||||
'browser_run_code',
|
||||
'browser_snapshot',
|
||||
'browser_tabs',
|
||||
'browser_take_screenshot',
|
||||
@@ -67,6 +68,7 @@ test('test tool list proxy mode', async ({ startClient }) => {
|
||||
'browser_network_requests',
|
||||
'browser_press_key',
|
||||
'browser_resize',
|
||||
'browser_run_code',
|
||||
'browser_snapshot',
|
||||
'browser_tabs',
|
||||
'browser_take_screenshot',
|
||||
|
||||
@@ -16,10 +16,16 @@
|
||||
|
||||
import { test, expect } from './fixtures';
|
||||
|
||||
test('browser_click', async ({ client, server, mcpBrowser }) => {
|
||||
test('browser_click', async ({ client, server }) => {
|
||||
server.setContent('/', `
|
||||
<title>Title</title>
|
||||
<button>Submit</button>
|
||||
<script>
|
||||
const button = document.querySelector('button');
|
||||
button.addEventListener('click', () => {
|
||||
button.focus(); // without manual focus, webkit focuses body
|
||||
});
|
||||
</script>
|
||||
`, 'text/html');
|
||||
|
||||
expect(await client.callTool({
|
||||
@@ -38,6 +44,6 @@ test('browser_click', async ({ client, server, mcpBrowser }) => {
|
||||
},
|
||||
})).toHaveResponse({
|
||||
code: `await page.getByRole('button', { name: 'Submit' }).click();`,
|
||||
pageState: expect.stringContaining(`- button "Submit" ${mcpBrowser !== 'webkit' || process.platform === 'linux' ? '[active] ' : ''}[ref=e2]`),
|
||||
pageState: expect.stringContaining(`button "Submit" [active] [ref=e2]`),
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user