playwright 1.58.0-alpha-2025-12-03 → 1.58.0-alpha-2025-12-05
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/README.md +2 -2
- package/ThirdPartyNotices.txt +288 -2773
- package/lib/agents/agent.js +2 -2
- package/lib/agents/performTask.js +121 -8
- package/lib/index.js +6 -3
- package/lib/mcp/browser/browserContextFactory.js +2 -0
- package/lib/mcp/browser/browserServerBackend.js +2 -1
- package/lib/mcp/browser/config.js +21 -2
- package/lib/mcp/browser/response.js +129 -53
- package/lib/mcp/browser/tab.js +39 -8
- package/lib/mcp/browser/tools/common.js +5 -5
- package/lib/mcp/browser/tools/console.js +4 -4
- package/lib/mcp/browser/tools/dialogs.js +4 -4
- package/lib/mcp/browser/tools/evaluate.js +5 -5
- package/lib/mcp/browser/tools/files.js +3 -3
- package/lib/mcp/browser/tools/form.js +7 -7
- package/lib/mcp/browser/tools/install.js +2 -2
- package/lib/mcp/browser/tools/keyboard.js +6 -6
- package/lib/mcp/browser/tools/mouse.js +11 -11
- package/lib/mcp/browser/tools/navigate.js +4 -4
- package/lib/mcp/browser/tools/network.js +17 -11
- package/lib/mcp/browser/tools/pdf.js +3 -3
- package/lib/mcp/browser/tools/runCode.js +3 -3
- package/lib/mcp/browser/tools/screenshot.js +7 -7
- package/lib/mcp/browser/tools/snapshot.js +14 -14
- package/lib/mcp/browser/tools/tabs.js +4 -4
- package/lib/mcp/browser/tools/tool.js +8 -7
- package/lib/mcp/browser/tools/tracing.js +3 -3
- package/lib/mcp/browser/tools/verify.js +15 -15
- package/lib/mcp/browser/tools/wait.js +5 -5
- package/lib/mcp/program.js +1 -1
- package/lib/mcp/sdk/http.js +1 -1
- package/lib/mcp/sdk/proxyBackend.js +1 -1
- package/lib/mcp/sdk/server.js +1 -1
- package/lib/mcp/sdk/tool.js +2 -2
- package/lib/mcp/test/browserBackend.js +1 -1
- package/lib/mcp/test/generatorTools.js +9 -9
- package/lib/mcp/test/plannerTools.js +16 -16
- package/lib/mcp/test/testBackend.js +2 -2
- package/lib/mcp/test/testTools.js +9 -9
- package/package.json +2 -2
- package/types/test.d.ts +1 -3
- package/lib/mcp/sdk/bundle.js +0 -84
- package/lib/mcpBundleImpl.js +0 -96
|
@@ -21,7 +21,7 @@ __export(common_exports, {
|
|
|
21
21
|
default: () => common_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(common_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const close = (0, import_tool.defineTool)({
|
|
27
27
|
capability: "core",
|
|
@@ -29,7 +29,7 @@ const close = (0, import_tool.defineTool)({
|
|
|
29
29
|
name: "browser_close",
|
|
30
30
|
title: "Close browser",
|
|
31
31
|
description: "Close the page",
|
|
32
|
-
inputSchema:
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
33
33
|
type: "action"
|
|
34
34
|
},
|
|
35
35
|
handle: async (context, params, response) => {
|
|
@@ -44,9 +44,9 @@ const resize = (0, import_tool.defineTabTool)({
|
|
|
44
44
|
name: "browser_resize",
|
|
45
45
|
title: "Resize browser window",
|
|
46
46
|
description: "Resize the browser window",
|
|
47
|
-
inputSchema:
|
|
48
|
-
width:
|
|
49
|
-
height:
|
|
47
|
+
inputSchema: import_mcpBundle.z.object({
|
|
48
|
+
width: import_mcpBundle.z.number().describe("Width of the browser window"),
|
|
49
|
+
height: import_mcpBundle.z.number().describe("Height of the browser window")
|
|
50
50
|
}),
|
|
51
51
|
type: "action"
|
|
52
52
|
},
|
|
@@ -21,7 +21,7 @@ __export(console_exports, {
|
|
|
21
21
|
default: () => console_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(console_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const console = (0, import_tool.defineTabTool)({
|
|
27
27
|
capability: "core",
|
|
@@ -29,13 +29,13 @@ const console = (0, import_tool.defineTabTool)({
|
|
|
29
29
|
name: "browser_console_messages",
|
|
30
30
|
title: "Get console messages",
|
|
31
31
|
description: "Returns all console messages",
|
|
32
|
-
inputSchema:
|
|
33
|
-
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
level: import_mcpBundle.z.enum(["error", "warning", "info", "debug"]).default("info").describe('Level of the console messages to return. Each level includes the messages of more severe levels. Defaults to "info".')
|
|
34
34
|
}),
|
|
35
35
|
type: "readOnly"
|
|
36
36
|
},
|
|
37
37
|
handle: async (tab, params, response) => {
|
|
38
|
-
const messages = await tab.consoleMessages(params.
|
|
38
|
+
const messages = await tab.consoleMessages(params.level);
|
|
39
39
|
messages.map((message) => response.addResult(message.toString()));
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -22,7 +22,7 @@ __export(dialogs_exports, {
|
|
|
22
22
|
handleDialog: () => handleDialog
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(dialogs_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
const handleDialog = (0, import_tool.defineTabTool)({
|
|
28
28
|
capability: "core",
|
|
@@ -30,9 +30,9 @@ const handleDialog = (0, import_tool.defineTabTool)({
|
|
|
30
30
|
name: "browser_handle_dialog",
|
|
31
31
|
title: "Handle a dialog",
|
|
32
32
|
description: "Handle a dialog",
|
|
33
|
-
inputSchema:
|
|
34
|
-
accept:
|
|
35
|
-
promptText:
|
|
33
|
+
inputSchema: import_mcpBundle.z.object({
|
|
34
|
+
accept: import_mcpBundle.z.boolean().describe("Whether to accept the dialog."),
|
|
35
|
+
promptText: import_mcpBundle.z.string().optional().describe("The text of the prompt in case of a prompt dialog.")
|
|
36
36
|
}),
|
|
37
37
|
type: "action"
|
|
38
38
|
},
|
|
@@ -31,13 +31,13 @@ __export(evaluate_exports, {
|
|
|
31
31
|
default: () => evaluate_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(evaluate_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
35
35
|
var import_tool = require("./tool");
|
|
36
36
|
var javascript = __toESM(require("../codegen"));
|
|
37
|
-
const evaluateSchema =
|
|
38
|
-
function:
|
|
39
|
-
element:
|
|
40
|
-
ref:
|
|
37
|
+
const evaluateSchema = import_mcpBundle.z.object({
|
|
38
|
+
function: import_mcpBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
|
|
39
|
+
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to interact with the element"),
|
|
40
|
+
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot")
|
|
41
41
|
});
|
|
42
42
|
const evaluate = (0, import_tool.defineTabTool)({
|
|
43
43
|
capability: "core",
|
|
@@ -22,7 +22,7 @@ __export(files_exports, {
|
|
|
22
22
|
uploadFile: () => uploadFile
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(files_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
26
|
var import_tool = require("./tool");
|
|
27
27
|
const uploadFile = (0, import_tool.defineTabTool)({
|
|
28
28
|
capability: "core",
|
|
@@ -30,8 +30,8 @@ const uploadFile = (0, import_tool.defineTabTool)({
|
|
|
30
30
|
name: "browser_file_upload",
|
|
31
31
|
title: "Upload files",
|
|
32
32
|
description: "Upload one or multiple files",
|
|
33
|
-
inputSchema:
|
|
34
|
-
paths:
|
|
33
|
+
inputSchema: import_mcpBundle.z.object({
|
|
34
|
+
paths: import_mcpBundle.z.array(import_mcpBundle.z.string()).optional().describe("The absolute paths to the files to upload. Can be single file or multiple files. If omitted, file chooser is cancelled.")
|
|
35
35
|
}),
|
|
36
36
|
type: "action"
|
|
37
37
|
},
|
|
@@ -31,7 +31,7 @@ __export(form_exports, {
|
|
|
31
31
|
default: () => form_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(form_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
35
35
|
var import_tool = require("./tool");
|
|
36
36
|
var codegen = __toESM(require("../codegen"));
|
|
37
37
|
const fillForm = (0, import_tool.defineTabTool)({
|
|
@@ -40,12 +40,12 @@ const fillForm = (0, import_tool.defineTabTool)({
|
|
|
40
40
|
name: "browser_fill_form",
|
|
41
41
|
title: "Fill form",
|
|
42
42
|
description: "Fill multiple form fields",
|
|
43
|
-
inputSchema:
|
|
44
|
-
fields:
|
|
45
|
-
name:
|
|
46
|
-
type:
|
|
47
|
-
ref:
|
|
48
|
-
value:
|
|
43
|
+
inputSchema: import_mcpBundle.z.object({
|
|
44
|
+
fields: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
|
45
|
+
name: import_mcpBundle.z.string().describe("Human-readable field name"),
|
|
46
|
+
type: import_mcpBundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the field"),
|
|
47
|
+
ref: import_mcpBundle.z.string().describe("Exact target field reference from the page snapshot"),
|
|
48
|
+
value: import_mcpBundle.z.string().describe("Value to fill in the field. If the field is a checkbox, the value should be `true` or `false`. If the field is a combobox, the value should be the text of the option.")
|
|
49
49
|
})).describe("Fields to fill in")
|
|
50
50
|
}),
|
|
51
51
|
type: "input"
|
|
@@ -33,7 +33,7 @@ __export(install_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(install_exports);
|
|
34
34
|
var import_child_process = require("child_process");
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
|
-
var
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
37
|
var import_tool = require("./tool");
|
|
38
38
|
const install = (0, import_tool.defineTool)({
|
|
39
39
|
capability: "core-install",
|
|
@@ -41,7 +41,7 @@ const install = (0, import_tool.defineTool)({
|
|
|
41
41
|
name: "browser_install",
|
|
42
42
|
title: "Install the browser specified in the config",
|
|
43
43
|
description: "Install the browser specified in the config. Call this if you get an error about the browser not being installed.",
|
|
44
|
-
inputSchema:
|
|
44
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
45
45
|
type: "action"
|
|
46
46
|
},
|
|
47
47
|
handle: async (context, params, response) => {
|
|
@@ -21,7 +21,7 @@ __export(keyboard_exports, {
|
|
|
21
21
|
default: () => keyboard_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(keyboard_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
var import_snapshot = require("./snapshot");
|
|
27
27
|
const pressKey = (0, import_tool.defineTabTool)({
|
|
@@ -30,8 +30,8 @@ const pressKey = (0, import_tool.defineTabTool)({
|
|
|
30
30
|
name: "browser_press_key",
|
|
31
31
|
title: "Press a key",
|
|
32
32
|
description: "Press a key on the keyboard",
|
|
33
|
-
inputSchema:
|
|
34
|
-
key:
|
|
33
|
+
inputSchema: import_mcpBundle.z.object({
|
|
34
|
+
key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
|
35
35
|
}),
|
|
36
36
|
type: "input"
|
|
37
37
|
},
|
|
@@ -45,9 +45,9 @@ const pressKey = (0, import_tool.defineTabTool)({
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
const typeSchema = import_snapshot.elementSchema.extend({
|
|
48
|
-
text:
|
|
49
|
-
submit:
|
|
50
|
-
slowly:
|
|
48
|
+
text: import_mcpBundle.z.string().describe("Text to type into the element"),
|
|
49
|
+
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)"),
|
|
50
|
+
slowly: import_mcpBundle.z.boolean().optional().describe("Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.")
|
|
51
51
|
});
|
|
52
52
|
const type = (0, import_tool.defineTabTool)({
|
|
53
53
|
capability: "core",
|
|
@@ -21,10 +21,10 @@ __export(mouse_exports, {
|
|
|
21
21
|
default: () => mouse_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(mouse_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
|
-
const elementSchema =
|
|
27
|
-
element:
|
|
26
|
+
const elementSchema = import_mcpBundle.z.object({
|
|
27
|
+
element: import_mcpBundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
|
|
28
28
|
});
|
|
29
29
|
const mouseMove = (0, import_tool.defineTabTool)({
|
|
30
30
|
capability: "vision",
|
|
@@ -33,8 +33,8 @@ const mouseMove = (0, import_tool.defineTabTool)({
|
|
|
33
33
|
title: "Move mouse",
|
|
34
34
|
description: "Move mouse to a given position",
|
|
35
35
|
inputSchema: elementSchema.extend({
|
|
36
|
-
x:
|
|
37
|
-
y:
|
|
36
|
+
x: import_mcpBundle.z.number().describe("X coordinate"),
|
|
37
|
+
y: import_mcpBundle.z.number().describe("Y coordinate")
|
|
38
38
|
}),
|
|
39
39
|
type: "input"
|
|
40
40
|
},
|
|
@@ -53,8 +53,8 @@ const mouseClick = (0, import_tool.defineTabTool)({
|
|
|
53
53
|
title: "Click",
|
|
54
54
|
description: "Click left mouse button at a given position",
|
|
55
55
|
inputSchema: elementSchema.extend({
|
|
56
|
-
x:
|
|
57
|
-
y:
|
|
56
|
+
x: import_mcpBundle.z.number().describe("X coordinate"),
|
|
57
|
+
y: import_mcpBundle.z.number().describe("Y coordinate")
|
|
58
58
|
}),
|
|
59
59
|
type: "input"
|
|
60
60
|
},
|
|
@@ -78,10 +78,10 @@ const mouseDrag = (0, import_tool.defineTabTool)({
|
|
|
78
78
|
title: "Drag mouse",
|
|
79
79
|
description: "Drag left mouse button to a given position",
|
|
80
80
|
inputSchema: elementSchema.extend({
|
|
81
|
-
startX:
|
|
82
|
-
startY:
|
|
83
|
-
endX:
|
|
84
|
-
endY:
|
|
81
|
+
startX: import_mcpBundle.z.number().describe("Start X coordinate"),
|
|
82
|
+
startY: import_mcpBundle.z.number().describe("Start Y coordinate"),
|
|
83
|
+
endX: import_mcpBundle.z.number().describe("End X coordinate"),
|
|
84
|
+
endY: import_mcpBundle.z.number().describe("End Y coordinate")
|
|
85
85
|
}),
|
|
86
86
|
type: "input"
|
|
87
87
|
},
|
|
@@ -21,7 +21,7 @@ __export(navigate_exports, {
|
|
|
21
21
|
default: () => navigate_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(navigate_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const navigate = (0, import_tool.defineTool)({
|
|
27
27
|
capability: "core",
|
|
@@ -29,8 +29,8 @@ const navigate = (0, import_tool.defineTool)({
|
|
|
29
29
|
name: "browser_navigate",
|
|
30
30
|
title: "Navigate to a URL",
|
|
31
31
|
description: "Navigate to a URL",
|
|
32
|
-
inputSchema:
|
|
33
|
-
url:
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
url: import_mcpBundle.z.string().describe("The URL to navigate to")
|
|
34
34
|
}),
|
|
35
35
|
type: "action"
|
|
36
36
|
},
|
|
@@ -47,7 +47,7 @@ const goBack = (0, import_tool.defineTabTool)({
|
|
|
47
47
|
name: "browser_navigate_back",
|
|
48
48
|
title: "Go back",
|
|
49
49
|
description: "Go back to the previous page",
|
|
50
|
-
inputSchema:
|
|
50
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
51
51
|
type: "action"
|
|
52
52
|
},
|
|
53
53
|
handle: async (tab, params, response) => {
|
|
@@ -21,7 +21,7 @@ __export(network_exports, {
|
|
|
21
21
|
default: () => network_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(network_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const requests = (0, import_tool.defineTabTool)({
|
|
27
27
|
capability: "core",
|
|
@@ -29,24 +29,30 @@ const requests = (0, import_tool.defineTabTool)({
|
|
|
29
29
|
name: "browser_network_requests",
|
|
30
30
|
title: "List network requests",
|
|
31
31
|
description: "Returns all network requests since loading the page",
|
|
32
|
-
inputSchema:
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
includeStatic: import_mcpBundle.z.boolean().default(false).describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false.")
|
|
34
|
+
}),
|
|
33
35
|
type: "readOnly"
|
|
34
36
|
},
|
|
35
37
|
handle: async (tab, params, response) => {
|
|
36
38
|
const requests2 = await tab.requests();
|
|
37
|
-
for (const request of requests2)
|
|
38
|
-
|
|
39
|
+
for (const request of requests2) {
|
|
40
|
+
const rendered = await renderRequest(request, params.includeStatic);
|
|
41
|
+
if (rendered)
|
|
42
|
+
response.addResult(rendered);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
});
|
|
41
|
-
async function renderRequest(request) {
|
|
46
|
+
async function renderRequest(request, includeStatic) {
|
|
47
|
+
const response = request._hasResponse ? await request.response() : void 0;
|
|
48
|
+
const isStaticRequest = ["document", "stylesheet", "image", "media", "font", "script", "manifest"].includes(request.resourceType());
|
|
49
|
+
const isSuccessfulRequest = !response || response.status() < 400;
|
|
50
|
+
if (isStaticRequest && isSuccessfulRequest && !includeStatic)
|
|
51
|
+
return void 0;
|
|
42
52
|
const result = [];
|
|
43
53
|
result.push(`[${request.method().toUpperCase()}] ${request.url()}`);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const response = await request.response();
|
|
47
|
-
if (response)
|
|
48
|
-
result.push(`=> [${response.status()}] ${response.statusText()}`);
|
|
49
|
-
}
|
|
54
|
+
if (response)
|
|
55
|
+
result.push(`=> [${response.status()}] ${response.statusText()}`);
|
|
50
56
|
return result.join(" ");
|
|
51
57
|
}
|
|
52
58
|
var network_default = [
|
|
@@ -31,12 +31,12 @@ __export(pdf_exports, {
|
|
|
31
31
|
default: () => pdf_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(pdf_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
35
35
|
var import_tool = require("./tool");
|
|
36
36
|
var javascript = __toESM(require("../codegen"));
|
|
37
37
|
var import_utils = require("./utils");
|
|
38
|
-
const pdfSchema =
|
|
39
|
-
filename:
|
|
38
|
+
const pdfSchema = import_mcpBundle.z.object({
|
|
39
|
+
filename: import_mcpBundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.")
|
|
40
40
|
});
|
|
41
41
|
const pdf = (0, import_tool.defineTabTool)({
|
|
42
42
|
capability: "pdf",
|
|
@@ -33,10 +33,10 @@ __export(runCode_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(runCode_exports);
|
|
34
34
|
var import_vm = __toESM(require("vm"));
|
|
35
35
|
var import_utils = require("playwright-core/lib/utils");
|
|
36
|
-
var
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
37
|
var import_tool = require("./tool");
|
|
38
|
-
const codeSchema =
|
|
39
|
-
code:
|
|
38
|
+
const codeSchema = import_mcpBundle.z.object({
|
|
39
|
+
code: import_mcpBundle.z.string().describe(`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();\``)
|
|
40
40
|
});
|
|
41
41
|
const runCode = (0, import_tool.defineTabTool)({
|
|
42
42
|
capability: "core",
|
|
@@ -35,16 +35,16 @@ module.exports = __toCommonJS(screenshot_exports);
|
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_utils = require("playwright-core/lib/utils");
|
|
37
37
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
38
|
-
var
|
|
38
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
39
39
|
var import_tool = require("./tool");
|
|
40
40
|
var javascript = __toESM(require("../codegen"));
|
|
41
41
|
var import_utils2 = require("./utils");
|
|
42
|
-
const screenshotSchema =
|
|
43
|
-
type:
|
|
44
|
-
filename:
|
|
45
|
-
element:
|
|
46
|
-
ref:
|
|
47
|
-
fullPage:
|
|
42
|
+
const screenshotSchema = import_mcpBundle.z.object({
|
|
43
|
+
type: import_mcpBundle.z.enum(["png", "jpeg"]).default("png").describe("Image format for the screenshot. Default is png."),
|
|
44
|
+
filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory."),
|
|
45
|
+
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too."),
|
|
46
|
+
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too."),
|
|
47
|
+
fullPage: import_mcpBundle.z.boolean().optional().describe("When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.")
|
|
48
48
|
});
|
|
49
49
|
const screenshot = (0, import_tool.defineTabTool)({
|
|
50
50
|
capability: "core",
|
|
@@ -32,7 +32,7 @@ __export(snapshot_exports, {
|
|
|
32
32
|
elementSchema: () => elementSchema
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(snapshot_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
36
36
|
var import_tool = require("./tool");
|
|
37
37
|
var javascript = __toESM(require("../codegen"));
|
|
38
38
|
const snapshot = (0, import_tool.defineTool)({
|
|
@@ -41,7 +41,7 @@ const snapshot = (0, import_tool.defineTool)({
|
|
|
41
41
|
name: "browser_snapshot",
|
|
42
42
|
title: "Page snapshot",
|
|
43
43
|
description: "Capture accessibility snapshot of the current page, this is better than screenshot",
|
|
44
|
-
inputSchema:
|
|
44
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
45
45
|
type: "readOnly"
|
|
46
46
|
},
|
|
47
47
|
handle: async (context, params, response) => {
|
|
@@ -49,14 +49,14 @@ const snapshot = (0, import_tool.defineTool)({
|
|
|
49
49
|
response.setIncludeFullSnapshot();
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
|
-
const elementSchema =
|
|
53
|
-
element:
|
|
54
|
-
ref:
|
|
52
|
+
const elementSchema = import_mcpBundle.z.object({
|
|
53
|
+
element: import_mcpBundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element"),
|
|
54
|
+
ref: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
|
|
55
55
|
});
|
|
56
56
|
const clickSchema = elementSchema.extend({
|
|
57
|
-
doubleClick:
|
|
58
|
-
button:
|
|
59
|
-
modifiers:
|
|
57
|
+
doubleClick: import_mcpBundle.z.boolean().optional().describe("Whether to perform a double click instead of a single click"),
|
|
58
|
+
button: import_mcpBundle.z.enum(["left", "right", "middle"]).optional().describe("Button to click, defaults to left"),
|
|
59
|
+
modifiers: import_mcpBundle.z.array(import_mcpBundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
|
|
60
60
|
});
|
|
61
61
|
const click = (0, import_tool.defineTabTool)({
|
|
62
62
|
capability: "core",
|
|
@@ -94,11 +94,11 @@ const drag = (0, import_tool.defineTabTool)({
|
|
|
94
94
|
name: "browser_drag",
|
|
95
95
|
title: "Drag mouse",
|
|
96
96
|
description: "Perform drag and drop between two elements",
|
|
97
|
-
inputSchema:
|
|
98
|
-
startElement:
|
|
99
|
-
startRef:
|
|
100
|
-
endElement:
|
|
101
|
-
endRef:
|
|
97
|
+
inputSchema: import_mcpBundle.z.object({
|
|
98
|
+
startElement: import_mcpBundle.z.string().describe("Human-readable source element description used to obtain the permission to interact with the element"),
|
|
99
|
+
startRef: import_mcpBundle.z.string().describe("Exact source element reference from the page snapshot"),
|
|
100
|
+
endElement: import_mcpBundle.z.string().describe("Human-readable target element description used to obtain the permission to interact with the element"),
|
|
101
|
+
endRef: import_mcpBundle.z.string().describe("Exact target element reference from the page snapshot")
|
|
102
102
|
}),
|
|
103
103
|
type: "input"
|
|
104
104
|
},
|
|
@@ -133,7 +133,7 @@ const hover = (0, import_tool.defineTabTool)({
|
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
135
|
const selectOptionSchema = elementSchema.extend({
|
|
136
|
-
values:
|
|
136
|
+
values: import_mcpBundle.z.array(import_mcpBundle.z.string()).describe("Array of values to select in the dropdown. This can be a single value or multiple values.")
|
|
137
137
|
});
|
|
138
138
|
const selectOption = (0, import_tool.defineTabTool)({
|
|
139
139
|
capability: "core",
|
|
@@ -21,7 +21,7 @@ __export(tabs_exports, {
|
|
|
21
21
|
default: () => tabs_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(tabs_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const browserTabs = (0, import_tool.defineTool)({
|
|
27
27
|
capability: "core-tabs",
|
|
@@ -29,9 +29,9 @@ const browserTabs = (0, import_tool.defineTool)({
|
|
|
29
29
|
name: "browser_tabs",
|
|
30
30
|
title: "Manage tabs",
|
|
31
31
|
description: "List, create, close, or select a browser tab.",
|
|
32
|
-
inputSchema:
|
|
33
|
-
action:
|
|
34
|
-
index:
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
action: import_mcpBundle.z.enum(["list", "new", "close", "select"]).describe("Operation to perform"),
|
|
34
|
+
index: import_mcpBundle.z.number().optional().describe("Tab index, used for close/select. If omitted for close, current tab is closed.")
|
|
35
35
|
}),
|
|
36
36
|
type: "action"
|
|
37
37
|
},
|
|
@@ -31,14 +31,15 @@ function defineTabTool(tool) {
|
|
|
31
31
|
handle: async (context, params, response) => {
|
|
32
32
|
const tab = await context.ensureTab();
|
|
33
33
|
const modalStates = tab.modalStates().map((state) => state.type);
|
|
34
|
-
if (tool.clearsModalState && !modalStates.includes(tool.clearsModalState))
|
|
35
|
-
response.
|
|
36
|
-
`
|
|
37
|
-
else if (!tool.clearsModalState && modalStates.length)
|
|
38
|
-
response.
|
|
39
|
-
`
|
|
40
|
-
else
|
|
34
|
+
if (tool.clearsModalState && !modalStates.includes(tool.clearsModalState)) {
|
|
35
|
+
response.setIncludeModalStates(tab.modalStates());
|
|
36
|
+
response.addError(`Error: The tool "${tool.schema.name}" can only be used when there is related modal state present.`);
|
|
37
|
+
} else if (!tool.clearsModalState && modalStates.length) {
|
|
38
|
+
response.setIncludeModalStates(tab.modalStates());
|
|
39
|
+
response.addError(`Error: Tool "${tool.schema.name}" does not handle the modal state.`);
|
|
40
|
+
} else {
|
|
41
41
|
return tool.handle(tab, params, response);
|
|
42
|
+
}
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
}
|
|
@@ -21,7 +21,7 @@ __export(tracing_exports, {
|
|
|
21
21
|
default: () => tracing_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(tracing_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const tracingStart = (0, import_tool.defineTool)({
|
|
27
27
|
capability: "tracing",
|
|
@@ -29,7 +29,7 @@ const tracingStart = (0, import_tool.defineTool)({
|
|
|
29
29
|
name: "browser_start_tracing",
|
|
30
30
|
title: "Start tracing",
|
|
31
31
|
description: "Start trace recording",
|
|
32
|
-
inputSchema:
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
33
33
|
type: "readOnly"
|
|
34
34
|
},
|
|
35
35
|
handle: async (context, params, response) => {
|
|
@@ -56,7 +56,7 @@ const tracingStop = (0, import_tool.defineTool)({
|
|
|
56
56
|
name: "browser_stop_tracing",
|
|
57
57
|
title: "Stop tracing",
|
|
58
58
|
description: "Stop trace recording",
|
|
59
|
-
inputSchema:
|
|
59
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
60
60
|
type: "readOnly"
|
|
61
61
|
},
|
|
62
62
|
handle: async (context, params, response) => {
|
|
@@ -31,7 +31,7 @@ __export(verify_exports, {
|
|
|
31
31
|
default: () => verify_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(verify_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
35
35
|
var import_tool = require("./tool");
|
|
36
36
|
var javascript = __toESM(require("../codegen"));
|
|
37
37
|
const verifyElement = (0, import_tool.defineTabTool)({
|
|
@@ -40,9 +40,9 @@ const verifyElement = (0, import_tool.defineTabTool)({
|
|
|
40
40
|
name: "browser_verify_element_visible",
|
|
41
41
|
title: "Verify element visible",
|
|
42
42
|
description: "Verify element is visible on the page",
|
|
43
|
-
inputSchema:
|
|
44
|
-
role:
|
|
45
|
-
accessibleName:
|
|
43
|
+
inputSchema: import_mcpBundle.z.object({
|
|
44
|
+
role: import_mcpBundle.z.string().describe('ROLE of the element. Can be found in the snapshot like this: `- {ROLE} "Accessible Name":`'),
|
|
45
|
+
accessibleName: import_mcpBundle.z.string().describe('ACCESSIBLE_NAME of the element. Can be found in the snapshot like this: `- role "{ACCESSIBLE_NAME}"`')
|
|
46
46
|
}),
|
|
47
47
|
type: "assertion"
|
|
48
48
|
},
|
|
@@ -62,8 +62,8 @@ const verifyText = (0, import_tool.defineTabTool)({
|
|
|
62
62
|
name: "browser_verify_text_visible",
|
|
63
63
|
title: "Verify text visible",
|
|
64
64
|
description: `Verify text is visible on the page. Prefer ${verifyElement.schema.name} if possible.`,
|
|
65
|
-
inputSchema:
|
|
66
|
-
text:
|
|
65
|
+
inputSchema: import_mcpBundle.z.object({
|
|
66
|
+
text: import_mcpBundle.z.string().describe('TEXT to verify. Can be found in the snapshot like this: `- role "Accessible Name": {TEXT}` or like this: `- text: {TEXT}`')
|
|
67
67
|
}),
|
|
68
68
|
type: "assertion"
|
|
69
69
|
},
|
|
@@ -83,10 +83,10 @@ const verifyList = (0, import_tool.defineTabTool)({
|
|
|
83
83
|
name: "browser_verify_list_visible",
|
|
84
84
|
title: "Verify list visible",
|
|
85
85
|
description: "Verify list is visible on the page",
|
|
86
|
-
inputSchema:
|
|
87
|
-
element:
|
|
88
|
-
ref:
|
|
89
|
-
items:
|
|
86
|
+
inputSchema: import_mcpBundle.z.object({
|
|
87
|
+
element: import_mcpBundle.z.string().describe("Human-readable list description"),
|
|
88
|
+
ref: import_mcpBundle.z.string().describe("Exact target element reference that points to the list"),
|
|
89
|
+
items: import_mcpBundle.z.array(import_mcpBundle.z.string()).describe("Items to verify")
|
|
90
90
|
}),
|
|
91
91
|
type: "assertion"
|
|
92
92
|
},
|
|
@@ -115,11 +115,11 @@ const verifyValue = (0, import_tool.defineTabTool)({
|
|
|
115
115
|
name: "browser_verify_value",
|
|
116
116
|
title: "Verify value",
|
|
117
117
|
description: "Verify element value",
|
|
118
|
-
inputSchema:
|
|
119
|
-
type:
|
|
120
|
-
element:
|
|
121
|
-
ref:
|
|
122
|
-
value:
|
|
118
|
+
inputSchema: import_mcpBundle.z.object({
|
|
119
|
+
type: import_mcpBundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the element"),
|
|
120
|
+
element: import_mcpBundle.z.string().describe("Human-readable element description"),
|
|
121
|
+
ref: import_mcpBundle.z.string().describe("Exact target element reference that points to the element"),
|
|
122
|
+
value: import_mcpBundle.z.string().describe('Value to verify. For checkbox, use "true" or "false".')
|
|
123
123
|
}),
|
|
124
124
|
type: "assertion"
|
|
125
125
|
},
|
|
@@ -21,7 +21,7 @@ __export(wait_exports, {
|
|
|
21
21
|
default: () => wait_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(wait_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
25
|
var import_tool = require("./tool");
|
|
26
26
|
const wait = (0, import_tool.defineTool)({
|
|
27
27
|
capability: "core",
|
|
@@ -29,10 +29,10 @@ const wait = (0, import_tool.defineTool)({
|
|
|
29
29
|
name: "browser_wait_for",
|
|
30
30
|
title: "Wait for",
|
|
31
31
|
description: "Wait for text to appear or disappear or a specified time to pass",
|
|
32
|
-
inputSchema:
|
|
33
|
-
time:
|
|
34
|
-
text:
|
|
35
|
-
textGone:
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
time: import_mcpBundle.z.number().optional().describe("The time to wait in seconds"),
|
|
34
|
+
text: import_mcpBundle.z.string().optional().describe("The text to wait for"),
|
|
35
|
+
textGone: import_mcpBundle.z.string().optional().describe("The text to wait for to disappear")
|
|
36
36
|
}),
|
|
37
37
|
type: "assertion"
|
|
38
38
|
},
|