mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2026-02-02 20:43:39 +00:00
Compare commits
1 Commits
v0.0.55
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dccd4e908b |
46
.github/workflows/publish.yml
vendored
46
.github/workflows/publish.yml
vendored
@@ -147,3 +147,49 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
gh release upload ${{github.event.release.tag_name}} ./extension/playwright-mcp-extension-${{ steps.get-version.outputs.version }}.zip
|
gh release upload ${{github.event.release.tag_name}} ./extension/playwright-mcp-extension-${{ steps.get-version.outputs.version }}.zip
|
||||||
|
|
||||||
|
publish-release-mcp-registry:
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: allow-mcp-registry-publishing
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write # Needed for GitHub OIDC authentication
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Clone MCP Registry and build publisher tool
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
cd ${{ runner.temp }}
|
||||||
|
|
||||||
|
# Install Microsoft Go
|
||||||
|
go run github.com/microsoft/go-infra/goinstallscript@v1.1.0
|
||||||
|
./go-install.ps1 -GitHubActionsPath
|
||||||
|
|
||||||
|
# Enable compliant crypto
|
||||||
|
$env:GOEXPERIMENT = "systemcrypto"
|
||||||
|
|
||||||
|
# Clone and build the publisher tool
|
||||||
|
git clone --branch "v1.3.7" https://github.com/modelcontextprotocol/registry
|
||||||
|
cd registry
|
||||||
|
go build -o ${{ runner.temp }}/mcp-publisher ./cmd/publisher
|
||||||
|
|
||||||
|
# show help for the tool to ensure it's working
|
||||||
|
${{ runner.temp }}/mcp-publisher --help
|
||||||
|
- name: Azure Login via OIDC
|
||||||
|
uses: azure/login@v2
|
||||||
|
with:
|
||||||
|
client-id: ${{ secrets.AZURE_MCP_REGISTRY_CLIENT_ID }}
|
||||||
|
tenant-id: ${{ secrets.AZURE_MCP_REGISTRY_TENANT_ID }}
|
||||||
|
subscription-id: ${{ secrets.AZURE_MCP_REGISTRY_SUBSCRIPTION_ID }}
|
||||||
|
- name: Publish to the MCP Registry
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
# log in using Key Vault
|
||||||
|
${{ runner.temp }}/mcp-publisher `
|
||||||
|
login dns azure-key-vault `
|
||||||
|
-vault "${{ secrets.KV_NAME }}" -key "${{ secrets.KV_KEY_NAME }}" `
|
||||||
|
-domain microsoft.com
|
||||||
|
|
||||||
|
# publish the server.json
|
||||||
|
${{ runner.temp }}/mcp-publisher publish ./.mcp/server.json
|
||||||
|
|||||||
22
.mcp/server.json
Normal file
22
.mcp/server.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
|
||||||
|
"name": "com.microsoft/playwright-mcp",
|
||||||
|
"title": "Playwright",
|
||||||
|
"description": "Automate web browsers using accessibility trees for testing and data extraction.",
|
||||||
|
"repository": {
|
||||||
|
"url": "https://github.com/microsoft/playwright-mcp",
|
||||||
|
"source": "github"
|
||||||
|
},
|
||||||
|
"websiteUrl": "https://github.com/microsoft/playwright-mcp",
|
||||||
|
"version": "0.0.52",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"registryType": "npm",
|
||||||
|
"identifier": "@playwright/mcp",
|
||||||
|
"version": "0.0.52",
|
||||||
|
"transport": {
|
||||||
|
"type": "stdio"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
46
README.md
46
README.md
@@ -81,38 +81,6 @@ Follow the MCP install [guide](https://modelcontextprotocol.io/quickstart/user),
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Cline</summary>
|
|
||||||
|
|
||||||
Follow the instruction in the section [MCP Integration](https://docs.cline.bot/mcp/mcp-overview)
|
|
||||||
|
|
||||||
Connection Types
|
|
||||||
Local (stdio): Cline runs the server as a local process.
|
|
||||||
Remote (streamableHttp): hosted/cloud environments.
|
|
||||||
Legacy (sse): Only use if the host doesn't support the modern streamableHttp protocol.
|
|
||||||
|
|
||||||
Example: Local Setup
|
|
||||||
Add the following to your cline_mcp_settings.json file:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"playwright": {
|
|
||||||
"type": "stdio",
|
|
||||||
"command": "npx",
|
|
||||||
"timeout": 30,
|
|
||||||
"args": [
|
|
||||||
"-y",
|
|
||||||
"@playwright/mcp@latest"
|
|
||||||
],
|
|
||||||
"disabled": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Codex</summary>
|
<summary>Codex</summary>
|
||||||
|
|
||||||
@@ -340,14 +308,6 @@ Playwright MCP server supports following arguments. They can be provided in the
|
|||||||
Important: *does not* serve as a
|
Important: *does not* serve as a
|
||||||
security boundary and *does not* affect
|
security boundary and *does not* affect
|
||||||
redirects.
|
redirects.
|
||||||
--allow-unrestricted-file-access allow access to files outside of the
|
|
||||||
workspace roots. Also allows
|
|
||||||
unrestricted access to file:// URLs. By
|
|
||||||
default access to file system is
|
|
||||||
restricted to workspace root directories
|
|
||||||
(or cwd if no roots are configured)
|
|
||||||
only, and navigation to file:// URLs is
|
|
||||||
blocked.
|
|
||||||
--blocked-origins <origins> semicolon-separated list of origins to
|
--blocked-origins <origins> semicolon-separated list of origins to
|
||||||
block the browser from requesting.
|
block the browser from requesting.
|
||||||
Blocklist is evaluated before allowlist.
|
Blocklist is evaluated before allowlist.
|
||||||
@@ -705,12 +665,6 @@ npx @playwright/mcp@latest --config path/to/config.json
|
|||||||
*/
|
*/
|
||||||
mode?: 'incremental' | 'full' | 'none';
|
mode?: 'incremental' | 'full' | 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to allow file uploads from anywhere on the file system.
|
|
||||||
* By default (false), file uploads are restricted to paths within the MCP roots only.
|
|
||||||
*/
|
|
||||||
allowUnrestrictedFileAccess?: boolean;
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
6
config.d.ts
vendored
6
config.d.ts
vendored
@@ -189,10 +189,4 @@ export type Config = {
|
|||||||
*/
|
*/
|
||||||
mode?: 'incremental' | 'full' | 'none';
|
mode?: 'incremental' | 'full' | 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to allow file uploads from anywhere on the file system.
|
|
||||||
* By default (false), file uploads are restricted to paths within the MCP roots only.
|
|
||||||
*/
|
|
||||||
allowUnrestrictedFileAccess?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Playwright MCP Bridge",
|
"name": "Playwright MCP Bridge",
|
||||||
"version": "0.0.55",
|
"version": "0.0.52",
|
||||||
"description": "Share browser tabs with Playwright MCP server",
|
"description": "Share browser tabs with Playwright MCP server",
|
||||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9nMS2b0WCohjVHPGb8D9qAdkbIngDqoAjTeSccHJijgcONejge+OJxOQOMLu7b0ovt1c9BiEJa5JcpM+EHFVGL1vluBxK71zmBy1m2f9vZF3HG0LSCp7YRkum9rAIEthDwbkxx6XTvpmAY5rjFa/NON6b9Hlbo+8peUSkoOK7HTwYnnI36asZ9eUTiveIf+DMPLojW2UX33vDWG2UKvMVDewzclb4+uLxAYshY7Mx8we/b44xu+Anb/EBLKjOPk9Yh541xJ5Ozc8EiP/5yxOp9c/lRiYUHaRW+4r0HKZyFt0eZ52ti2iM4Nfk7jRXR7an3JPsUIf5deC/1cVM/+1ZQIDAQAB",
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9nMS2b0WCohjVHPGb8D9qAdkbIngDqoAjTeSccHJijgcONejge+OJxOQOMLu7b0ovt1c9BiEJa5JcpM+EHFVGL1vluBxK71zmBy1m2f9vZF3HG0LSCp7YRkum9rAIEthDwbkxx6XTvpmAY5rjFa/NON6b9Hlbo+8peUSkoOK7HTwYnnI36asZ9eUTiveIf+DMPLojW2UX33vDWG2UKvMVDewzclb4+uLxAYshY7Mx8we/b44xu+Anb/EBLKjOPk9Yh541xJ5Ozc8EiP/5yxOp9c/lRiYUHaRW+4r0HKZyFt0eZ52ti2iM4Nfk7jRXR7an3JPsUIf5deC/1cVM/+1ZQIDAQAB",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
|||||||
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@playwright/mcp-extension",
|
"name": "@playwright/mcp-extension",
|
||||||
"version": "0.0.55",
|
"version": "0.0.52",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@playwright/mcp-extension",
|
"name": "@playwright/mcp-extension",
|
||||||
"version": "0.0.55",
|
"version": "0.0.52",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chrome": "^0.0.315",
|
"@types/chrome": "^0.0.315",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@playwright/mcp-extension",
|
"name": "@playwright/mcp-extension",
|
||||||
"version": "0.0.55",
|
"version": "0.0.52",
|
||||||
"description": "Playwright MCP Browser Extension",
|
"description": "Playwright MCP Browser Extension",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -44,18 +44,8 @@ const ConnectApp: React.FC = () => {
|
|||||||
const relayUrl = params.get('mcpRelayUrl');
|
const relayUrl = params.get('mcpRelayUrl');
|
||||||
|
|
||||||
if (!relayUrl) {
|
if (!relayUrl) {
|
||||||
handleReject('Missing mcpRelayUrl parameter in URL.');
|
setShowButtons(false);
|
||||||
return;
|
setStatus({ type: 'error', message: 'Missing mcpRelayUrl parameter in URL.' });
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const host = new URL(relayUrl).hostname;
|
|
||||||
if (host !== '127.0.0.1' && host !== '[::1]') {
|
|
||||||
handleReject(`MCP extension only allows loopback connections (127.0.0.1 or [::1]). Received host: ${host}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
handleReject(`Invalid mcpRelayUrl parameter in URL: ${relayUrl}. ${e}`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,28 @@ const test = base.extend<TestFixtures>({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function startAndCallConnectTool(browserWithExtension: BrowserWithExtension, startClient: StartClient): Promise<Client> {
|
||||||
|
const { client } = await startClient({
|
||||||
|
args: [`--connect-tool`],
|
||||||
|
config: {
|
||||||
|
browser: {
|
||||||
|
userDataDir: browserWithExtension.userDataDir,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(await client.callTool({
|
||||||
|
name: 'browser_connect',
|
||||||
|
arguments: {
|
||||||
|
name: 'extension'
|
||||||
|
}
|
||||||
|
})).toHaveResponse({
|
||||||
|
result: 'Successfully changed connection method.',
|
||||||
|
});
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
async function startWithExtensionFlag(browserWithExtension: BrowserWithExtension, startClient: StartClient): Promise<Client> {
|
async function startWithExtensionFlag(browserWithExtension: BrowserWithExtension, startClient: StartClient): Promise<Client> {
|
||||||
const { client } = await startClient({
|
const { client } = await startClient({
|
||||||
args: [`--extension`],
|
args: [`--extension`],
|
||||||
@@ -115,137 +137,144 @@ const testWithOldExtensionVersion = test.extend({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
test(`navigate with extension`, async ({ browserWithExtension, startClient, server }) => {
|
for (const [mode, startClientMethod] of [
|
||||||
const browserContext = await browserWithExtension.launch();
|
['connect-tool', startAndCallConnectTool],
|
||||||
|
['extension-flag', startWithExtensionFlag],
|
||||||
|
] as const) {
|
||||||
|
|
||||||
const client = await startWithExtensionFlag(browserWithExtension, startClient);
|
test(`navigate with extension (${mode})`, async ({ browserWithExtension, startClient, server }) => {
|
||||||
|
const browserContext = await browserWithExtension.launch();
|
||||||
|
|
||||||
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
const client = await startClientMethod(browserWithExtension, startClient);
|
||||||
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
|
||||||
|
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
||||||
|
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
||||||
|
});
|
||||||
|
|
||||||
|
const navigateResponse = client.callTool({
|
||||||
|
name: 'browser_navigate',
|
||||||
|
arguments: { url: server.HELLO_WORLD },
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectorPage = await confirmationPagePromise;
|
||||||
|
// For browser_navigate command, the UI shows Allow/Reject buttons instead of tab selector
|
||||||
|
await selectorPage.getByRole('button', { name: 'Allow' }).click();
|
||||||
|
|
||||||
|
expect(await navigateResponse).toHaveResponse({
|
||||||
|
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const navigateResponse = client.callTool({
|
test(`snapshot of an existing page (${mode})`, async ({ browserWithExtension, startClient, server }) => {
|
||||||
name: 'browser_navigate',
|
const browserContext = await browserWithExtension.launch();
|
||||||
arguments: { url: server.HELLO_WORLD },
|
|
||||||
|
const page = await browserContext.newPage();
|
||||||
|
await page.goto(server.HELLO_WORLD);
|
||||||
|
|
||||||
|
// Another empty page.
|
||||||
|
await browserContext.newPage();
|
||||||
|
expect(browserContext.pages()).toHaveLength(3);
|
||||||
|
|
||||||
|
const client = await startClientMethod(browserWithExtension, startClient);
|
||||||
|
expect(browserContext.pages()).toHaveLength(3);
|
||||||
|
|
||||||
|
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
||||||
|
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
||||||
|
});
|
||||||
|
|
||||||
|
const navigateResponse = client.callTool({
|
||||||
|
name: 'browser_snapshot',
|
||||||
|
arguments: { },
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectorPage = await confirmationPagePromise;
|
||||||
|
expect(browserContext.pages()).toHaveLength(4);
|
||||||
|
|
||||||
|
await selectorPage.locator('.tab-item', { hasText: 'Title' }).getByRole('button', { name: 'Connect' }).click();
|
||||||
|
|
||||||
|
expect(await navigateResponse).toHaveResponse({
|
||||||
|
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(browserContext.pages()).toHaveLength(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectorPage = await confirmationPagePromise;
|
test(`extension not installed timeout (${mode})`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => {
|
||||||
// For browser_navigate command, the UI shows Allow/Reject buttons instead of tab selector
|
useShortConnectionTimeout(100);
|
||||||
await selectorPage.getByRole('button', { name: 'Allow' }).click();
|
|
||||||
|
|
||||||
expect(await navigateResponse).toHaveResponse({
|
const browserContext = await browserWithExtension.launch();
|
||||||
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test(`snapshot of an existing page`, async ({ browserWithExtension, startClient, server }) => {
|
const client = await startClientMethod(browserWithExtension, startClient);
|
||||||
const browserContext = await browserWithExtension.launch();
|
|
||||||
|
|
||||||
const page = await browserContext.newPage();
|
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
||||||
await page.goto(server.HELLO_WORLD);
|
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
||||||
|
});
|
||||||
|
|
||||||
// Another empty page.
|
expect(await client.callTool({
|
||||||
await browserContext.newPage();
|
name: 'browser_navigate',
|
||||||
expect(browserContext.pages()).toHaveLength(3);
|
arguments: { url: server.HELLO_WORLD },
|
||||||
|
})).toHaveResponse({
|
||||||
|
result: expect.stringContaining('Extension connection timeout. Make sure the "Playwright MCP Bridge" extension is installed.'),
|
||||||
|
isError: true,
|
||||||
|
});
|
||||||
|
|
||||||
const client = await startWithExtensionFlag(browserWithExtension, startClient);
|
await confirmationPagePromise;
|
||||||
expect(browserContext.pages()).toHaveLength(3);
|
|
||||||
|
|
||||||
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
|
||||||
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const navigateResponse = client.callTool({
|
testWithOldExtensionVersion(`works with old extension version (${mode})`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => {
|
||||||
name: 'browser_snapshot',
|
useShortConnectionTimeout(500);
|
||||||
arguments: { },
|
|
||||||
|
// Prelaunch the browser, so that it is properly closed after the test.
|
||||||
|
const browserContext = await browserWithExtension.launch();
|
||||||
|
|
||||||
|
const client = await startClientMethod(browserWithExtension, startClient);
|
||||||
|
|
||||||
|
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
||||||
|
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
||||||
|
});
|
||||||
|
|
||||||
|
const navigateResponse = client.callTool({
|
||||||
|
name: 'browser_navigate',
|
||||||
|
arguments: { url: server.HELLO_WORLD },
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectorPage = await confirmationPagePromise;
|
||||||
|
// For browser_navigate command, the UI shows Allow/Reject buttons instead of tab selector
|
||||||
|
await selectorPage.getByRole('button', { name: 'Allow' }).click();
|
||||||
|
|
||||||
|
expect(await navigateResponse).toHaveResponse({
|
||||||
|
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectorPage = await confirmationPagePromise;
|
test(`extension needs update (${mode})`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout, overrideProtocolVersion }) => {
|
||||||
expect(browserContext.pages()).toHaveLength(4);
|
useShortConnectionTimeout(500);
|
||||||
|
overrideProtocolVersion(1000);
|
||||||
|
|
||||||
await selectorPage.locator('.tab-item', { hasText: 'Title' }).getByRole('button', { name: 'Connect' }).click();
|
// Prelaunch the browser, so that it is properly closed after the test.
|
||||||
|
const browserContext = await browserWithExtension.launch();
|
||||||
|
|
||||||
expect(await navigateResponse).toHaveResponse({
|
const client = await startClientMethod(browserWithExtension, startClient);
|
||||||
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
|
||||||
|
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
||||||
|
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
||||||
|
});
|
||||||
|
|
||||||
|
const navigateResponse = client.callTool({
|
||||||
|
name: 'browser_navigate',
|
||||||
|
arguments: { url: server.HELLO_WORLD },
|
||||||
|
});
|
||||||
|
|
||||||
|
const confirmationPage = await confirmationPagePromise;
|
||||||
|
await expect(confirmationPage.locator('.status-banner')).toContainText(`Playwright MCP version trying to connect requires newer extension version`);
|
||||||
|
|
||||||
|
expect(await navigateResponse).toHaveResponse({
|
||||||
|
result: expect.stringContaining('Extension connection timeout.'),
|
||||||
|
isError: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(browserContext.pages()).toHaveLength(4);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
test(`extension not installed timeout`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => {
|
|
||||||
useShortConnectionTimeout(100);
|
|
||||||
|
|
||||||
const browserContext = await browserWithExtension.launch();
|
|
||||||
|
|
||||||
const client = await startWithExtensionFlag(browserWithExtension, startClient);
|
|
||||||
|
|
||||||
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
|
||||||
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(await client.callTool({
|
|
||||||
name: 'browser_navigate',
|
|
||||||
arguments: { url: server.HELLO_WORLD },
|
|
||||||
})).toHaveResponse({
|
|
||||||
result: expect.stringContaining('Extension connection timeout. Make sure the "Playwright MCP Bridge" extension is installed.'),
|
|
||||||
isError: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
await confirmationPagePromise;
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithOldExtensionVersion(`works with old extension version`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => {
|
|
||||||
useShortConnectionTimeout(500);
|
|
||||||
|
|
||||||
// Prelaunch the browser, so that it is properly closed after the test.
|
|
||||||
const browserContext = await browserWithExtension.launch();
|
|
||||||
|
|
||||||
const client = await startWithExtensionFlag(browserWithExtension, startClient);
|
|
||||||
|
|
||||||
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
|
||||||
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
|
||||||
});
|
|
||||||
|
|
||||||
const navigateResponse = client.callTool({
|
|
||||||
name: 'browser_navigate',
|
|
||||||
arguments: { url: server.HELLO_WORLD },
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectorPage = await confirmationPagePromise;
|
|
||||||
// For browser_navigate command, the UI shows Allow/Reject buttons instead of tab selector
|
|
||||||
await selectorPage.getByRole('button', { name: 'Allow' }).click();
|
|
||||||
|
|
||||||
expect(await navigateResponse).toHaveResponse({
|
|
||||||
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test(`extension needs update`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout, overrideProtocolVersion }) => {
|
|
||||||
useShortConnectionTimeout(500);
|
|
||||||
overrideProtocolVersion(1000);
|
|
||||||
|
|
||||||
// Prelaunch the browser, so that it is properly closed after the test.
|
|
||||||
const browserContext = await browserWithExtension.launch();
|
|
||||||
|
|
||||||
const client = await startWithExtensionFlag(browserWithExtension, startClient);
|
|
||||||
|
|
||||||
const confirmationPagePromise = browserContext.waitForEvent('page', page => {
|
|
||||||
return page.url().startsWith('chrome-extension://jakfalbnbhgkpmoaakfflhflbfpkailf/connect.html');
|
|
||||||
});
|
|
||||||
|
|
||||||
const navigateResponse = client.callTool({
|
|
||||||
name: 'browser_navigate',
|
|
||||||
arguments: { url: server.HELLO_WORLD },
|
|
||||||
});
|
|
||||||
|
|
||||||
const confirmationPage = await confirmationPagePromise;
|
|
||||||
await expect(confirmationPage.locator('.status-banner')).toContainText(`Playwright MCP version trying to connect requires newer extension version`);
|
|
||||||
|
|
||||||
expect(await navigateResponse).toHaveResponse({
|
|
||||||
result: expect.stringContaining('Extension connection timeout.'),
|
|
||||||
isError: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test(`custom executablePath`, async ({ startClient, server, useShortConnectionTimeout }) => {
|
test(`custom executablePath`, async ({ startClient, server, useShortConnectionTimeout }) => {
|
||||||
useShortConnectionTimeout(1000);
|
useShortConnectionTimeout(1000);
|
||||||
@@ -302,4 +331,6 @@ test(`bypass connection dialog with token`, async ({ browserWithExtension, start
|
|||||||
expect(await navigateResponse).toHaveResponse({
|
expect(await navigateResponse).toHaveResponse({
|
||||||
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
32
package-lock.json
generated
32
package-lock.json
generated
@@ -1,23 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "@playwright/mcp",
|
"name": "@playwright/mcp",
|
||||||
"version": "0.0.55",
|
"version": "0.0.52",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@playwright/mcp",
|
"name": "@playwright/mcp",
|
||||||
"version": "0.0.55",
|
"version": "0.0.52",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright": "1.58.0-alpha-2026-01-07",
|
"playwright": "1.58.0-alpha-2025-12-11",
|
||||||
"playwright-core": "1.58.0-alpha-2026-01-07"
|
"playwright-core": "1.58.0-alpha-2025-12-11"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"mcp-server-playwright": "cli.js"
|
"mcp-server-playwright": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.24.0",
|
"@modelcontextprotocol/sdk": "^1.24.0",
|
||||||
"@playwright/test": "1.58.0-alpha-2026-01-07",
|
"@playwright/test": "1.58.0-alpha-2025-12-11",
|
||||||
"@types/node": "^24.3.0"
|
"@types/node": "^24.3.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -63,13 +63,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@playwright/test": {
|
"node_modules/@playwright/test": {
|
||||||
"version": "1.58.0-alpha-2026-01-07",
|
"version": "1.58.0-alpha-2025-12-11",
|
||||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.58.0-alpha-2026-01-07.tgz",
|
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.58.0-alpha-2025-12-11.tgz",
|
||||||
"integrity": "sha512-57P04rQ8X+9UH3Wl8SDNwi0Rg7yw1jrlD3/BY44VgQn1auUdKzFonL5Nkf4hu3qsrxuSmU3yrI8pS+wMgSJFxA==",
|
"integrity": "sha512-Lo3wdh1iFDzq6s5sW5Lqj9CI9612yUjVIW0s+DQ+lA6Nqz7C9ittrSkMYBcrLNat/IVp1HnUBG1ZmGJIG0dHbA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright": "1.58.0-alpha-2026-01-07"
|
"playwright": "1.58.0-alpha-2025-12-11"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
@@ -884,12 +884,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/playwright": {
|
"node_modules/playwright": {
|
||||||
"version": "1.58.0-alpha-2026-01-07",
|
"version": "1.58.0-alpha-2025-12-11",
|
||||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.0-alpha-2026-01-07.tgz",
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.0-alpha-2025-12-11.tgz",
|
||||||
"integrity": "sha512-ToIdvA1wM46BFcVURbbX9HCPNbzY2ugrJe2MUv2h6phkrD+hDD+vxNFkOOo+LLj5sJkiqr+Nwccay21tJj1NGw==",
|
"integrity": "sha512-wNAnyMpt4VZCy9wryVXphHfHgpoD2LRO/h4Bl8GDuvzIpvx6uU/TkRmC5/91feROZ1ng1tTjY6oTVdqIKt7uGQ==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright-core": "1.58.0-alpha-2026-01-07"
|
"playwright-core": "1.58.0-alpha-2025-12-11"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
@@ -902,9 +902,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/playwright-core": {
|
"node_modules/playwright-core": {
|
||||||
"version": "1.58.0-alpha-2026-01-07",
|
"version": "1.58.0-alpha-2025-12-11",
|
||||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.0-alpha-2026-01-07.tgz",
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.0-alpha-2025-12-11.tgz",
|
||||||
"integrity": "sha512-BV81BlzDg+WWhMut60z+1huVsSZF0O/6OXkwD16NXA6Mul49/yLHLJl4qHODAxAtdG/jxeXvJ87oFr3ERUCK0A==",
|
"integrity": "sha512-8c8vO4BMIGmEac13g4hxzWNCP/pGdRLhysUvcANU0uxH5UcN/DeFQ5RP+6NIK732u/KpLjCqI27TWdr1xgKb3A==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright-core": "cli.js"
|
"playwright-core": "cli.js"
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@playwright/mcp",
|
"name": "@playwright/mcp",
|
||||||
"version": "0.0.55",
|
"version": "0.0.52",
|
||||||
"description": "Playwright Tools for MCP",
|
"description": "Playwright Tools for MCP",
|
||||||
|
"mcpName": "com.microsoft/playwright-mcp",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/microsoft/playwright-mcp.git"
|
"url": "git+https://github.com/microsoft/playwright-mcp.git"
|
||||||
@@ -37,15 +38,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright": "1.58.0-alpha-2026-01-07",
|
"playwright": "1.58.0-alpha-2025-12-11",
|
||||||
"playwright-core": "1.58.0-alpha-2026-01-07"
|
"playwright-core": "1.58.0-alpha-2025-12-11"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"mcp-server-playwright": "cli.js"
|
"mcp-server-playwright": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.24.0",
|
"@modelcontextprotocol/sdk": "^1.24.0",
|
||||||
"@playwright/test": "1.58.0-alpha-2026-01-07",
|
"@playwright/test": "1.58.0-alpha-2025-12-11",
|
||||||
"@types/node": "^24.3.0"
|
"@types/node": "^24.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# Where is the source?
|
# Where is the source?
|
||||||
|
|
||||||
Playwright MCP source code is located in the [Playwright monorepo](https://github.com/microsoft/playwright/blob/main/packages/playwright/src/mcp). Please refer to the contributor's guide in [CONTRIBUTING.md](../CONTRIBUTING.md) for more details.
|
Playwright MCP source code is located in the Playwright monorepo. Please refer to the contributor's guide in [CONTRIBUTING.md](../CONTRIBUTING.md) for more details.
|
||||||
|
|||||||
@@ -44,6 +44,38 @@ test('test snapshot tool list', async ({ client }) => {
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test tool list proxy mode', async ({ startClient }) => {
|
||||||
|
const { client } = await startClient({
|
||||||
|
args: ['--connect-tool'],
|
||||||
|
});
|
||||||
|
const { tools } = await client.listTools();
|
||||||
|
expect(new Set(tools.map(t => t.name))).toEqual(new Set([
|
||||||
|
'browser_click',
|
||||||
|
'browser_connect', // the extra tool
|
||||||
|
'browser_console_messages',
|
||||||
|
'browser_drag',
|
||||||
|
'browser_evaluate',
|
||||||
|
'browser_file_upload',
|
||||||
|
'browser_fill_form',
|
||||||
|
'browser_handle_dialog',
|
||||||
|
'browser_hover',
|
||||||
|
'browser_select_option',
|
||||||
|
'browser_type',
|
||||||
|
'browser_close',
|
||||||
|
'browser_install',
|
||||||
|
'browser_navigate_back',
|
||||||
|
'browser_navigate',
|
||||||
|
'browser_network_requests',
|
||||||
|
'browser_press_key',
|
||||||
|
'browser_resize',
|
||||||
|
'browser_run_code',
|
||||||
|
'browser_snapshot',
|
||||||
|
'browser_tabs',
|
||||||
|
'browser_take_screenshot',
|
||||||
|
'browser_wait_for',
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
|
||||||
test('test capabilities (pdf)', async ({ startClient }) => {
|
test('test capabilities (pdf)', async ({ startClient }) => {
|
||||||
const { client } = await startClient({
|
const { client } = await startClient({
|
||||||
args: ['--caps=pdf'],
|
args: ['--caps=pdf'],
|
||||||
|
|||||||
Reference in New Issue
Block a user