@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,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var install_exports = {};
|
|
30
|
+
__export(install_exports, {
|
|
31
|
+
default: () => install_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(install_exports);
|
|
34
|
+
var import_child_process = require("child_process");
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
|
+
var import_tool = require("./tool");
|
|
38
|
+
var import_response = require("../response");
|
|
39
|
+
const install = (0, import_tool.defineTool)({
|
|
40
|
+
capability: "core-install",
|
|
41
|
+
schema: {
|
|
42
|
+
name: "browser_install",
|
|
43
|
+
title: "Install the browser specified in the config",
|
|
44
|
+
description: "Install the browser specified in the config. Call this if you get an error about the browser not being installed.",
|
|
45
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
46
|
+
type: "action"
|
|
47
|
+
},
|
|
48
|
+
handle: async (context, params, response) => {
|
|
49
|
+
const channel = context.config.browser?.launchOptions?.channel ?? context.config.browser?.browserName ?? "chrome";
|
|
50
|
+
const cliPath = import_path.default.join(require.resolve("playwright-core/package.json"), "../cli.js");
|
|
51
|
+
const child = (0, import_child_process.fork)(cliPath, ["install", channel], {
|
|
52
|
+
stdio: "pipe"
|
|
53
|
+
});
|
|
54
|
+
const output = [];
|
|
55
|
+
child.stdout?.on("data", (data) => output.push(data.toString()));
|
|
56
|
+
child.stderr?.on("data", (data) => output.push(data.toString()));
|
|
57
|
+
await new Promise((resolve, reject) => {
|
|
58
|
+
child.on("close", (code) => {
|
|
59
|
+
if (code === 0)
|
|
60
|
+
resolve();
|
|
61
|
+
else
|
|
62
|
+
reject(new Error(`Failed to install browser: ${output.join("")}`));
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
response.addTextResult(`Browser ${channel} installed.`);
|
|
66
|
+
const tabHeaders = await Promise.all(context.tabs().map((tab) => tab.headerSnapshot()));
|
|
67
|
+
const result = (0, import_response.renderTabsMarkdown)(tabHeaders);
|
|
68
|
+
response.addTextResult(result.join("\n"));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
var install_default = [
|
|
72
|
+
install
|
|
73
|
+
];
|
|
@@ -0,0 +1,151 @@
|
|
|
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 keyboard_exports = {};
|
|
20
|
+
__export(keyboard_exports, {
|
|
21
|
+
default: () => keyboard_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(keyboard_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
var import_snapshot = require("./snapshot");
|
|
27
|
+
const press = (0, import_tool.defineTabTool)({
|
|
28
|
+
capability: "core-input",
|
|
29
|
+
schema: {
|
|
30
|
+
name: "browser_press_key",
|
|
31
|
+
title: "Press a key",
|
|
32
|
+
description: "Press a key on the keyboard",
|
|
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
|
+
}),
|
|
36
|
+
type: "input"
|
|
37
|
+
},
|
|
38
|
+
handle: async (tab, params, response) => {
|
|
39
|
+
response.addCode(`// Press ${params.key}`);
|
|
40
|
+
response.addCode(`await page.keyboard.press('${params.key}');`);
|
|
41
|
+
if (params.key === "Enter") {
|
|
42
|
+
response.setIncludeSnapshot();
|
|
43
|
+
await tab.waitForCompletion(async () => {
|
|
44
|
+
await tab.page.keyboard.press("Enter");
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
await tab.page.keyboard.press(params.key);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const pressSequentially = (0, import_tool.defineTabTool)({
|
|
52
|
+
capability: "core-input",
|
|
53
|
+
skillOnly: true,
|
|
54
|
+
schema: {
|
|
55
|
+
name: "browser_press_sequentially",
|
|
56
|
+
title: "Type text key by key",
|
|
57
|
+
description: "Type text key by key on the keyboard",
|
|
58
|
+
inputSchema: import_mcpBundle.z.object({
|
|
59
|
+
text: import_mcpBundle.z.string().describe("Text to type"),
|
|
60
|
+
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)")
|
|
61
|
+
}),
|
|
62
|
+
type: "input"
|
|
63
|
+
},
|
|
64
|
+
handle: async (tab, params, response) => {
|
|
65
|
+
response.addCode(`// Press ${params.text}`);
|
|
66
|
+
response.addCode(`await page.keyboard.type('${params.text}');`);
|
|
67
|
+
await tab.page.keyboard.type(params.text);
|
|
68
|
+
if (params.submit) {
|
|
69
|
+
response.addCode(`await page.keyboard.press('Enter');`);
|
|
70
|
+
response.setIncludeSnapshot();
|
|
71
|
+
await tab.waitForCompletion(async () => {
|
|
72
|
+
await tab.page.keyboard.press("Enter");
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const typeSchema = import_snapshot.elementSchema.extend({
|
|
78
|
+
text: import_mcpBundle.z.string().describe("Text to type into the element"),
|
|
79
|
+
submit: import_mcpBundle.z.boolean().optional().describe("Whether to submit entered text (press Enter after)"),
|
|
80
|
+
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.")
|
|
81
|
+
});
|
|
82
|
+
const type = (0, import_tool.defineTabTool)({
|
|
83
|
+
capability: "core-input",
|
|
84
|
+
schema: {
|
|
85
|
+
name: "browser_type",
|
|
86
|
+
title: "Type text",
|
|
87
|
+
description: "Type text into editable element",
|
|
88
|
+
inputSchema: typeSchema,
|
|
89
|
+
type: "input"
|
|
90
|
+
},
|
|
91
|
+
handle: async (tab, params, response) => {
|
|
92
|
+
const { locator, resolved } = await tab.refLocator(params);
|
|
93
|
+
const secret = tab.context.lookupSecret(params.text);
|
|
94
|
+
await tab.waitForCompletion(async () => {
|
|
95
|
+
if (params.slowly) {
|
|
96
|
+
response.setIncludeSnapshot();
|
|
97
|
+
response.addCode(`await page.${resolved}.pressSequentially(${secret.code});`);
|
|
98
|
+
await locator.pressSequentially(secret.value);
|
|
99
|
+
} else {
|
|
100
|
+
response.addCode(`await page.${resolved}.fill(${secret.code});`);
|
|
101
|
+
await locator.fill(secret.value);
|
|
102
|
+
}
|
|
103
|
+
if (params.submit) {
|
|
104
|
+
response.setIncludeSnapshot();
|
|
105
|
+
response.addCode(`await page.${resolved}.press('Enter');`);
|
|
106
|
+
await locator.press("Enter");
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
const keydown = (0, import_tool.defineTabTool)({
|
|
112
|
+
capability: "core-input",
|
|
113
|
+
skillOnly: true,
|
|
114
|
+
schema: {
|
|
115
|
+
name: "browser_keydown",
|
|
116
|
+
title: "Press a key down",
|
|
117
|
+
description: "Press a key down on the keyboard",
|
|
118
|
+
inputSchema: import_mcpBundle.z.object({
|
|
119
|
+
key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
|
120
|
+
}),
|
|
121
|
+
type: "input"
|
|
122
|
+
},
|
|
123
|
+
handle: async (tab, params, response) => {
|
|
124
|
+
response.addCode(`await page.keyboard.down('${params.key}');`);
|
|
125
|
+
await tab.page.keyboard.down(params.key);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const keyup = (0, import_tool.defineTabTool)({
|
|
129
|
+
capability: "core-input",
|
|
130
|
+
skillOnly: true,
|
|
131
|
+
schema: {
|
|
132
|
+
name: "browser_keyup",
|
|
133
|
+
title: "Press a key up",
|
|
134
|
+
description: "Press a key up on the keyboard",
|
|
135
|
+
inputSchema: import_mcpBundle.z.object({
|
|
136
|
+
key: import_mcpBundle.z.string().describe("Name of the key to press or a character to generate, such as `ArrowLeft` or `a`")
|
|
137
|
+
}),
|
|
138
|
+
type: "input"
|
|
139
|
+
},
|
|
140
|
+
handle: async (tab, params, response) => {
|
|
141
|
+
response.addCode(`await page.keyboard.up('${params.key}');`);
|
|
142
|
+
await tab.page.keyboard.up(params.key);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
var keyboard_default = [
|
|
146
|
+
press,
|
|
147
|
+
type,
|
|
148
|
+
pressSequentially,
|
|
149
|
+
keydown,
|
|
150
|
+
keyup
|
|
151
|
+
];
|
|
@@ -0,0 +1,159 @@
|
|
|
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 mouse_exports = {};
|
|
20
|
+
__export(mouse_exports, {
|
|
21
|
+
default: () => mouse_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mouse_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const mouseMove = (0, import_tool.defineTabTool)({
|
|
27
|
+
capability: "vision",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_mouse_move_xy",
|
|
30
|
+
title: "Move mouse",
|
|
31
|
+
description: "Move mouse to a given position",
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
x: import_mcpBundle.z.number().describe("X coordinate"),
|
|
34
|
+
y: import_mcpBundle.z.number().describe("Y coordinate")
|
|
35
|
+
}),
|
|
36
|
+
type: "input"
|
|
37
|
+
},
|
|
38
|
+
handle: async (tab, params, response) => {
|
|
39
|
+
response.addCode(`// Move mouse to (${params.x}, ${params.y})`);
|
|
40
|
+
response.addCode(`await page.mouse.move(${params.x}, ${params.y});`);
|
|
41
|
+
await tab.waitForCompletion(async () => {
|
|
42
|
+
await tab.page.mouse.move(params.x, params.y);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const mouseDown = (0, import_tool.defineTabTool)({
|
|
47
|
+
capability: "vision",
|
|
48
|
+
schema: {
|
|
49
|
+
name: "browser_mouse_down",
|
|
50
|
+
title: "Press mouse down",
|
|
51
|
+
description: "Press mouse down",
|
|
52
|
+
inputSchema: import_mcpBundle.z.object({
|
|
53
|
+
button: import_mcpBundle.z.enum(["left", "right", "middle"]).optional().describe("Button to press, defaults to left")
|
|
54
|
+
}),
|
|
55
|
+
type: "input"
|
|
56
|
+
},
|
|
57
|
+
handle: async (tab, params, response) => {
|
|
58
|
+
response.addCode(`// Press mouse down`);
|
|
59
|
+
response.addCode(`await page.mouse.down({ button: '${params.button}' });`);
|
|
60
|
+
await tab.page.mouse.down({ button: params.button });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const mouseUp = (0, import_tool.defineTabTool)({
|
|
64
|
+
capability: "vision",
|
|
65
|
+
schema: {
|
|
66
|
+
name: "browser_mouse_up",
|
|
67
|
+
title: "Press mouse up",
|
|
68
|
+
description: "Press mouse up",
|
|
69
|
+
inputSchema: import_mcpBundle.z.object({
|
|
70
|
+
button: import_mcpBundle.z.enum(["left", "right", "middle"]).optional().describe("Button to press, defaults to left")
|
|
71
|
+
}),
|
|
72
|
+
type: "input"
|
|
73
|
+
},
|
|
74
|
+
handle: async (tab, params, response) => {
|
|
75
|
+
response.addCode(`// Press mouse up`);
|
|
76
|
+
response.addCode(`await page.mouse.up({ button: '${params.button}' });`);
|
|
77
|
+
await tab.page.mouse.up({ button: params.button });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const mouseWheel = (0, import_tool.defineTabTool)({
|
|
81
|
+
capability: "vision",
|
|
82
|
+
schema: {
|
|
83
|
+
name: "browser_mouse_wheel",
|
|
84
|
+
title: "Scroll mouse wheel",
|
|
85
|
+
description: "Scroll mouse wheel",
|
|
86
|
+
inputSchema: import_mcpBundle.z.object({
|
|
87
|
+
deltaX: import_mcpBundle.z.number().default(0).describe("X delta"),
|
|
88
|
+
deltaY: import_mcpBundle.z.number().default(0).describe("Y delta")
|
|
89
|
+
}),
|
|
90
|
+
type: "input"
|
|
91
|
+
},
|
|
92
|
+
handle: async (tab, params, response) => {
|
|
93
|
+
response.addCode(`// Scroll mouse wheel`);
|
|
94
|
+
response.addCode(`await page.mouse.wheel(${params.deltaX}, ${params.deltaY});`);
|
|
95
|
+
await tab.page.mouse.wheel(params.deltaX, params.deltaY);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const mouseClick = (0, import_tool.defineTabTool)({
|
|
99
|
+
capability: "vision",
|
|
100
|
+
schema: {
|
|
101
|
+
name: "browser_mouse_click_xy",
|
|
102
|
+
title: "Click",
|
|
103
|
+
description: "Click left mouse button at a given position",
|
|
104
|
+
inputSchema: import_mcpBundle.z.object({
|
|
105
|
+
x: import_mcpBundle.z.number().describe("X coordinate"),
|
|
106
|
+
y: import_mcpBundle.z.number().describe("Y coordinate")
|
|
107
|
+
}),
|
|
108
|
+
type: "input"
|
|
109
|
+
},
|
|
110
|
+
handle: async (tab, params, response) => {
|
|
111
|
+
response.setIncludeSnapshot();
|
|
112
|
+
response.addCode(`// Click mouse at coordinates (${params.x}, ${params.y})`);
|
|
113
|
+
response.addCode(`await page.mouse.move(${params.x}, ${params.y});`);
|
|
114
|
+
response.addCode(`await page.mouse.down();`);
|
|
115
|
+
response.addCode(`await page.mouse.up();`);
|
|
116
|
+
await tab.waitForCompletion(async () => {
|
|
117
|
+
await tab.page.mouse.move(params.x, params.y);
|
|
118
|
+
await tab.page.mouse.down();
|
|
119
|
+
await tab.page.mouse.up();
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const mouseDrag = (0, import_tool.defineTabTool)({
|
|
124
|
+
capability: "vision",
|
|
125
|
+
schema: {
|
|
126
|
+
name: "browser_mouse_drag_xy",
|
|
127
|
+
title: "Drag mouse",
|
|
128
|
+
description: "Drag left mouse button to a given position",
|
|
129
|
+
inputSchema: import_mcpBundle.z.object({
|
|
130
|
+
startX: import_mcpBundle.z.number().describe("Start X coordinate"),
|
|
131
|
+
startY: import_mcpBundle.z.number().describe("Start Y coordinate"),
|
|
132
|
+
endX: import_mcpBundle.z.number().describe("End X coordinate"),
|
|
133
|
+
endY: import_mcpBundle.z.number().describe("End Y coordinate")
|
|
134
|
+
}),
|
|
135
|
+
type: "input"
|
|
136
|
+
},
|
|
137
|
+
handle: async (tab, params, response) => {
|
|
138
|
+
response.setIncludeSnapshot();
|
|
139
|
+
response.addCode(`// Drag mouse from (${params.startX}, ${params.startY}) to (${params.endX}, ${params.endY})`);
|
|
140
|
+
response.addCode(`await page.mouse.move(${params.startX}, ${params.startY});`);
|
|
141
|
+
response.addCode(`await page.mouse.down();`);
|
|
142
|
+
response.addCode(`await page.mouse.move(${params.endX}, ${params.endY});`);
|
|
143
|
+
response.addCode(`await page.mouse.up();`);
|
|
144
|
+
await tab.waitForCompletion(async () => {
|
|
145
|
+
await tab.page.mouse.move(params.startX, params.startY);
|
|
146
|
+
await tab.page.mouse.down();
|
|
147
|
+
await tab.page.mouse.move(params.endX, params.endY);
|
|
148
|
+
await tab.page.mouse.up();
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
var mouse_default = [
|
|
153
|
+
mouseMove,
|
|
154
|
+
mouseClick,
|
|
155
|
+
mouseDrag,
|
|
156
|
+
mouseDown,
|
|
157
|
+
mouseUp,
|
|
158
|
+
mouseWheel
|
|
159
|
+
];
|
|
@@ -0,0 +1,105 @@
|
|
|
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 navigate_exports = {};
|
|
20
|
+
__export(navigate_exports, {
|
|
21
|
+
default: () => navigate_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(navigate_exports);
|
|
24
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_tool = require("./tool");
|
|
26
|
+
const navigate = (0, import_tool.defineTool)({
|
|
27
|
+
capability: "core-navigation",
|
|
28
|
+
schema: {
|
|
29
|
+
name: "browser_navigate",
|
|
30
|
+
title: "Navigate to a URL",
|
|
31
|
+
description: "Navigate to a URL",
|
|
32
|
+
inputSchema: import_mcpBundle.z.object({
|
|
33
|
+
url: import_mcpBundle.z.string().describe("The URL to navigate to")
|
|
34
|
+
}),
|
|
35
|
+
type: "action"
|
|
36
|
+
},
|
|
37
|
+
handle: async (context, params, response) => {
|
|
38
|
+
const tab = await context.ensureTab();
|
|
39
|
+
let url = params.url;
|
|
40
|
+
try {
|
|
41
|
+
new URL(url);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (url.startsWith("localhost"))
|
|
44
|
+
url = "http://" + url;
|
|
45
|
+
else
|
|
46
|
+
url = "https://" + url;
|
|
47
|
+
}
|
|
48
|
+
await tab.navigate(url);
|
|
49
|
+
response.setIncludeSnapshot();
|
|
50
|
+
response.addCode(`await page.goto('${params.url}');`);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const goBack = (0, import_tool.defineTabTool)({
|
|
54
|
+
capability: "core-navigation",
|
|
55
|
+
schema: {
|
|
56
|
+
name: "browser_navigate_back",
|
|
57
|
+
title: "Go back",
|
|
58
|
+
description: "Go back to the previous page in the history",
|
|
59
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
60
|
+
type: "action"
|
|
61
|
+
},
|
|
62
|
+
handle: async (tab, params, response) => {
|
|
63
|
+
await tab.page.goBack();
|
|
64
|
+
response.setIncludeSnapshot();
|
|
65
|
+
response.addCode(`await page.goBack();`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const goForward = (0, import_tool.defineTabTool)({
|
|
69
|
+
capability: "core-navigation",
|
|
70
|
+
skillOnly: true,
|
|
71
|
+
schema: {
|
|
72
|
+
name: "browser_navigate_forward",
|
|
73
|
+
title: "Go forward",
|
|
74
|
+
description: "Go forward to the next page in the history",
|
|
75
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
76
|
+
type: "action"
|
|
77
|
+
},
|
|
78
|
+
handle: async (tab, params, response) => {
|
|
79
|
+
await tab.page.goForward();
|
|
80
|
+
response.setIncludeSnapshot();
|
|
81
|
+
response.addCode(`await page.goForward();`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const reload = (0, import_tool.defineTabTool)({
|
|
85
|
+
capability: "core-navigation",
|
|
86
|
+
skillOnly: true,
|
|
87
|
+
schema: {
|
|
88
|
+
name: "browser_reload",
|
|
89
|
+
title: "Reload the page",
|
|
90
|
+
description: "Reload the current page",
|
|
91
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
92
|
+
type: "action"
|
|
93
|
+
},
|
|
94
|
+
handle: async (tab, params, response) => {
|
|
95
|
+
await tab.page.reload();
|
|
96
|
+
response.setIncludeSnapshot();
|
|
97
|
+
response.addCode(`await page.reload();`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
var navigate_default = [
|
|
101
|
+
navigate,
|
|
102
|
+
goBack,
|
|
103
|
+
goForward,
|
|
104
|
+
reload
|
|
105
|
+
];
|
|
@@ -0,0 +1,92 @@
|
|
|
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 network_exports = {};
|
|
20
|
+
__export(network_exports, {
|
|
21
|
+
default: () => network_default,
|
|
22
|
+
isFetch: () => isFetch,
|
|
23
|
+
renderRequest: () => renderRequest
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(network_exports);
|
|
26
|
+
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
27
|
+
var import_tool = require("./tool");
|
|
28
|
+
const requests = (0, import_tool.defineTabTool)({
|
|
29
|
+
capability: "core",
|
|
30
|
+
schema: {
|
|
31
|
+
name: "browser_network_requests",
|
|
32
|
+
title: "List network requests",
|
|
33
|
+
description: "Returns all network requests since loading the page",
|
|
34
|
+
inputSchema: import_mcpBundle.z.object({
|
|
35
|
+
includeStatic: import_mcpBundle.z.boolean().default(false).describe("Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false."),
|
|
36
|
+
filename: import_mcpBundle.z.string().optional().describe("Filename to save the network requests to. If not provided, requests are returned as text.")
|
|
37
|
+
}),
|
|
38
|
+
type: "readOnly"
|
|
39
|
+
},
|
|
40
|
+
handle: async (tab, params, response) => {
|
|
41
|
+
const requests2 = await tab.requests();
|
|
42
|
+
const text = [];
|
|
43
|
+
for (const request of requests2) {
|
|
44
|
+
if (!params.includeStatic && !isFetch(request) && isSuccessfulResponse(request))
|
|
45
|
+
continue;
|
|
46
|
+
text.push(await renderRequest(request));
|
|
47
|
+
}
|
|
48
|
+
await response.addResult("Network", text.join("\n"), { prefix: "network", ext: "log", suggestedFilename: params.filename });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const networkClear = (0, import_tool.defineTabTool)({
|
|
52
|
+
capability: "core",
|
|
53
|
+
skillOnly: true,
|
|
54
|
+
schema: {
|
|
55
|
+
name: "browser_network_clear",
|
|
56
|
+
title: "Clear network requests",
|
|
57
|
+
description: "Clear all network requests",
|
|
58
|
+
inputSchema: import_mcpBundle.z.object({}),
|
|
59
|
+
type: "readOnly"
|
|
60
|
+
},
|
|
61
|
+
handle: async (tab, params, response) => {
|
|
62
|
+
await tab.clearRequests();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
function isSuccessfulResponse(request) {
|
|
66
|
+
if (request.failure())
|
|
67
|
+
return false;
|
|
68
|
+
const response = request.existingResponse();
|
|
69
|
+
return !!response && response.status() < 400;
|
|
70
|
+
}
|
|
71
|
+
function isFetch(request) {
|
|
72
|
+
return ["fetch", "xhr"].includes(request.resourceType());
|
|
73
|
+
}
|
|
74
|
+
async function renderRequest(request) {
|
|
75
|
+
const response = request.existingResponse();
|
|
76
|
+
const result = [];
|
|
77
|
+
result.push(`[${request.method().toUpperCase()}] ${request.url()}`);
|
|
78
|
+
if (response)
|
|
79
|
+
result.push(`=> [${response.status()}] ${response.statusText()}`);
|
|
80
|
+
else if (request.failure())
|
|
81
|
+
result.push(`=> [FAILED] ${request.failure()?.errorText ?? "Unknown error"}`);
|
|
82
|
+
return result.join(" ");
|
|
83
|
+
}
|
|
84
|
+
var network_default = [
|
|
85
|
+
requests,
|
|
86
|
+
networkClear
|
|
87
|
+
];
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
isFetch,
|
|
91
|
+
renderRequest
|
|
92
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
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 pdf_exports = {};
|
|
20
|
+
__export(pdf_exports, {
|
|
21
|
+
default: () => pdf_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(pdf_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 pdfSchema = import_mcpBundle.z.object({
|
|
28
|
+
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.")
|
|
29
|
+
});
|
|
30
|
+
const pdf = (0, import_tool.defineTabTool)({
|
|
31
|
+
capability: "pdf",
|
|
32
|
+
schema: {
|
|
33
|
+
name: "browser_pdf_save",
|
|
34
|
+
title: "Save as PDF",
|
|
35
|
+
description: "Save page as PDF",
|
|
36
|
+
inputSchema: pdfSchema,
|
|
37
|
+
type: "readOnly"
|
|
38
|
+
},
|
|
39
|
+
handle: async (tab, params, response) => {
|
|
40
|
+
const data = await tab.page.pdf();
|
|
41
|
+
const result = await response.resolveClientFile({ prefix: "page", ext: "pdf", suggestedFilename: params.filename }, "Page as pdf");
|
|
42
|
+
await response.addFileResult(result, data);
|
|
43
|
+
response.addCode(`await page.pdf(${(0, import_utils.formatObject)({ path: result.relativeName })});`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
var pdf_default = [
|
|
47
|
+
pdf
|
|
48
|
+
];
|