@quantum-ai/playwright-mcp 0.1.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.
- package/LICENSE +201 -0
- package/README.md +1559 -0
- package/cli.js +32 -0
- package/config.d.ts +239 -0
- package/index.d.ts +23 -0
- package/index.js +19 -0
- package/package.json +51 -0
package/cli.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { program } = require('playwright-core/lib/utilsBundle');
|
|
19
|
+
const { tools, libCli } = require('playwright-core/lib/coreBundle');
|
|
20
|
+
|
|
21
|
+
if (process.argv.includes('install-browser')) {
|
|
22
|
+
const argv = process.argv.map(arg => arg === 'install-browser' ? 'install' : arg);
|
|
23
|
+
libCli.decorateProgram(program);
|
|
24
|
+
void program.parseAsync(argv);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const packageJSON = require('./package.json');
|
|
29
|
+
const p = program.version('Version ' + packageJSON.version).name('Playwright MCP');
|
|
30
|
+
tools.decorateMCPCommand(p, packageJSON.version);
|
|
31
|
+
|
|
32
|
+
void program.parseAsync(process.argv);
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type * as playwright from '../../..';
|
|
18
|
+
|
|
19
|
+
export type ToolCapability =
|
|
20
|
+
'config' |
|
|
21
|
+
'core' |
|
|
22
|
+
'core-navigation' |
|
|
23
|
+
'core-tabs' |
|
|
24
|
+
'core-input' |
|
|
25
|
+
'core-install' |
|
|
26
|
+
'network' |
|
|
27
|
+
'pdf' |
|
|
28
|
+
'storage' |
|
|
29
|
+
'testing' |
|
|
30
|
+
'vision' |
|
|
31
|
+
'devtools';
|
|
32
|
+
|
|
33
|
+
export type Config = {
|
|
34
|
+
/**
|
|
35
|
+
* The browser to use.
|
|
36
|
+
*/
|
|
37
|
+
browser?: {
|
|
38
|
+
/**
|
|
39
|
+
* The type of browser to use.
|
|
40
|
+
*/
|
|
41
|
+
browserName?: 'chromium' | 'firefox' | 'webkit';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Keep the browser profile in memory, do not save it to disk.
|
|
45
|
+
*/
|
|
46
|
+
isolated?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Path to a user data directory for browser profile persistence.
|
|
50
|
+
* Temporary directory is created by default.
|
|
51
|
+
*/
|
|
52
|
+
userDataDir?: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Launch options passed to
|
|
56
|
+
* @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
|
|
57
|
+
*
|
|
58
|
+
* This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
|
|
59
|
+
*/
|
|
60
|
+
launchOptions?: playwright.LaunchOptions;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Context options for the browser context.
|
|
64
|
+
*
|
|
65
|
+
* This is useful for settings options like `viewport`.
|
|
66
|
+
*/
|
|
67
|
+
contextOptions?: playwright.BrowserContextOptions;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
|
|
71
|
+
*/
|
|
72
|
+
cdpEndpoint?: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* CDP headers to send with the connect request.
|
|
76
|
+
*/
|
|
77
|
+
cdpHeaders?: Record<string, string>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Timeout in milliseconds for connecting to CDP endpoint. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
|
|
81
|
+
*/
|
|
82
|
+
cdpTimeout?: number;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Remote endpoint to connect to an existing Playwright server. May be a
|
|
86
|
+
* WebSocket URL string, or a [ConnectOptions] object that mirrors the
|
|
87
|
+
* `connectOptions` shape used by the test runner. When passed as an object,
|
|
88
|
+
* `exposeNetwork`, `headers`, `slowMo`, and `timeout` are forwarded to the
|
|
89
|
+
* underlying connect call.
|
|
90
|
+
*/
|
|
91
|
+
remoteEndpoint?: string | playwright.ConnectOptions & { endpoint: string };
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Paths to TypeScript files to add as initialization scripts for Playwright page.
|
|
95
|
+
*/
|
|
96
|
+
initPage?: string[];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Paths to JavaScript files to add as initialization scripts.
|
|
100
|
+
* The scripts will be evaluated in every page before any of the page's scripts.
|
|
101
|
+
*/
|
|
102
|
+
initScript?: string[];
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Connect to a running browser instance (Edge/Chrome only). If specified, `browser`
|
|
107
|
+
* config is ignored.
|
|
108
|
+
* Requires the "Playwright Extension" to be installed.
|
|
109
|
+
*/
|
|
110
|
+
extension?: boolean;
|
|
111
|
+
|
|
112
|
+
server?: {
|
|
113
|
+
/**
|
|
114
|
+
* The port to listen on for SSE or MCP transport.
|
|
115
|
+
*/
|
|
116
|
+
port?: number;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
|
|
120
|
+
*/
|
|
121
|
+
host?: string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The hosts this server is allowed to serve from. Defaults to the host server is bound to.
|
|
125
|
+
* This is not for CORS, but rather for the DNS rebinding protection.
|
|
126
|
+
*/
|
|
127
|
+
allowedHosts?: string[];
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* List of enabled tool capabilities. Possible values:
|
|
132
|
+
* - 'core': Core browser automation features.
|
|
133
|
+
* - 'pdf': PDF generation and manipulation.
|
|
134
|
+
* - 'vision': Coordinate-based interactions.
|
|
135
|
+
* - 'devtools': Developer tools features.
|
|
136
|
+
*/
|
|
137
|
+
capabilities?: ToolCapability[];
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Whether to save the Playwright session into the output directory.
|
|
141
|
+
*/
|
|
142
|
+
saveSession?: boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Reuse the same browser context between all connected HTTP clients.
|
|
146
|
+
*/
|
|
147
|
+
sharedBrowserContext?: boolean;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Secrets are used to replace matching plain text in the tool responses to prevent the LLM
|
|
151
|
+
* from accidentally getting sensitive data. It is a convenience and not a security feature,
|
|
152
|
+
* make sure to always examine information coming in and from the tool on the client.
|
|
153
|
+
*/
|
|
154
|
+
secrets?: Record<string, string>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The directory to save output files.
|
|
158
|
+
*/
|
|
159
|
+
outputDir?: string;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Threshold for evicting old output files, in bytes.
|
|
163
|
+
*/
|
|
164
|
+
outputMaxSize?: number;
|
|
165
|
+
|
|
166
|
+
console?: {
|
|
167
|
+
/**
|
|
168
|
+
* The level of console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
|
|
169
|
+
*/
|
|
170
|
+
level?: 'error' | 'warning' | 'info' | 'debug';
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
network?: {
|
|
174
|
+
/**
|
|
175
|
+
* List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
176
|
+
*
|
|
177
|
+
* Supported formats:
|
|
178
|
+
* - Full origin: `https://example.com:8080` - matches only that origin
|
|
179
|
+
* - Wildcard port: `http://localhost:*` - matches any port on localhost with http protocol
|
|
180
|
+
*/
|
|
181
|
+
allowedOrigins?: string[];
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
185
|
+
*
|
|
186
|
+
* Supported formats:
|
|
187
|
+
* - Full origin: `https://example.com:8080` - matches only that origin
|
|
188
|
+
* - Wildcard port: `http://localhost:*` - matches any port on localhost with http protocol
|
|
189
|
+
*/
|
|
190
|
+
blockedOrigins?: string[];
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Specify the attribute to use for test ids, defaults to "data-testid".
|
|
195
|
+
*/
|
|
196
|
+
testIdAttribute?: string;
|
|
197
|
+
|
|
198
|
+
timeouts?: {
|
|
199
|
+
/*
|
|
200
|
+
* Configures default action timeout: https://playwright.dev/docs/api/class-page#page-set-default-timeout. Defaults to 5000ms.
|
|
201
|
+
*/
|
|
202
|
+
action?: number;
|
|
203
|
+
|
|
204
|
+
/*
|
|
205
|
+
* Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms.
|
|
206
|
+
*/
|
|
207
|
+
navigation?: number;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Configures default expect timeout: https://playwright.dev/docs/test-timeouts#expect-timeout. Defaults to 5000ms.
|
|
211
|
+
*/
|
|
212
|
+
expect?: number;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Whether to send image responses to the client. Can be "allow", "omit", or "auto". Defaults to "auto", which sends images if the client can display them.
|
|
217
|
+
*/
|
|
218
|
+
imageResponses?: 'allow' | 'omit';
|
|
219
|
+
|
|
220
|
+
snapshot?: {
|
|
221
|
+
/**
|
|
222
|
+
* When taking snapshots for responses, specifies the mode to use.
|
|
223
|
+
*/
|
|
224
|
+
mode?: 'full' | 'none';
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* allowUnrestrictedFileAccess acts as a guardrail to prevent the LLM from accidentally
|
|
229
|
+
* wandering outside its intended workspace. It is a convenience defense to catch unintended
|
|
230
|
+
* file access, not a secure boundary; a deliberate attempt to reach other directories can be
|
|
231
|
+
* easily worked around, so always rely on client-level permissions for true security.
|
|
232
|
+
*/
|
|
233
|
+
allowUnrestrictedFileAccess?: boolean;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Specify the language to use for code generation.
|
|
237
|
+
*/
|
|
238
|
+
codegen?: 'typescript' | 'none';
|
|
239
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
19
|
+
import type { Config } from './config';
|
|
20
|
+
import type { BrowserContext } from 'playwright';
|
|
21
|
+
|
|
22
|
+
export declare function createConnection(config?: Config, contextGetter?: () => Promise<BrowserContext>): Promise<Server>;
|
|
23
|
+
export {};
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { tools } = require('playwright-core/lib/coreBundle');
|
|
19
|
+
module.exports = { createConnection: tools.createConnection };
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quantum-ai/playwright-mcp",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Playwright Tools for MCP",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/microsoft/playwright-mcp.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://playwright.dev",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Microsoft Corporation"
|
|
15
|
+
},
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"mcpName": "io.github.microsoft/playwright-mcp",
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": "./package.json",
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./index.d.ts",
|
|
22
|
+
"default": "./index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"playwright": "1.61.0-alpha-1781023400000",
|
|
27
|
+
"playwright-core": "1.61.0-alpha-1781023400000"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
31
|
+
"@playwright/test": "1.61.0-alpha-1781023400000",
|
|
32
|
+
"@types/node": "^24.3.0"
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"playwright-mcp": "cli.js"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"lint": "node update-readme.js",
|
|
39
|
+
"test": "playwright test",
|
|
40
|
+
"ctest": "playwright test --project=chrome",
|
|
41
|
+
"ftest": "playwright test --project=firefox",
|
|
42
|
+
"wtest": "playwright test --project=webkit",
|
|
43
|
+
"dtest": "MCP_IN_DOCKER=1 playwright test --project=chromium-docker",
|
|
44
|
+
"build": "echo OK",
|
|
45
|
+
"npm-publish": "npm run lint && npm run test && npm publish",
|
|
46
|
+
"docker-build": "docker build --no-cache -t playwright-mcp-dev:latest .",
|
|
47
|
+
"docker-rm": "docker rm playwright-mcp-dev",
|
|
48
|
+
"docker-run": "docker run -it -p 8080:8080 --name playwright-mcp-dev playwright-mcp-dev:latest",
|
|
49
|
+
"roll": "node roll.js"
|
|
50
|
+
}
|
|
51
|
+
}
|