@cotestdev/mcp_playwright 0.0.5 → 0.0.9
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/index.d.ts +18 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +17 -29
- package/lib/index.js.map +1 -1
- package/lib/mcp/cli.js +19 -0
- package/lib/mcp/program.js +101 -0
- package/package.json +2 -2
- package/lib/cli.d.ts +0 -8
- package/lib/cli.d.ts.map +0 -1
- package/lib/cli.js +0 -11
- package/lib/cli.js.map +0 -1
- package/lib/server.d.ts +0 -8
- package/lib/server.d.ts.map +0 -1
- package/lib/server.js +0 -27
- package/lib/server.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @cotestdev/mcp_playwright
|
|
18
|
+
* Standalone MCP package for Playwright browser automation
|
|
19
|
+
* The actual CLI entry point is at lib/mcp/cli.js
|
|
8
20
|
*/
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
export * from 'playwright/lib/mcp/sdk/exports';
|
|
12
|
-
export * from 'playwright/lib/mcp/sdk/server';
|
|
21
|
+
declare const _default: {};
|
|
22
|
+
export default _default;
|
|
13
23
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;GAIG;;AAEH,wBAAkB"}
|
package/lib/index.js
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @cotestdev/mcp_playwright
|
|
19
|
+
* Standalone MCP package for Playwright browser automation
|
|
20
|
+
* The actual CLI entry point is at lib/mcp/cli.js
|
|
9
21
|
*/
|
|
10
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
-
}
|
|
16
|
-
Object.defineProperty(o, k2, desc);
|
|
17
|
-
}) : (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
o[k2] = m[k];
|
|
20
|
-
}));
|
|
21
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
-
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.default =
|
|
29
|
-
// Export MCP browser tools
|
|
30
|
-
__exportStar(require("playwright/lib/mcp/browser/tools"), exports);
|
|
31
|
-
var tools_1 = require("playwright/lib/mcp/browser/tools");
|
|
32
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(tools_1).default; } });
|
|
33
|
-
// Export MCP SDK components for server setup
|
|
34
|
-
__exportStar(require("playwright/lib/mcp/sdk/exports"), exports);
|
|
35
|
-
__exportStar(require("playwright/lib/mcp/sdk/server"), exports);
|
|
23
|
+
exports.default = {};
|
|
36
24
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;GAIG;;AAEH,kBAAe,EAAE,CAAC"}
|
package/lib/mcp/cli.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { program } = require('./program');
|
|
19
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,101 @@
|
|
|
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 program_exports = {};
|
|
30
|
+
__export(program_exports, {
|
|
31
|
+
decorateCommand: () => decorateCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(program_exports);
|
|
34
|
+
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
35
|
+
var mcpServer = __toESM(require("./sdk/server"));
|
|
36
|
+
var import_config = require("./browser/config");
|
|
37
|
+
var import_watchdog = require("./browser/watchdog");
|
|
38
|
+
var import_browserContextFactory = require("./browser/browserContextFactory");
|
|
39
|
+
var import_proxyBackend = require("./sdk/proxyBackend");
|
|
40
|
+
var import_browserServerBackend = require("./browser/browserServerBackend");
|
|
41
|
+
var import_extensionContextFactory = require("./extension/extensionContextFactory");
|
|
42
|
+
var import_host = require("./vscode/host");
|
|
43
|
+
function decorateCommand(command, version) {
|
|
44
|
+
command.option("--allowed-origins <origins>", "semicolon-separated list of origins to allow the browser to request. Default is to allow all.", import_config.semicolonSeparatedList).option("--blocked-origins <origins>", "semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed.", import_config.semicolonSeparatedList).option("--block-service-workers", "block service workers").option("--browser <browser>", "browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.").option("--caps <caps>", "comma-separated list of additional capabilities to enable, possible values: vision, pdf.", import_config.commaSeparatedList).option("--cdp-endpoint <endpoint>", "CDP endpoint to connect to.").option("--cdp-header <headers...>", "CDP headers to send with the connect request, multiple can be specified.", import_config.headerParser).option("--config <path>", "path to the configuration file.").option("--device <device>", 'device to emulate, for example: "iPhone 15"').option("--executable-path <path>", "path to the browser executable.").option("--extension", 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').option("--grant-permissions <permissions...>", 'List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".', import_config.commaSeparatedList).option("--headless", "run browser in headless mode, headed by default").option("--host <host>", "host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.").option("--ignore-https-errors", "ignore https errors").option("--init-script <path...>", "path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times.").option("--isolated", "keep the browser profile in memory, do not save it to disk.").option("--image-responses <mode>", 'whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".').option("--no-sandbox", "disable the sandbox for all process types that are normally sandboxed.").option("--output-dir <path>", "path to the directory for output files.").option("--port <port>", "port to listen on for SSE transport.").option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--save-session", "Whether to save the Playwright MCP session into the output directory.").option("--save-trace", "Whether to save the Playwright Trace of the session into the output directory.").option("--secrets <path>", "path to a file containing secrets in the dotenv format", import_config.dotenvFileLoader).option("--shared-browser-context", "reuse the same browser context between all connected HTTP clients.").option("--storage-state <path>", "path to the storage state file for isolated sessions.").option("--timeout-action <timeout>", "specify action timeout in milliseconds, defaults to 5000ms", import_config.numberParser).option("--timeout-navigation <timeout>", "specify navigation timeout in milliseconds, defaults to 60000ms", import_config.numberParser).option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <path>", "path to the user data directory. If not specified, a temporary directory will be created.").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280, 720"').addOption(new import_utilsBundle.ProgramOption("--connect-tool", "Allow to switch between different browser connection methods.").hideHelp()).addOption(new import_utilsBundle.ProgramOption("--vscode", "VS Code tools.").hideHelp()).addOption(new import_utilsBundle.ProgramOption("--vision", "Legacy option, use --caps=vision instead").hideHelp()).action(async (options) => {
|
|
45
|
+
(0, import_watchdog.setupExitWatchdog)();
|
|
46
|
+
if (options.vision) {
|
|
47
|
+
console.error("The --vision option is deprecated, use --caps=vision instead");
|
|
48
|
+
options.caps = "vision";
|
|
49
|
+
}
|
|
50
|
+
const config = await (0, import_config.resolveCLIConfig)(options);
|
|
51
|
+
const browserContextFactory = (0, import_browserContextFactory.contextFactory)(config);
|
|
52
|
+
const extensionContextFactory = new import_extensionContextFactory.ExtensionContextFactory(config.browser.launchOptions.channel || "chrome", config.browser.userDataDir, config.browser.launchOptions.executablePath);
|
|
53
|
+
if (options.extension) {
|
|
54
|
+
const serverBackendFactory = {
|
|
55
|
+
name: "Playwright w/ extension",
|
|
56
|
+
nameInConfig: "playwright-extension",
|
|
57
|
+
version,
|
|
58
|
+
create: () => new import_browserServerBackend.BrowserServerBackend(config, extensionContextFactory)
|
|
59
|
+
};
|
|
60
|
+
await mcpServer.start(serverBackendFactory, config.server);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (options.vscode) {
|
|
64
|
+
await (0, import_host.runVSCodeTools)(config);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (options.connectTool) {
|
|
68
|
+
const providers = [
|
|
69
|
+
{
|
|
70
|
+
name: "default",
|
|
71
|
+
description: "Starts standalone browser",
|
|
72
|
+
connect: () => mcpServer.wrapInProcess(new import_browserServerBackend.BrowserServerBackend(config, browserContextFactory))
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "extension",
|
|
76
|
+
description: "Connect to a browser using the Playwright MCP extension",
|
|
77
|
+
connect: () => mcpServer.wrapInProcess(new import_browserServerBackend.BrowserServerBackend(config, extensionContextFactory))
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
const factory2 = {
|
|
81
|
+
name: "Playwright w/ switch",
|
|
82
|
+
nameInConfig: "playwright-switch",
|
|
83
|
+
version,
|
|
84
|
+
create: () => new import_proxyBackend.ProxyBackend(providers)
|
|
85
|
+
};
|
|
86
|
+
await mcpServer.start(factory2, config.server);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const factory = {
|
|
90
|
+
name: "Playwright",
|
|
91
|
+
nameInConfig: "playwright",
|
|
92
|
+
version,
|
|
93
|
+
create: () => new import_browserServerBackend.BrowserServerBackend(config, browserContextFactory)
|
|
94
|
+
};
|
|
95
|
+
await mcpServer.start(factory, config.server);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
decorateCommand
|
|
101
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotestdev/mcp_playwright",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Playwright MCP (Model Context Protocol) tools for browser automation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"bin": {
|
|
8
|
-
"mcp-playwright": "lib/
|
|
8
|
+
"mcp-playwright": "lib/mcp/cli.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"lib/**/*.js",
|
package/lib/cli.d.ts
DELETED
package/lib/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,QAAA,MAAM,GAAG,KAAqB,CAAC"}
|
package/lib/cli.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* @cotestdev/mcp_playwright CLI Entry Point
|
|
4
|
-
*
|
|
5
|
-
* Provides MCP tools for Playwright browser automation
|
|
6
|
-
*/
|
|
7
|
-
const mcp = require('./index');
|
|
8
|
-
console.log('Playwright MCP Tools Loaded Successfully');
|
|
9
|
-
console.log('Version: 0.0.2');
|
|
10
|
-
console.log('Tools available:', Object.keys(mcp).join(', '));
|
|
11
|
-
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAE/B,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AACxD,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC9B,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
package/lib/server.d.ts
DELETED
package/lib/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAEA;;;;GAIG"}
|
package/lib/server.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* @cotestdev/mcp_playwright Server
|
|
5
|
-
*
|
|
6
|
-
* Standalone MCP server for Playwright browser automation
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
// Start the MCP server
|
|
10
|
-
async function main() {
|
|
11
|
-
try {
|
|
12
|
-
console.log('Starting Playwright MCP Server...');
|
|
13
|
-
console.log('Version: 0.0.2');
|
|
14
|
-
console.log('MCP Tools: execute_playwright_script, dialogs, tabs, and 15+ more');
|
|
15
|
-
console.log('');
|
|
16
|
-
console.log('For integration with MCP clients, use:');
|
|
17
|
-
console.log(' npx @cotestdev/mcp_playwright');
|
|
18
|
-
console.log('');
|
|
19
|
-
console.log('Server is ready to accept connections.');
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
console.error('Failed to start MCP server:', error);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
main().catch(console.error);
|
|
27
|
-
//# sourceMappingURL=server.js.map
|
package/lib/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;AAEA;;;;GAIG;;AAIH,uBAAuB;AACvB,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC;QACjF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|