@treegress.com/treegress-browser-mcp 0.0.56-treegress.3
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 +68 -0
- package/cli.js +25 -0
- package/config.d.ts +223 -0
- package/index.d.ts +23 -0
- package/index.js +19 -0
- package/mcp/browser/browserContextFactory.js +332 -0
- package/mcp/browser/browserServerBackend.js +105 -0
- package/mcp/browser/config.js +489 -0
- package/mcp/browser/configIni.js +194 -0
- package/mcp/browser/context.js +302 -0
- package/mcp/browser/domSnapshot.js +307 -0
- package/mcp/browser/logFile.js +96 -0
- package/mcp/browser/response.js +299 -0
- package/mcp/browser/sessionLog.js +75 -0
- package/mcp/browser/tab.js +1193 -0
- package/mcp/browser/tools/common.js +63 -0
- package/mcp/browser/tools/config.js +41 -0
- package/mcp/browser/tools/console.js +65 -0
- package/mcp/browser/tools/cookies.js +152 -0
- package/mcp/browser/tools/devtools.js +42 -0
- package/mcp/browser/tools/dialogs.js +59 -0
- package/mcp/browser/tools/evaluate.js +61 -0
- package/mcp/browser/tools/files.js +58 -0
- package/mcp/browser/tools/form.js +63 -0
- package/mcp/browser/tools/install.js +73 -0
- package/mcp/browser/tools/keyboard.js +151 -0
- package/mcp/browser/tools/mouse.js +159 -0
- package/mcp/browser/tools/navigate.js +105 -0
- package/mcp/browser/tools/network.js +92 -0
- package/mcp/browser/tools/pdf.js +48 -0
- package/mcp/browser/tools/route.js +140 -0
- package/mcp/browser/tools/runCode.js +76 -0
- package/mcp/browser/tools/screenshot.js +86 -0
- package/mcp/browser/tools/snapshot.js +207 -0
- package/mcp/browser/tools/storage.js +67 -0
- package/mcp/browser/tools/tabs.js +67 -0
- package/mcp/browser/tools/tool.js +47 -0
- package/mcp/browser/tools/tracing.js +75 -0
- package/mcp/browser/tools/utils.js +88 -0
- package/mcp/browser/tools/verify.js +143 -0
- package/mcp/browser/tools/video.js +89 -0
- package/mcp/browser/tools/wait.js +63 -0
- package/mcp/browser/tools/webstorage.js +223 -0
- package/mcp/browser/tools.js +96 -0
- package/mcp/browser/watchdog.js +44 -0
- package/mcp/config.d.js +16 -0
- package/mcp/extension/cdpRelay.js +354 -0
- package/mcp/extension/extensionContextFactory.js +77 -0
- package/mcp/extension/protocol.js +28 -0
- package/mcp/index.js +61 -0
- package/mcp/log.js +35 -0
- package/mcp/program.js +126 -0
- package/mcp/sdk/exports.js +28 -0
- package/mcp/sdk/http.js +172 -0
- package/mcp/sdk/inProcessTransport.js +71 -0
- package/mcp/sdk/server.js +223 -0
- package/mcp/sdk/tool.js +54 -0
- package/mcp/test/browserBackend.js +98 -0
- package/mcp/test/generatorTools.js +122 -0
- package/mcp/test/plannerTools.js +145 -0
- package/mcp/test/seed.js +82 -0
- package/mcp/test/streams.js +44 -0
- package/mcp/test/testBackend.js +99 -0
- package/mcp/test/testContext.js +285 -0
- package/mcp/test/testTool.js +30 -0
- package/mcp/test/testTools.js +108 -0
- package/package.json +46 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var common_exports = {};
|
|
20
|
+
__export(common_exports, {
|
|
21
|
+
default: () => common_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(common_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
var import_response = require("../response");
|
|
27
|
+
const close = (0, import_tool.defineTool)({
|
|
28
|
+
capability: "core",
|
|
29
|
+
schema: {
|
|
30
|
+
name: "browser_close",
|
|
31
|
+
title: "Close browser",
|
|
32
|
+
description: "Close the page",
|
|
33
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
34
|
+
type: "action"
|
|
35
|
+
},
|
|
36
|
+
handle: async (context, params, response) => {
|
|
37
|
+
await context.closeBrowserContext();
|
|
38
|
+
const result = (0, import_response.renderTabsMarkdown)([]);
|
|
39
|
+
response.addTextResult(result.join("\n"));
|
|
40
|
+
response.addCode(`await page.close()`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const resize = (0, import_tool.defineTabTool)({
|
|
44
|
+
capability: "core",
|
|
45
|
+
schema: {
|
|
46
|
+
name: "browser_resize",
|
|
47
|
+
title: "Resize browser window",
|
|
48
|
+
description: "Resize the browser window",
|
|
49
|
+
inputSchema: import_mcpBundle.z.object({
|
|
50
|
+
width: import_mcpBundle.z.number().describe("Width of the browser window"),
|
|
51
|
+
height: import_mcpBundle.z.number().describe("Height of the browser window")
|
|
52
|
+
}),
|
|
53
|
+
type: "action"
|
|
54
|
+
},
|
|
55
|
+
handle: async (tab, params, response) => {
|
|
56
|
+
response.addCode(`await page.setViewportSize({ width: ${params.width}, height: ${params.height} });`);
|
|
57
|
+
await tab.page.setViewportSize({ width: params.width, height: params.height });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var common_default = [
|
|
61
|
+
close,
|
|
62
|
+
resize
|
|
63
|
+
];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var config_exports = {};
|
|
20
|
+
__export(config_exports, {
|
|
21
|
+
default: () => config_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(config_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const configShow = (0, import_tool.defineTool)({
|
|
27
|
+
capability: "config",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_get_config",
|
|
30
|
+
title: "Get config",
|
|
31
|
+
description: "Get the final resolved config after merging CLI options, environment variables and config file.",
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
33
|
+
type: "readOnly"
|
|
34
|
+
},
|
|
35
|
+
handle: async (context, params, response) => {
|
|
36
|
+
response.addTextResult(JSON.stringify(context.config, null, 2));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var config_default = [
|
|
40
|
+
configShow
|
|
41
|
+
];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var console_exports = {};
|
|
20
|
+
__export(console_exports, {
|
|
21
|
+
default: () => console_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(console_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const console = (0, import_tool.defineTabTool)({
|
|
27
|
+
capability: "core",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_console_messages",
|
|
30
|
+
title: "Get console messages",
|
|
31
|
+
description: "Returns all console messages",
|
|
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
|
+
filename: import_mcpBundle.z.string().optional().describe("Filename to save the console messages to. If not provided, messages are returned as text.")
|
|
35
|
+
}),
|
|
36
|
+
type: "readOnly"
|
|
37
|
+
},
|
|
38
|
+
handle: async (tab, params, response) => {
|
|
39
|
+
const count = await tab.consoleMessageCount();
|
|
40
|
+
const header = [`Total messages: ${count.total} (Errors: ${count.errors}, Warnings: ${count.warnings})`];
|
|
41
|
+
const messages = await tab.consoleMessages(params.level);
|
|
42
|
+
if (messages.length !== count.total)
|
|
43
|
+
header.push(`Returning ${messages.length} messages for level "${params.level}"`);
|
|
44
|
+
const text = [...header, "", ...messages.map((message) => message.toString())].join("\n");
|
|
45
|
+
await response.addResult("Console", text, { prefix: "console", ext: "log", suggestedFilename: params.filename });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const consoleClear = (0, import_tool.defineTabTool)({
|
|
49
|
+
capability: "core",
|
|
50
|
+
skillOnly: true,
|
|
51
|
+
schema: {
|
|
52
|
+
name: "browser_console_clear",
|
|
53
|
+
title: "Clear console messages",
|
|
54
|
+
description: "Clear all console messages",
|
|
55
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
56
|
+
type: "readOnly"
|
|
57
|
+
},
|
|
58
|
+
handle: async (tab) => {
|
|
59
|
+
await tab.clearConsoleMessages();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var console_default = [
|
|
63
|
+
console,
|
|
64
|
+
consoleClear
|
|
65
|
+
];
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cookies_exports = {};
|
|
20
|
+
__export(cookies_exports, {
|
|
21
|
+
default: () => cookies_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cookies_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const cookieList = (0, import_tool.defineTool)({
|
|
27
|
+
capability: "storage",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_cookie_list",
|
|
30
|
+
title: "List cookies",
|
|
31
|
+
description: "List all cookies (optionally filtered by domain/path)",
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
domain: import_mcpBundle.z.string().optional().describe("Filter cookies by domain"),
|
|
34
|
+
path: import_mcpBundle.z.string().optional().describe("Filter cookies by path")
|
|
35
|
+
}),
|
|
36
|
+
type: "readOnly"
|
|
37
|
+
},
|
|
38
|
+
handle: async (context, params, response) => {
|
|
39
|
+
const browserContext = await context.ensureBrowserContext();
|
|
40
|
+
let cookies = await browserContext.cookies();
|
|
41
|
+
if (params.domain)
|
|
42
|
+
cookies = cookies.filter((c) => c.domain.includes(params.domain));
|
|
43
|
+
if (params.path)
|
|
44
|
+
cookies = cookies.filter((c) => c.path.startsWith(params.path));
|
|
45
|
+
if (cookies.length === 0)
|
|
46
|
+
response.addTextResult("No cookies found");
|
|
47
|
+
else
|
|
48
|
+
response.addTextResult(cookies.map((c) => `${c.name}=${c.value} (domain: ${c.domain}, path: ${c.path})`).join("\n"));
|
|
49
|
+
response.addCode(`await page.context().cookies();`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const cookieGet = (0, import_tool.defineTool)({
|
|
53
|
+
capability: "storage",
|
|
54
|
+
schema: {
|
|
55
|
+
name: "browser_cookie_get",
|
|
56
|
+
title: "Get cookie",
|
|
57
|
+
description: "Get a specific cookie by name",
|
|
58
|
+
inputSchema: import_mcpBundle.z.object({
|
|
59
|
+
name: import_mcpBundle.z.string().describe("Cookie name to get")
|
|
60
|
+
}),
|
|
61
|
+
type: "readOnly"
|
|
62
|
+
},
|
|
63
|
+
handle: async (context, params, response) => {
|
|
64
|
+
const browserContext = await context.ensureBrowserContext();
|
|
65
|
+
const cookies = await browserContext.cookies();
|
|
66
|
+
const cookie = cookies.find((c) => c.name === params.name);
|
|
67
|
+
if (!cookie)
|
|
68
|
+
response.addTextResult(`Cookie '${params.name}' not found`);
|
|
69
|
+
else
|
|
70
|
+
response.addTextResult(`${cookie.name}=${cookie.value} (domain: ${cookie.domain}, path: ${cookie.path}, httpOnly: ${cookie.httpOnly}, secure: ${cookie.secure}, sameSite: ${cookie.sameSite})`);
|
|
71
|
+
response.addCode(`await page.context().cookies();`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const cookieSet = (0, import_tool.defineTool)({
|
|
75
|
+
capability: "storage",
|
|
76
|
+
schema: {
|
|
77
|
+
name: "browser_cookie_set",
|
|
78
|
+
title: "Set cookie",
|
|
79
|
+
description: "Set a cookie with optional flags (domain, path, expires, httpOnly, secure, sameSite)",
|
|
80
|
+
inputSchema: import_mcpBundle.z.object({
|
|
81
|
+
name: import_mcpBundle.z.string().describe("Cookie name"),
|
|
82
|
+
value: import_mcpBundle.z.string().describe("Cookie value"),
|
|
83
|
+
domain: import_mcpBundle.z.string().optional().describe("Cookie domain"),
|
|
84
|
+
path: import_mcpBundle.z.string().optional().describe("Cookie path"),
|
|
85
|
+
expires: import_mcpBundle.z.number().optional().describe("Cookie expiration as Unix timestamp"),
|
|
86
|
+
httpOnly: import_mcpBundle.z.boolean().optional().describe("Whether the cookie is HTTP only"),
|
|
87
|
+
secure: import_mcpBundle.z.boolean().optional().describe("Whether the cookie is secure"),
|
|
88
|
+
sameSite: import_mcpBundle.z.enum(["Strict", "Lax", "None"]).optional().describe("Cookie SameSite attribute")
|
|
89
|
+
}),
|
|
90
|
+
type: "action"
|
|
91
|
+
},
|
|
92
|
+
handle: async (context, params, response) => {
|
|
93
|
+
const browserContext = await context.ensureBrowserContext();
|
|
94
|
+
const tab = await context.ensureTab();
|
|
95
|
+
const url = new URL(tab.page.url());
|
|
96
|
+
const cookie = {
|
|
97
|
+
name: params.name,
|
|
98
|
+
value: params.value,
|
|
99
|
+
domain: params.domain || url.hostname,
|
|
100
|
+
path: params.path || "/"
|
|
101
|
+
};
|
|
102
|
+
if (params.expires !== void 0)
|
|
103
|
+
cookie.expires = params.expires;
|
|
104
|
+
if (params.httpOnly !== void 0)
|
|
105
|
+
cookie.httpOnly = params.httpOnly;
|
|
106
|
+
if (params.secure !== void 0)
|
|
107
|
+
cookie.secure = params.secure;
|
|
108
|
+
if (params.sameSite !== void 0)
|
|
109
|
+
cookie.sameSite = params.sameSite;
|
|
110
|
+
await browserContext.addCookies([cookie]);
|
|
111
|
+
response.addCode(`await page.context().addCookies([${JSON.stringify(cookie)}]);`);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const cookieDelete = (0, import_tool.defineTool)({
|
|
115
|
+
capability: "storage",
|
|
116
|
+
schema: {
|
|
117
|
+
name: "browser_cookie_delete",
|
|
118
|
+
title: "Delete cookie",
|
|
119
|
+
description: "Delete a specific cookie",
|
|
120
|
+
inputSchema: import_mcpBundle.z.object({
|
|
121
|
+
name: import_mcpBundle.z.string().describe("Cookie name to delete")
|
|
122
|
+
}),
|
|
123
|
+
type: "action"
|
|
124
|
+
},
|
|
125
|
+
handle: async (context, params, response) => {
|
|
126
|
+
const browserContext = await context.ensureBrowserContext();
|
|
127
|
+
await browserContext.clearCookies({ name: params.name });
|
|
128
|
+
response.addCode(`await page.context().clearCookies({ name: '${params.name}' });`);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const cookieClear = (0, import_tool.defineTool)({
|
|
132
|
+
capability: "storage",
|
|
133
|
+
schema: {
|
|
134
|
+
name: "browser_cookie_clear",
|
|
135
|
+
title: "Clear cookies",
|
|
136
|
+
description: "Clear all cookies",
|
|
137
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
138
|
+
type: "action"
|
|
139
|
+
},
|
|
140
|
+
handle: async (context, params, response) => {
|
|
141
|
+
const browserContext = await context.ensureBrowserContext();
|
|
142
|
+
await browserContext.clearCookies();
|
|
143
|
+
response.addCode(`await page.context().clearCookies();`);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
var cookies_default = [
|
|
147
|
+
cookieList,
|
|
148
|
+
cookieGet,
|
|
149
|
+
cookieSet,
|
|
150
|
+
cookieDelete,
|
|
151
|
+
cookieClear
|
|
152
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var devtools_exports = {};
|
|
20
|
+
__export(devtools_exports, {
|
|
21
|
+
default: () => devtools_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(devtools_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const devtoolsConnect = (0, import_tool.defineTool)({
|
|
27
|
+
capability: "devtools",
|
|
28
|
+
skillOnly: true,
|
|
29
|
+
schema: {
|
|
30
|
+
name: "browser_devtools_start",
|
|
31
|
+
title: "Start browser DevTools",
|
|
32
|
+
description: "Start browser DevTools",
|
|
33
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
34
|
+
type: "action"
|
|
35
|
+
},
|
|
36
|
+
handle: async (context, params, response) => {
|
|
37
|
+
const browserContext = await context.ensureBrowserContext();
|
|
38
|
+
const { url } = await browserContext._devtoolsStart();
|
|
39
|
+
response.addTextResult("Server is listening on: " + url);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var devtools_default = [devtoolsConnect];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var dialogs_exports = {};
|
|
20
|
+
__export(dialogs_exports, {
|
|
21
|
+
default: () => dialogs_default,
|
|
22
|
+
handleDialog: () => handleDialog
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(dialogs_exports);
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
|
+
var import_tool = require("./tool");
|
|
27
|
+
const handleDialog = (0, import_tool.defineTabTool)({
|
|
28
|
+
capability: "core",
|
|
29
|
+
schema: {
|
|
30
|
+
name: "browser_handle_dialog",
|
|
31
|
+
title: "Handle a dialog",
|
|
32
|
+
description: "Handle a dialog",
|
|
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
|
+
}),
|
|
37
|
+
type: "action"
|
|
38
|
+
},
|
|
39
|
+
handle: async (tab, params, response) => {
|
|
40
|
+
const dialogState = tab.modalStates().find((state) => state.type === "dialog");
|
|
41
|
+
if (!dialogState)
|
|
42
|
+
throw new Error("No dialog visible");
|
|
43
|
+
tab.clearModalState(dialogState);
|
|
44
|
+
await tab.waitForCompletion(async () => {
|
|
45
|
+
if (params.accept)
|
|
46
|
+
await dialogState.dialog.accept(params.promptText);
|
|
47
|
+
else
|
|
48
|
+
await dialogState.dialog.dismiss();
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
clearsModalState: "dialog"
|
|
52
|
+
});
|
|
53
|
+
var dialogs_default = [
|
|
54
|
+
handleDialog
|
|
55
|
+
];
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
handleDialog
|
|
59
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var evaluate_exports = {};
|
|
20
|
+
__export(evaluate_exports, {
|
|
21
|
+
default: () => evaluate_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(evaluate_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
26
|
+
var import_tool = require("./tool");
|
|
27
|
+
const evaluateSchema = import_mcpBundle.z.object({
|
|
28
|
+
function: import_mcpBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
|
|
29
|
+
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to interact with the element"),
|
|
30
|
+
ref: import_mcpBundle.z.string().optional().describe("Exact target element reference from the page snapshot")
|
|
31
|
+
});
|
|
32
|
+
const evaluate = (0, import_tool.defineTabTool)({
|
|
33
|
+
capability: "core",
|
|
34
|
+
schema: {
|
|
35
|
+
name: "browser_evaluate",
|
|
36
|
+
title: "Evaluate JavaScript",
|
|
37
|
+
description: "Evaluate JavaScript expression on page or element",
|
|
38
|
+
inputSchema: evaluateSchema,
|
|
39
|
+
type: "action"
|
|
40
|
+
},
|
|
41
|
+
handle: async (tab, params, response) => {
|
|
42
|
+
let locator;
|
|
43
|
+
if (!params.function.includes("=>"))
|
|
44
|
+
params.function = `() => (${params.function})`;
|
|
45
|
+
if (params.ref) {
|
|
46
|
+
locator = await tab.refLocator({ ref: params.ref, element: params.element || "element" });
|
|
47
|
+
response.addCode(`await page.${locator.resolved}.evaluate(${(0, import_utils.escapeWithQuotes)(params.function)});`);
|
|
48
|
+
} else {
|
|
49
|
+
response.addCode(`await page.evaluate(${(0, import_utils.escapeWithQuotes)(params.function)});`);
|
|
50
|
+
}
|
|
51
|
+
await tab.waitForCompletion(async () => {
|
|
52
|
+
const receiver = locator?.locator ?? tab.page;
|
|
53
|
+
const result = await receiver._evaluateFunction(params.function);
|
|
54
|
+
const text = JSON.stringify(result, null, 2) || "undefined";
|
|
55
|
+
response.addTextResult(text);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
var evaluate_default = [
|
|
60
|
+
evaluate
|
|
61
|
+
];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var files_exports = {};
|
|
20
|
+
__export(files_exports, {
|
|
21
|
+
default: () => files_default,
|
|
22
|
+
uploadFile: () => uploadFile
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(files_exports);
|
|
25
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
26
|
+
var import_tool = require("./tool");
|
|
27
|
+
const uploadFile = (0, import_tool.defineTabTool)({
|
|
28
|
+
capability: "core",
|
|
29
|
+
schema: {
|
|
30
|
+
name: "browser_file_upload",
|
|
31
|
+
title: "Upload files",
|
|
32
|
+
description: "Upload one or multiple files",
|
|
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
|
+
}),
|
|
36
|
+
type: "action"
|
|
37
|
+
},
|
|
38
|
+
handle: async (tab, params, response) => {
|
|
39
|
+
response.setIncludeSnapshot();
|
|
40
|
+
const modalState = tab.modalStates().find((state) => state.type === "fileChooser");
|
|
41
|
+
if (!modalState)
|
|
42
|
+
throw new Error("No file chooser visible");
|
|
43
|
+
response.addCode(`await fileChooser.setFiles(${JSON.stringify(params.paths)})`);
|
|
44
|
+
tab.clearModalState(modalState);
|
|
45
|
+
await tab.waitForCompletion(async () => {
|
|
46
|
+
if (params.paths)
|
|
47
|
+
await modalState.fileChooser.setFiles(params.paths);
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
clearsModalState: "fileChooser"
|
|
51
|
+
});
|
|
52
|
+
var files_default = [
|
|
53
|
+
uploadFile
|
|
54
|
+
];
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
uploadFile
|
|
58
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var form_exports = {};
|
|
20
|
+
__export(form_exports, {
|
|
21
|
+
default: () => form_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(form_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
26
|
+
var import_tool = require("./tool");
|
|
27
|
+
const fillForm = (0, import_tool.defineTabTool)({
|
|
28
|
+
capability: "core",
|
|
29
|
+
schema: {
|
|
30
|
+
name: "browser_fill_form",
|
|
31
|
+
title: "Fill form",
|
|
32
|
+
description: "Fill multiple form fields",
|
|
33
|
+
inputSchema: import_mcpBundle.z.object({
|
|
34
|
+
fields: import_mcpBundle.z.array(import_mcpBundle.z.object({
|
|
35
|
+
name: import_mcpBundle.z.string().describe("Human-readable field name"),
|
|
36
|
+
type: import_mcpBundle.z.enum(["textbox", "checkbox", "radio", "combobox", "slider"]).describe("Type of the field"),
|
|
37
|
+
ref: import_mcpBundle.z.string().describe("Exact target field reference from the page snapshot"),
|
|
38
|
+
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.")
|
|
39
|
+
})).describe("Fields to fill in")
|
|
40
|
+
}),
|
|
41
|
+
type: "input"
|
|
42
|
+
},
|
|
43
|
+
handle: async (tab, params, response) => {
|
|
44
|
+
for (const field of params.fields) {
|
|
45
|
+
const { locator, resolved } = await tab.refLocator({ element: field.name, ref: field.ref });
|
|
46
|
+
const locatorSource = `await page.${resolved}`;
|
|
47
|
+
if (field.type === "textbox" || field.type === "slider") {
|
|
48
|
+
const secret = tab.context.lookupSecret(field.value);
|
|
49
|
+
await locator.fill(secret.value);
|
|
50
|
+
response.addCode(`${locatorSource}.fill(${secret.code});`);
|
|
51
|
+
} else if (field.type === "checkbox" || field.type === "radio") {
|
|
52
|
+
await locator.setChecked(field.value === "true");
|
|
53
|
+
response.addCode(`${locatorSource}.setChecked(${field.value});`);
|
|
54
|
+
} else if (field.type === "combobox") {
|
|
55
|
+
await locator.selectOption({ label: field.value });
|
|
56
|
+
response.addCode(`${locatorSource}.selectOption(${(0, import_utils.escapeWithQuotes)(field.value)});`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
var form_default = [
|
|
62
|
+
fillForm
|
|
63
|
+
];
|