@cotestdev/mcp_playwright 0.0.32 → 0.0.34

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 CHANGED
@@ -1,40 +1,40 @@
1
- # @cotestdeve/mcp_playwright
2
-
3
- Playwright MCP (Model Context Protocol) tools for browser automation.
4
-
5
- This package provides a standalone, published version of Playwright's MCP tools that can be integrated with MCP-compatible applications and AI assistants.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- npm install @cotestdeve/mcp_playwright
11
- ```
12
-
13
- ## Features
14
-
15
- - **execute_playwright_script**: Execute arbitrary Playwright scripts within the MCP context
16
- - **Browser Dialogs**: Handle dialog boxes with automatic code recording
17
- - **Tab Management**: Manage browser tabs and windows with code generation
18
- - **Network Monitoring**: Capture and analyze network requests
19
- - **Page Verification**: Verify page states and elements
20
- - **Form Automation**: Fill and submit forms automatically
21
- - **And 15+ more tools** for complete browser automation
22
-
23
- ## Usage
24
-
25
- ```typescript
26
- import * as mcp_tools from '@cotestdeve/mcp_playwright';
27
-
28
- // Use Playwright MCP tools in your MCP server
29
- const tools = mcp_tools.browserTools;
30
- ```
31
-
32
- ## Related
33
-
34
- - [Official Playwright MCP](https://github.com/microsoft/playwright-mcp)
35
- - [Playwright Documentation](https://playwright.dev)
36
- - [Model Context Protocol](https://modelcontextprotocol.io)
37
-
38
- ## License
39
-
40
- Apache-2.0
1
+ # @cotestdeve/mcp_playwright
2
+
3
+ Playwright MCP (Model Context Protocol) tools for browser automation.
4
+
5
+ This package provides a standalone, published version of Playwright's MCP tools that can be integrated with MCP-compatible applications and AI assistants.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @cotestdeve/mcp_playwright
11
+ ```
12
+
13
+ ## Features
14
+
15
+ - **execute_playwright_script**: Execute arbitrary Playwright scripts within the MCP context
16
+ - **Browser Dialogs**: Handle dialog boxes with automatic code recording
17
+ - **Tab Management**: Manage browser tabs and windows with code generation
18
+ - **Network Monitoring**: Capture and analyze network requests
19
+ - **Page Verification**: Verify page states and elements
20
+ - **Form Automation**: Fill and submit forms automatically
21
+ - **And 15+ more tools** for complete browser automation
22
+
23
+ ## Usage
24
+
25
+ ```typescript
26
+ import * as mcp_tools from '@cotestdeve/mcp_playwright';
27
+
28
+ // Use Playwright MCP tools in your MCP server
29
+ const tools = mcp_tools.browserTools;
30
+ ```
31
+
32
+ ## Related
33
+
34
+ - [Official Playwright MCP](https://github.com/microsoft/playwright-mcp)
35
+ - [Playwright Documentation](https://playwright.dev)
36
+ - [Model Context Protocol](https://modelcontextprotocol.io)
37
+
38
+ ## License
39
+
40
+ Apache-2.0
@@ -178,12 +178,8 @@ class Context {
178
178
  const result = await this._browserContextFactory.createContext(this._clientInfo, this._abortController.signal, this._runningToolName);
179
179
  const { browserContext } = result;
180
180
  if (!this.config.allowUnrestrictedFileAccess) {
181
- if (typeof browserContext._setAllowedProtocols === "function") {
182
- browserContext._setAllowedProtocols(["http:", "https:", "about:", "data:"]);
183
- }
184
- if (typeof browserContext._setAllowedDirectories === "function") {
185
- browserContext._setAllowedDirectories(allRootPaths(this._clientInfo));
186
- }
181
+ browserContext._setAllowedProtocols(["http:", "https:", "about:", "data:"]);
182
+ browserContext._setAllowedDirectories(allRootPaths(this._clientInfo));
187
183
  }
188
184
  await this._setupRequestInterception(browserContext);
189
185
  if (this.sessionLog)
@@ -22,7 +22,7 @@ __export(common_exports, {
22
22
  default: () => common_default
23
23
  });
24
24
  module.exports = __toCommonJS(common_exports);
25
- var import_mcpBundle = require("../../../mcpBundleImpl");
25
+ var import_mcpBundle = require("../../../mcpBundle");
26
26
  var import_tool = require("./tool");
27
27
  const baseSchema = import_mcpBundle.z.object({
28
28
  toolText: import_mcpBundle.z.string().describe("A human-readable description of the action to perform by the tool.")
@@ -21,7 +21,7 @@ __export(console_exports, {
21
21
  default: () => console_default
22
22
  });
23
23
  module.exports = __toCommonJS(console_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  const console = (0, import_tool.defineTabTool)({
27
27
  capability: "core",
@@ -22,7 +22,7 @@ __export(dialogs_exports, {
22
22
  handleDialog: () => handleDialog
23
23
  });
24
24
  module.exports = __toCommonJS(dialogs_exports);
25
- var import_mcpBundle = require("../../../mcpBundleImpl");
25
+ var import_mcpBundle = require("../../../mcpBundle");
26
26
  var import_tool = require("./tool");
27
27
  var import_common = require("./common");
28
28
  const handleDialog = (0, import_tool.defineTabTool)({
@@ -21,7 +21,7 @@ __export(evaluate_exports, {
21
21
  default: () => evaluate_default
22
22
  });
23
23
  module.exports = __toCommonJS(evaluate_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_utils = require("playwright-core/lib/utils");
26
26
  var import_tool = require("./tool");
27
27
  var import_common = require("./common");
@@ -22,7 +22,7 @@ __export(files_exports, {
22
22
  uploadFile: () => uploadFile
23
23
  });
24
24
  module.exports = __toCommonJS(files_exports);
25
- var import_mcpBundle = require("../../../mcpBundleImpl");
25
+ var import_mcpBundle = require("../../../mcpBundle");
26
26
  var import_tool = require("./tool");
27
27
  var import_common = require("./common");
28
28
  const uploadFile = (0, import_tool.defineTabTool)({
@@ -21,7 +21,7 @@ __export(form_exports, {
21
21
  default: () => form_default
22
22
  });
23
23
  module.exports = __toCommonJS(form_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_utils = require("playwright-core/lib/utils");
26
26
  var import_tool = require("./tool");
27
27
  var import_common = require("./common");
@@ -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 import_mcpBundle = require("../../../mcpBundleImpl");
36
+ var import_mcpBundle = require("../../../mcpBundle");
37
37
  var import_tool = require("./tool");
38
38
  const install = (0, import_tool.defineTool)({
39
39
  capability: "core-install",
@@ -21,7 +21,7 @@ __export(keyboard_exports, {
21
21
  default: () => keyboard_default
22
22
  });
23
23
  module.exports = __toCommonJS(keyboard_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  var import_snapshot = require("./snapshot");
27
27
  var import_common = require("./common");
@@ -21,7 +21,7 @@ __export(mouse_exports, {
21
21
  default: () => mouse_default
22
22
  });
23
23
  module.exports = __toCommonJS(mouse_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  const elementSchema = import_mcpBundle.z.object({
27
27
  element: import_mcpBundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element")
@@ -21,7 +21,7 @@ __export(navigate_exports, {
21
21
  default: () => navigate_default
22
22
  });
23
23
  module.exports = __toCommonJS(navigate_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  var import_common = require("./common");
27
27
  const navigate = (0, import_tool.defineTool)({
@@ -21,7 +21,7 @@ __export(network_exports, {
21
21
  default: () => network_default
22
22
  });
23
23
  module.exports = __toCommonJS(network_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  const requests = (0, import_tool.defineTabTool)({
27
27
  capability: "core",
@@ -21,7 +21,7 @@ __export(pdf_exports, {
21
21
  default: () => pdf_default
22
22
  });
23
23
  module.exports = __toCommonJS(pdf_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_utils = require("playwright-core/lib/utils");
26
26
  var import_tool = require("./tool");
27
27
  var import_utils2 = require("./utils");
@@ -34,11 +34,11 @@ module.exports = __toCommonJS(runCode_exports);
34
34
  var import_vm = __toESM(require("vm"));
35
35
  var import_utils = require("playwright-core/lib/utils");
36
36
  var import_test = require("playwright/test");
37
- var import_mcpBundle = require("../../../mcpBundleImpl");
37
+ var import_mcpBundle = require("../../../mcpBundle");
38
38
  var import_tool = require("./tool");
39
39
  var import_common = require("./common");
40
40
  const codeSchema = import_common.baseSchema.extend({
41
- code: import_mcpBundle.z.string().describe(`A Typescript 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(); }\``)
41
+ 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(); }\``)
42
42
  });
43
43
  const runCode = (0, import_tool.defineTabTool)({
44
44
  capability: "core",
@@ -75,7 +75,7 @@ const runCode = (0, import_tool.defineTabTool)({
75
75
  }
76
76
  });
77
77
  const scriptSchema = import_common.baseSchema.extend({
78
- code: import_mcpBundle.z.string().describe(`A Typescript 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(); }\``),
78
+ 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(); }\``),
79
79
  params: import_mcpBundle.z.record(import_mcpBundle.z.any()).optional().describe("Parameters to pass to the script.")
80
80
  });
81
81
  const runScript = (0, import_tool.defineTabTool)({
@@ -36,7 +36,7 @@ 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
38
  var import_utils2 = require("playwright-core/lib/utils");
39
- var import_mcpBundle = require("../../../mcpBundleImpl");
39
+ var import_mcpBundle = require("../../../mcpBundle");
40
40
  var import_tool = require("./tool");
41
41
  var import_utils3 = require("./utils");
42
42
  var import_common = require("./common");
@@ -33,7 +33,7 @@ __export(snapshot_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(snapshot_exports);
35
35
  var import_fs = __toESM(require("fs"));
36
- var import_mcpBundle = require("../../../mcpBundleImpl");
36
+ var import_mcpBundle = require("../../../mcpBundle");
37
37
  var import_utils = require("playwright-core/lib/utils");
38
38
  var import_tool = require("./tool");
39
39
  var import_common = require("./common");
@@ -21,7 +21,7 @@ __export(tabs_exports, {
21
21
  default: () => tabs_default
22
22
  });
23
23
  module.exports = __toCommonJS(tabs_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  var import_common = require("./common");
27
27
  const browserTabs = (0, import_tool.defineTool)({
@@ -21,7 +21,7 @@ __export(tracing_exports, {
21
21
  default: () => tracing_default
22
22
  });
23
23
  module.exports = __toCommonJS(tracing_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  const tracingStart = (0, import_tool.defineTool)({
27
27
  capability: "tracing",
@@ -21,7 +21,7 @@ __export(verify_exports, {
21
21
  default: () => verify_default
22
22
  });
23
23
  module.exports = __toCommonJS(verify_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_utils = require("playwright-core/lib/utils");
26
26
  var import_tool = require("./tool");
27
27
  var import_common = require("./common");
@@ -21,7 +21,7 @@ __export(wait_exports, {
21
21
  default: () => wait_default
22
22
  });
23
23
  module.exports = __toCommonJS(wait_exports);
24
- var import_mcpBundle = require("../../../mcpBundleImpl");
24
+ var import_mcpBundle = require("../../../mcpBundle");
25
25
  var import_tool = require("./tool");
26
26
  var import_common = require("./common");
27
27
  const wait = (0, import_tool.defineTool)({
package/lib/mcp/cli.js CHANGED
@@ -14,12 +14,11 @@ try {
14
14
 
15
15
  // Check if the first argument looks like an option (starts with --)
16
16
  // If so, treat it as direct MCP server invocation
17
- // If no arguments provided, default to MCP server
18
17
  const args = process.argv.slice(2);
19
18
  const firstArg = args[0];
20
- const isDirectOption = !firstArg || firstArg.startsWith('--') || firstArg === '-h' || firstArg === '--help';
19
+ const isDirectOption = firstArg && (firstArg.startsWith('--') || firstArg === '-h' || firstArg === '--help');
21
20
 
22
- // If no arguments or direct option provided, add 'mcp-server' as the command
21
+ // If direct option provided, add 'mcp-server' as the command
23
22
  if (isDirectOption) {
24
23
  process.argv.splice(2, 0, 'mcp-server');
25
24
  }
@@ -43,7 +43,7 @@ __export(bundle_exports, {
43
43
  zodToJsonSchema: () => zodToJsonSchema
44
44
  });
45
45
  module.exports = __toCommonJS(bundle_exports);
46
- var bundle = __toESM(require("../../mcpBundleImpl"));
46
+ var bundle = __toESM(require("../../mcpBundle"));
47
47
  const zodToJsonSchema = bundle.zodToJsonSchema;
48
48
  const Client = bundle.Client;
49
49
  const Server = bundle.Server;
@@ -35,7 +35,7 @@ module.exports = __toCommonJS(http_exports);
35
35
  var import_assert = __toESM(require("assert"));
36
36
  var import_crypto = __toESM(require("crypto"));
37
37
  var import_utilsBundle = require("playwright-core/lib/utilsBundle");
38
- var mcpBundle = __toESM(require("../../mcpBundleImpl"));
38
+ var mcpBundle = __toESM(require("../../mcpBundle"));
39
39
  var import_utils = require("playwright-core/lib/utils");
40
40
  var mcpServer = __toESM(require("./server"));
41
41
  const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
@@ -39,7 +39,7 @@ __export(server_exports, {
39
39
  module.exports = __toCommonJS(server_exports);
40
40
  var import_url = require("url");
41
41
  var import_utilsBundle = require("playwright-core/lib/utilsBundle");
42
- var mcpBundle = __toESM(require("../../mcpBundleImpl"));
42
+ var mcpBundle = __toESM(require("../../mcpBundle"));
43
43
  var import_http = require("./http");
44
44
  var import_inProcessTransport = require("./inProcessTransport");
45
45
  const serverDebug = (0, import_utilsBundle.debug)("pw:mcp:server");
@@ -22,13 +22,13 @@ __export(tool_exports, {
22
22
  toMcpTool: () => toMcpTool
23
23
  });
24
24
  module.exports = __toCommonJS(tool_exports);
25
- var import_mcpBundle = require("../../mcpBundleImpl");
25
+ var import_mcpBundle = require("../../mcpBundle");
26
26
  function toMcpTool(tool) {
27
27
  const readOnly = tool.type === "readOnly" || tool.type === "assertion";
28
28
  return {
29
29
  name: tool.name,
30
30
  description: tool.description,
31
- inputSchema: import_mcpBundle.z.toJSONSchema(tool.inputSchema),
31
+ inputSchema: import_mcpBundle.zodToJsonSchema(tool.inputSchema),
32
32
  annotations: {
33
33
  title: tool.title,
34
34
  readOnlyHint: readOnly,
@@ -35,7 +35,7 @@ __export(generatorTools_exports, {
35
35
  module.exports = __toCommonJS(generatorTools_exports);
36
36
  var import_fs = __toESM(require("fs"));
37
37
  var import_path = __toESM(require("path"));
38
- var import_mcpBundle = require("../../mcpBundleImpl");
38
+ var import_mcpBundle = require("../../mcpBundle");
39
39
  var import_testTool = require("./testTool");
40
40
  var import_testContext = require("./testContext");
41
41
  const setupPage = (0, import_testTool.defineTestTool)({
@@ -35,7 +35,7 @@ __export(plannerTools_exports, {
35
35
  module.exports = __toCommonJS(plannerTools_exports);
36
36
  var import_fs = __toESM(require("fs"));
37
37
  var import_path = __toESM(require("path"));
38
- var import_mcpBundle = require("../../mcpBundleImpl");
38
+ var import_mcpBundle = require("../../mcpBundle");
39
39
  var import_testTool = require("./testTool");
40
40
  const setupPage = (0, import_testTool.defineTestTool)({
41
41
  schema: {
@@ -31,7 +31,7 @@ __export(testBackend_exports, {
31
31
  TestServerBackend: () => TestServerBackend
32
32
  });
33
33
  module.exports = __toCommonJS(testBackend_exports);
34
- var import_mcpBundle = require("../../mcpBundleImpl");
34
+ var import_mcpBundle = require("../../mcpBundle");
35
35
  var mcp = __toESM(require("../sdk/exports"));
36
36
  var import_testContext = require("./testContext");
37
37
  var testTools = __toESM(require("./testTools.js"));
@@ -33,7 +33,7 @@ __export(testTools_exports, {
33
33
  runTests: () => runTests
34
34
  });
35
35
  module.exports = __toCommonJS(testTools_exports);
36
- var import_mcpBundle = require("../../mcpBundleImpl");
36
+ var import_mcpBundle = require("../../mcpBundle");
37
37
  var import_listModeReporter = __toESM(require("../../reporters/listModeReporter"));
38
38
  var import_testTool = require("./testTool");
39
39
  const listTests = (0, import_testTool.defineTestTool)({
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "name": "@cotestdev/mcp_playwright",
3
- "version": "0.0.32",
4
- "description": "Playwright MCP (Model Context Protocol) tools for browser automation",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "bin": {
8
- "mcp-playwright": "lib/mcp/cli.js"
9
- },
10
- "files": [
11
- "lib/**/*.js",
12
- "lib/**/*.d.ts",
13
- "lib/**/*.map"
14
- ],
15
- "scripts": {
16
- "build": "tsc && node scripts/copy-mcp-tools.js",
17
- "start": "node lib/mcp/cli.js"
18
- },
19
- "keywords": [
20
- "playwright",
21
- "mcp",
22
- "browser-automation",
23
- "model-context-protocol"
24
- ],
25
- "author": "",
26
- "license": "Apache-2.0",
27
- "dependencies": {
28
- "playwright": "^1.40.0"
29
- },
30
- "devDependencies": {
31
- "@types/node": "^20.0.0",
32
- "typescript": "^5.0.0"
33
- }
34
- }
1
+ {
2
+ "name": "@cotestdev/mcp_playwright",
3
+ "version": "0.0.34",
4
+ "description": "Playwright MCP (Model Context Protocol) tools for browser automation",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "bin": {
8
+ "mcp-playwright": "lib/mcp/cli.js"
9
+ },
10
+ "files": [
11
+ "lib/**/*.js",
12
+ "lib/**/*.d.ts",
13
+ "lib/**/*.map"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc && node scripts/copy-mcp-tools.js",
17
+ "start": "node lib/program.js"
18
+ },
19
+ "keywords": [
20
+ "playwright",
21
+ "mcp",
22
+ "browser-automation",
23
+ "model-context-protocol"
24
+ ],
25
+ "author": "",
26
+ "license": "Apache-2.0",
27
+ "dependencies": {
28
+ "playwright": "^1.40.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^20.0.0",
32
+ "typescript": "^5.0.0"
33
+ }
34
+ }