playwright 1.58.0-alpha-2025-12-30 → 1.58.0-alpha-2026-01-01
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.
|
@@ -187,6 +187,7 @@ function configFromCLIOptions(cliOptions) {
|
|
|
187
187
|
allowedOrigins: cliOptions.allowedOrigins,
|
|
188
188
|
blockedOrigins: cliOptions.blockedOrigins
|
|
189
189
|
},
|
|
190
|
+
allowUnrestrictedFileAccess: cliOptions.allowUnrestrictedFileAccess,
|
|
190
191
|
saveSession: cliOptions.saveSession,
|
|
191
192
|
saveTrace: cliOptions.saveTrace,
|
|
192
193
|
saveVideo: cliOptions.saveVideo,
|
|
@@ -207,6 +208,7 @@ function configFromEnv() {
|
|
|
207
208
|
const options = {};
|
|
208
209
|
options.allowedHosts = commaSeparatedList(process.env.PLAYWRIGHT_MCP_ALLOWED_HOSTNAMES);
|
|
209
210
|
options.allowedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_ALLOWED_ORIGINS);
|
|
211
|
+
options.allowUnrestrictedFileAccess = envToBoolean(process.env.PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS);
|
|
210
212
|
options.blockedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_BLOCKED_ORIGINS);
|
|
211
213
|
options.blockServiceWorkers = envToBoolean(process.env.PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS);
|
|
212
214
|
options.browser = envToString(process.env.PLAYWRIGHT_MCP_BROWSER);
|
|
@@ -36,6 +36,8 @@ var import_fs = __toESM(require("fs"));
|
|
|
36
36
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
37
37
|
var import_utils = require("playwright-core/lib/utils");
|
|
38
38
|
var import_playwright_core = require("playwright-core");
|
|
39
|
+
var import_url = require("url");
|
|
40
|
+
var import_os = __toESM(require("os"));
|
|
39
41
|
var import_log = require("../log");
|
|
40
42
|
var import_tab = require("./tab");
|
|
41
43
|
var import_config = require("./config");
|
|
@@ -197,6 +199,10 @@ class Context {
|
|
|
197
199
|
import_playwright_core.selectors.setTestIdAttribute(this.config.testIdAttribute);
|
|
198
200
|
const result = await this._browserContextFactory.createContext(this._clientInfo, this._abortController.signal, this._runningToolName);
|
|
199
201
|
const { browserContext } = result;
|
|
202
|
+
if (!this.config.allowUnrestrictedFileAccess) {
|
|
203
|
+
browserContext._setAllowedProtocols(["http:", "https:", "about:", "data:"]);
|
|
204
|
+
browserContext._setAllowedDirectories(allRootPaths(this._clientInfo));
|
|
205
|
+
}
|
|
200
206
|
await this._setupRequestInterception(browserContext);
|
|
201
207
|
if (this.sessionLog)
|
|
202
208
|
await InputRecorder.create(this, browserContext);
|
|
@@ -222,6 +228,25 @@ class Context {
|
|
|
222
228
|
};
|
|
223
229
|
}
|
|
224
230
|
}
|
|
231
|
+
function allRootPaths(clientInfo) {
|
|
232
|
+
const paths = [];
|
|
233
|
+
for (const root of clientInfo.roots) {
|
|
234
|
+
const url = new URL(root.uri);
|
|
235
|
+
let rootPath;
|
|
236
|
+
try {
|
|
237
|
+
rootPath = (0, import_url.fileURLToPath)(url);
|
|
238
|
+
} catch (e) {
|
|
239
|
+
if (e.code === "ERR_INVALID_FILE_URL_PATH" && import_os.default.platform() === "win32")
|
|
240
|
+
rootPath = decodeURIComponent(url.pathname);
|
|
241
|
+
}
|
|
242
|
+
if (!rootPath)
|
|
243
|
+
continue;
|
|
244
|
+
paths.push(rootPath);
|
|
245
|
+
}
|
|
246
|
+
if (paths.length === 0)
|
|
247
|
+
paths.push(process.cwd());
|
|
248
|
+
return paths;
|
|
249
|
+
}
|
|
225
250
|
function originOrHostGlob(originOrHost) {
|
|
226
251
|
try {
|
|
227
252
|
const url = new URL(originOrHost);
|
package/lib/mcp/program.js
CHANGED
|
@@ -41,7 +41,7 @@ var import_browserContextFactory = require("./browser/browserContextFactory");
|
|
|
41
41
|
var import_browserServerBackend = require("./browser/browserServerBackend");
|
|
42
42
|
var import_extensionContextFactory = require("./extension/extensionContextFactory");
|
|
43
43
|
function decorateCommand(command, version) {
|
|
44
|
-
command.option("--allowed-hosts <hosts...>", "comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check.", import_config.commaSeparatedList).option("--allowed-origins <origins>", "semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all.\nImportant: *does not* serve as a security boundary and *does not* affect redirects. ", import_config.semicolonSeparatedList).option("--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.\nImportant: *does not* serve as a security boundary and *does not* affect redirects.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf.", import_config.commaSeparatedList).option("--cdp-endpoint <endpoint>", "CDP endpoint to connect to.").option("--cdp-header <headers...>", "CDP headers to send with the connect request, multiple can be specified.", import_config.headerParser).option("--config <path>", "path to the configuration file.").option("--console-level <level>", 'level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels.', import_config.enumParser.bind(null, "--console-level", ["error", "warning", "info", "debug"])).option("--device <device>", 'device to emulate, for example: "iPhone 15"').option("--executable-path <path>", "path to the browser executable.").option("--extension", 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').option("--grant-permissions <permissions...>", 'List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".', import_config.commaSeparatedList).option("--headless", "run browser in headless mode, headed by default").option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.").option("--ignore-https-errors", "ignore https errors").option("--init-page <path...>", "path to TypeScript file to evaluate on Playwright page object").option("--init-script <path...>", "path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times.").option("--isolated", "keep the browser profile in memory, do not save it to disk.").option("--image-responses <mode>", 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".', import_config.enumParser.bind(null, "--image-responses", ["allow", "omit"])).option("--no-sandbox", "disable the sandbox for all process types that are normally sandboxed.").option("--output-dir <path>", "path to the directory for output files.").option("--port <port>", "port to listen on for SSE transport.").option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--save-session", "Whether to save the Playwright MCP session into the output directory.").option("--save-trace", "Whether to save the Playwright Trace of the session into the output directory.").option("--save-video <size>", 'Whether to save the video of the session into the output directory. For example "--save-video=800x600"', import_config.resolutionParser.bind(null, "--save-video")).option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--shared-browser-context", "reuse the same browser context between all connected HTTP clients.").option("--snapshot-mode <mode>", 'when taking snapshots for responses, specifies the mode to use. Can be "incremental", "full", or "none". Default is incremental.').option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--test-id-attribute <attribute>", 'specify the attribute to use for test ids, defaults to "data-testid"').option("--timeout-action <timeout>", "specify action timeout in milliseconds, defaults to 5000ms", import_config.numberParser).option("--timeout-navigation <timeout>", "specify navigation timeout in milliseconds, defaults to 60000ms", import_config.numberParser).option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <path>", "path to the user data directory. If not specified, a temporary directory will be created.").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280x720"', import_config.resolutionParser.bind(null, "--viewport-size")).addOption(new import_utilsBundle.ProgramOption("--vision", "Legacy option, use --caps=vision instead").hideHelp()).action(async (options) => {
|
|
44
|
+
command.option("--allowed-hosts <hosts...>", "comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check.", import_config.commaSeparatedList).option("--allowed-origins <origins>", "semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all.\nImportant: *does not* serve as a security boundary and *does not* affect redirects. ", import_config.semicolonSeparatedList).option("--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.").option("--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.\nImportant: *does not* serve as a security boundary and *does not* affect redirects.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf.", import_config.commaSeparatedList).option("--cdp-endpoint <endpoint>", "CDP endpoint to connect to.").option("--cdp-header <headers...>", "CDP headers to send with the connect request, multiple can be specified.", import_config.headerParser).option("--config <path>", "path to the configuration file.").option("--console-level <level>", 'level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels.', import_config.enumParser.bind(null, "--console-level", ["error", "warning", "info", "debug"])).option("--device <device>", 'device to emulate, for example: "iPhone 15"').option("--executable-path <path>", "path to the browser executable.").option("--extension", 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').option("--grant-permissions <permissions...>", 'List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".', import_config.commaSeparatedList).option("--headless", "run browser in headless mode, headed by default").option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.").option("--ignore-https-errors", "ignore https errors").option("--init-page <path...>", "path to TypeScript file to evaluate on Playwright page object").option("--init-script <path...>", "path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times.").option("--isolated", "keep the browser profile in memory, do not save it to disk.").option("--image-responses <mode>", 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".', import_config.enumParser.bind(null, "--image-responses", ["allow", "omit"])).option("--no-sandbox", "disable the sandbox for all process types that are normally sandboxed.").option("--output-dir <path>", "path to the directory for output files.").option("--port <port>", "port to listen on for SSE transport.").option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--save-session", "Whether to save the Playwright MCP session into the output directory.").option("--save-trace", "Whether to save the Playwright Trace of the session into the output directory.").option("--save-video <size>", 'Whether to save the video of the session into the output directory. For example "--save-video=800x600"', import_config.resolutionParser.bind(null, "--save-video")).option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--shared-browser-context", "reuse the same browser context between all connected HTTP clients.").option("--snapshot-mode <mode>", 'when taking snapshots for responses, specifies the mode to use. Can be "incremental", "full", or "none". Default is incremental.').option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--test-id-attribute <attribute>", 'specify the attribute to use for test ids, defaults to "data-testid"').option("--timeout-action <timeout>", "specify action timeout in milliseconds, defaults to 5000ms", import_config.numberParser).option("--timeout-navigation <timeout>", "specify navigation timeout in milliseconds, defaults to 60000ms", import_config.numberParser).option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <path>", "path to the user data directory. If not specified, a temporary directory will be created.").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280x720"', import_config.resolutionParser.bind(null, "--viewport-size")).addOption(new import_utilsBundle.ProgramOption("--vision", "Legacy option, use --caps=vision instead").hideHelp()).action(async (options) => {
|
|
45
45
|
(0, import_watchdog.setupExitWatchdog)();
|
|
46
46
|
if (options.vision) {
|
|
47
47
|
console.error("The --vision option is deprecated, use --caps=vision instead");
|
package/lib/mcp/sdk/server.js
CHANGED
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var server_exports = {};
|
|
30
30
|
__export(server_exports, {
|
|
31
|
+
allRootPaths: () => allRootPaths,
|
|
31
32
|
connect: () => connect,
|
|
32
33
|
createServer: () => createServer,
|
|
33
34
|
firstRootPath: () => firstRootPath,
|
|
@@ -175,6 +176,20 @@ function firstRootPath(clientInfo) {
|
|
|
175
176
|
return void 0;
|
|
176
177
|
}
|
|
177
178
|
}
|
|
179
|
+
function allRootPaths(clientInfo) {
|
|
180
|
+
const paths = [];
|
|
181
|
+
for (const root of clientInfo.roots) {
|
|
182
|
+
try {
|
|
183
|
+
const url = new URL(root.uri);
|
|
184
|
+
const path = (0, import_url.fileURLToPath)(url);
|
|
185
|
+
if (path)
|
|
186
|
+
paths.push(path);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
serverDebug(error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return paths;
|
|
192
|
+
}
|
|
178
193
|
function mergeTextParts(result) {
|
|
179
194
|
const content = [];
|
|
180
195
|
const testParts = [];
|
|
@@ -198,6 +213,7 @@ function mergeTextParts(result) {
|
|
|
198
213
|
}
|
|
199
214
|
// Annotate the CommonJS export names for ESM import in node:
|
|
200
215
|
0 && (module.exports = {
|
|
216
|
+
allRootPaths,
|
|
201
217
|
connect,
|
|
202
218
|
createServer,
|
|
203
219
|
firstRootPath,
|
|
@@ -62,8 +62,11 @@ const planSchema = import_mcpBundle.z.object({
|
|
|
62
62
|
tests: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
|
63
63
|
name: import_mcpBundle.z.string().describe("The name of the test"),
|
|
64
64
|
file: import_mcpBundle.z.string().describe('The file the test should be saved to, for example: "tests/<suite-name>/<test-name>.spec.ts".'),
|
|
65
|
-
steps: import_mcpBundle.z.array(import_mcpBundle.z.
|
|
66
|
-
|
|
65
|
+
steps: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
|
66
|
+
perform: import_mcpBundle.z.string().describe(`Action to perform. For example: 'Click on the "Submit" button'.`),
|
|
67
|
+
expect: import_mcpBundle.z.string().optional().describe(`Expected result of the action where appropriate. For example: 'The page should show the "Thank you for your submission" message'`)
|
|
68
|
+
})),
|
|
69
|
+
postConditions: import_mcpBundle.z.array(import_mcpBundle.z.string().describe(`Post conditions to verify that are not covered by the steps. Can be empty`))
|
|
67
70
|
}))
|
|
68
71
|
}))
|
|
69
72
|
});
|
|
@@ -118,12 +121,17 @@ const saveTestPlan = (0, import_testTool.defineTestTool)({
|
|
|
118
121
|
lines.push(`**File:** \`${test.file}\``);
|
|
119
122
|
lines.push(``);
|
|
120
123
|
lines.push(`**Steps:**`);
|
|
121
|
-
for (let k = 0; k < test.steps.length; k++)
|
|
122
|
-
lines.push(` ${k + 1}. ${test.steps[k]}`);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
for (let k = 0; k < test.steps.length; k++) {
|
|
125
|
+
lines.push(` ${k + 1}. ${test.steps[k].perform}`);
|
|
126
|
+
if (test.steps[k].expect?.trim())
|
|
127
|
+
lines.push(` ${" ".repeat(String(k + 1).length)} Expect: ${test.steps[k].expect}`);
|
|
128
|
+
}
|
|
129
|
+
if (test.postConditions.length) {
|
|
130
|
+
lines.push(``);
|
|
131
|
+
lines.push(`**Post Conditions:**`);
|
|
132
|
+
for (const postCondition of test.postConditions)
|
|
133
|
+
lines.push(` - ${postCondition}`);
|
|
134
|
+
}
|
|
127
135
|
}
|
|
128
136
|
}
|
|
129
137
|
lines.push(``);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.58.0-alpha-
|
|
3
|
+
"version": "1.58.0-alpha-2026-01-01",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"license": "Apache-2.0",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"playwright-core": "1.58.0-alpha-
|
|
67
|
+
"playwright-core": "1.58.0-alpha-2026-01-01"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|