rae-playwright-mcp 0.0.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 +202 -0
- package/README.md +1131 -0
- package/cli.js +24 -0
- package/config.d.ts +197 -0
- package/index.d.ts +23 -0
- package/index.js +19 -0
- package/package.json +52 -0
package/cli.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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 { decorateCommand } = require('playwright/lib/mcp/program');
|
|
20
|
+
|
|
21
|
+
const packageJSON = require('./package.json');
|
|
22
|
+
const p = program.version('Version ' + packageJSON.version).name('Playwright MCP');
|
|
23
|
+
decorateCommand(p, packageJSON.version)
|
|
24
|
+
void program.parseAsync(process.argv);
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
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 'playwright';
|
|
18
|
+
|
|
19
|
+
export type ToolCapability = 'core' | 'core-tabs' | 'core-install' | 'vision' | 'pdf' | 'testing' | 'tracing';
|
|
20
|
+
|
|
21
|
+
export type Config = {
|
|
22
|
+
/**
|
|
23
|
+
* The browser to use.
|
|
24
|
+
*/
|
|
25
|
+
browser?: {
|
|
26
|
+
/**
|
|
27
|
+
* The type of browser to use.
|
|
28
|
+
*/
|
|
29
|
+
browserName?: 'chromium' | 'firefox' | 'webkit';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Keep the browser profile in memory, do not save it to disk.
|
|
33
|
+
*/
|
|
34
|
+
isolated?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Path to a user data directory for browser profile persistence.
|
|
38
|
+
* Temporary directory is created by default.
|
|
39
|
+
*/
|
|
40
|
+
userDataDir?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Launch options passed to
|
|
44
|
+
* @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
|
|
45
|
+
*
|
|
46
|
+
* This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
|
|
47
|
+
*/
|
|
48
|
+
launchOptions?: playwright.LaunchOptions;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Context options for the browser context.
|
|
52
|
+
*
|
|
53
|
+
* This is useful for settings options like `viewport`.
|
|
54
|
+
*/
|
|
55
|
+
contextOptions?: playwright.BrowserContextOptions;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
|
|
59
|
+
*/
|
|
60
|
+
cdpEndpoint?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* CDP headers to send with the connect request.
|
|
64
|
+
*/
|
|
65
|
+
cdpHeaders?: Record<string, string>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Remote endpoint to connect to an existing Playwright server.
|
|
69
|
+
*/
|
|
70
|
+
remoteEndpoint?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Paths to TypeScript files to add as initialization scripts for Playwright page.
|
|
74
|
+
*/
|
|
75
|
+
initPage?: string[];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Paths to JavaScript files to add as initialization scripts.
|
|
79
|
+
* The scripts will be evaluated in every page before any of the page's scripts.
|
|
80
|
+
*/
|
|
81
|
+
initScript?: string[];
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
server?: {
|
|
85
|
+
/**
|
|
86
|
+
* The port to listen on for SSE or MCP transport.
|
|
87
|
+
*/
|
|
88
|
+
port?: number;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
|
|
92
|
+
*/
|
|
93
|
+
host?: string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The hosts this server is allowed to serve from. Defaults to the host server is bound to.
|
|
97
|
+
* This is not for CORS, but rather for the DNS rebinding protection.
|
|
98
|
+
*/
|
|
99
|
+
allowedHosts?: string[];
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* List of enabled tool capabilities. Possible values:
|
|
104
|
+
* - 'core': Core browser automation features.
|
|
105
|
+
* - 'pdf': PDF generation and manipulation.
|
|
106
|
+
* - 'vision': Coordinate-based interactions.
|
|
107
|
+
*/
|
|
108
|
+
capabilities?: ToolCapability[];
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Whether to save the Playwright session into the output directory.
|
|
112
|
+
*/
|
|
113
|
+
saveSession?: boolean;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Whether to save the Playwright trace of the session into the output directory.
|
|
117
|
+
*/
|
|
118
|
+
saveTrace?: boolean;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* If specified, saves the Playwright video of the session into the output directory.
|
|
122
|
+
*/
|
|
123
|
+
saveVideo?: {
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Reuse the same browser context between all connected HTTP clients.
|
|
130
|
+
*/
|
|
131
|
+
sharedBrowserContext?: boolean;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Secrets are used to prevent LLM from getting sensitive data while
|
|
135
|
+
* automating scenarios such as authentication.
|
|
136
|
+
* Prefer the browser.contextOptions.storageState over secrets file as a more secure alternative.
|
|
137
|
+
*/
|
|
138
|
+
secrets?: Record<string, string>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The directory to save output files.
|
|
142
|
+
*/
|
|
143
|
+
outputDir?: string;
|
|
144
|
+
|
|
145
|
+
console?: {
|
|
146
|
+
/**
|
|
147
|
+
* The level of console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
|
|
148
|
+
*/
|
|
149
|
+
level?: 'error' | 'warning' | 'info' | 'debug';
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
network?: {
|
|
153
|
+
/**
|
|
154
|
+
* List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
155
|
+
*/
|
|
156
|
+
allowedOrigins?: string[];
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
|
|
160
|
+
*/
|
|
161
|
+
blockedOrigins?: string[];
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Specify the attribute to use for test ids, defaults to "data-testid".
|
|
166
|
+
*/
|
|
167
|
+
testIdAttribute?: string;
|
|
168
|
+
|
|
169
|
+
timeouts?: {
|
|
170
|
+
/*
|
|
171
|
+
* Configures default action timeout: https://playwright.dev/docs/api/class-page#page-set-default-timeout. Defaults to 5000ms.
|
|
172
|
+
*/
|
|
173
|
+
action?: number;
|
|
174
|
+
|
|
175
|
+
/*
|
|
176
|
+
* Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms.
|
|
177
|
+
*/
|
|
178
|
+
navigation?: number;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 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.
|
|
183
|
+
*/
|
|
184
|
+
imageResponses?: 'allow' | 'omit';
|
|
185
|
+
|
|
186
|
+
snapshot?: {
|
|
187
|
+
/**
|
|
188
|
+
* When taking snapshots for responses, specifies the mode to use.
|
|
189
|
+
*/
|
|
190
|
+
mode?: 'incremental' | 'full' | 'none';
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* External UUID to use for HAR directory. If not provided, a UUID will be generated.
|
|
195
|
+
*/
|
|
196
|
+
runId?: string;
|
|
197
|
+
};
|
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 { createConnection } = require('playwright/lib/mcp/index');
|
|
19
|
+
module.exports = { createConnection };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rae-playwright-mcp",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Playwright Tools for MCP",
|
|
5
|
+
"mcpName": "com.microsoft/playwright-mcp",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/kalil0321/rae-playwright-mcp.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/kalil0321/rae-playwright-mcp",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18"
|
|
13
|
+
},
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Microsoft Corporation"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"lint": "npm run update-readme",
|
|
20
|
+
"update-readme": "node update-readme.js",
|
|
21
|
+
"docker-build": "docker build --no-cache -t playwright-mcp-dev:latest .",
|
|
22
|
+
"docker-rm": "docker rm playwright-mcp-dev",
|
|
23
|
+
"docker-run": "docker run -it -p 8080:8080 --name playwright-mcp-dev playwright-mcp-dev:latest",
|
|
24
|
+
"test": "playwright test",
|
|
25
|
+
"ctest": "playwright test --project=chrome",
|
|
26
|
+
"ftest": "playwright test --project=firefox",
|
|
27
|
+
"wtest": "playwright test --project=webkit",
|
|
28
|
+
"dtest": "MCP_IN_DOCKER=1 playwright test --project=chromium-docker",
|
|
29
|
+
"npm-publish": "npm run test && npm publish",
|
|
30
|
+
"copy-config": "cp ../playwright/packages/playwright/src/mcp/config.d.ts . && perl -pi -e \"s|import type \\* as playwright from 'playwright-core';|import type * as playwright from 'playwright';|\" ./config.d.ts",
|
|
31
|
+
"roll": "npm run copy-config && npm run lint"
|
|
32
|
+
},
|
|
33
|
+
"exports": {
|
|
34
|
+
"./package.json": "./package.json",
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./index.d.ts",
|
|
37
|
+
"default": "./index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"playwright": "1.58.0-alpha-2025-12-29",
|
|
42
|
+
"playwright-core": "1.58.0-alpha-2025-12-29"
|
|
43
|
+
},
|
|
44
|
+
"bin": {
|
|
45
|
+
"mcp-server-playwright": "cli.js"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@modelcontextprotocol/sdk": "^1.24.0",
|
|
49
|
+
"@playwright/test": "1.58.0-alpha-2025-12-29",
|
|
50
|
+
"@types/node": "^24.3.0"
|
|
51
|
+
}
|
|
52
|
+
}
|