@cotestdev/mcp_playwright 0.0.20 → 0.0.22
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/lib/mcp/browser/tools/runCode.js +2 -1
- package/lib/mcp/cli.js +17 -10
- package/lib/mcpBundleImpl/index.js +37 -37
- package/package.json +1 -1
|
@@ -35,7 +35,8 @@ var import_vm = __toESM(require("vm"));
|
|
|
35
35
|
var import_utils = require("playwright-core/lib/utils");
|
|
36
36
|
var import_mcpBundle = require("../../../mcpBundleImpl");
|
|
37
37
|
var import_tool = require("./tool");
|
|
38
|
-
|
|
38
|
+
var import_common = require("./common");
|
|
39
|
+
const codeSchema = import_common.baseSchema.extend({
|
|
39
40
|
code: import_mcpBundle.z.string().describe(`A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: \`async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }\``)
|
|
40
41
|
});
|
|
41
42
|
const runCode = (0, import_tool.defineTabTool)({
|
package/lib/mcp/cli.js
CHANGED
|
@@ -2,25 +2,32 @@
|
|
|
2
2
|
const { decorateCommand } = require('./program');
|
|
3
3
|
const packageJSON = require('../../package.json');
|
|
4
4
|
|
|
5
|
-
// Import program from playwright
|
|
5
|
+
// Import program from playwright-core
|
|
6
6
|
let program;
|
|
7
7
|
try {
|
|
8
8
|
const { program: prog } = require('playwright-core/lib/cli/program');
|
|
9
9
|
program = prog;
|
|
10
10
|
} catch (e) {
|
|
11
|
-
console.error('Failed to load playwright program:', e.message);
|
|
11
|
+
console.error('Failed to load playwright-core program:', e.message);
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
decorateCommand(command, packageJSON.version);
|
|
18
|
-
|
|
19
|
-
// Auto-run the MCP server if no arguments provided
|
|
15
|
+
// Check if the first argument looks like an option (starts with --)
|
|
16
|
+
// If so, treat it as direct MCP server invocation
|
|
20
17
|
const args = process.argv.slice(2);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const firstArg = args[0];
|
|
19
|
+
const isDirectOption = firstArg && (firstArg.startsWith('--') || firstArg === '-h' || firstArg === '--help');
|
|
20
|
+
|
|
21
|
+
// If direct option provided, add 'mcp-server' as the command
|
|
22
|
+
if (isDirectOption) {
|
|
23
|
+
process.argv.splice(2, 0, 'mcp-server');
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Create the mcp-server command with all its options
|
|
27
|
+
const command = program.command('mcp-server');
|
|
28
|
+
command.description('Interact with the browser over MCP');
|
|
29
|
+
|
|
30
|
+
// Apply all MCP options to this command
|
|
31
|
+
decorateCommand(command, packageJSON.version);
|
|
32
|
+
|
|
26
33
|
program.parse(process.argv);
|