@szymonrybczak/playwright-mcp 0.0.18 → 0.0.19
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/cjs/index.js
CHANGED
|
@@ -6,7 +6,25 @@ const mcp = require('agents/mcp');
|
|
|
6
6
|
const index = require('./src/index.js');
|
|
7
7
|
|
|
8
8
|
function createMcpAgent(endpoint, options) {
|
|
9
|
-
|
|
9
|
+
let cdpEndpoint;
|
|
10
|
+
if (typeof endpoint === "string") {
|
|
11
|
+
console.log(`[createMcpAgent] Endpoint is a string: ${endpoint}`);
|
|
12
|
+
cdpEndpoint = endpoint;
|
|
13
|
+
} else if (endpoint instanceof URL) {
|
|
14
|
+
console.log(`[createMcpAgent] Endpoint is a URL: ${endpoint.toString()}`);
|
|
15
|
+
cdpEndpoint = endpoint.toString();
|
|
16
|
+
} else {
|
|
17
|
+
console.error(`[createMcpAgent] ERROR: Received a Fetcher object instead of a URL string.`);
|
|
18
|
+
console.error(`[createMcpAgent] Cloudflare Browser Rendering bindings (Fetcher) are not directly compatible with Playwright's connectOverCDP().`);
|
|
19
|
+
console.error(`[createMcpAgent] Please provide a WebSocket CDP endpoint URL string instead.`);
|
|
20
|
+
console.error(`[createMcpAgent] Endpoint type: ${typeof endpoint}`);
|
|
21
|
+
console.error(`[createMcpAgent] Endpoint constructor: ${endpoint?.constructor?.name}`);
|
|
22
|
+
console.error(`[createMcpAgent] Endpoint keys: ${Object.keys(endpoint).join(", ")}`);
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Invalid endpoint type: expected a string URL or URL object, but received a Fetcher object. Cloudflare Browser Rendering bindings are not directly compatible with Playwright's connectOverCDP(). Please provide a WebSocket CDP endpoint URL string (e.g., "ws://localhost:9222") instead.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
console.log(`[createMcpAgent] Creating connection with cdpEndpoint: ${cdpEndpoint}`);
|
|
10
28
|
const connection = index.createConnection({
|
|
11
29
|
capabilities: ["core", "tabs", "pdf", "history", "wait", "files", "testing"],
|
|
12
30
|
browser: {
|
package/lib/esm/index.js
CHANGED
|
@@ -2,7 +2,25 @@ import { McpAgent } from 'agents/mcp';
|
|
|
2
2
|
import { createConnection } from './src/index.js';
|
|
3
3
|
|
|
4
4
|
function createMcpAgent(endpoint, options) {
|
|
5
|
-
|
|
5
|
+
let cdpEndpoint;
|
|
6
|
+
if (typeof endpoint === "string") {
|
|
7
|
+
console.log(`[createMcpAgent] Endpoint is a string: ${endpoint}`);
|
|
8
|
+
cdpEndpoint = endpoint;
|
|
9
|
+
} else if (endpoint instanceof URL) {
|
|
10
|
+
console.log(`[createMcpAgent] Endpoint is a URL: ${endpoint.toString()}`);
|
|
11
|
+
cdpEndpoint = endpoint.toString();
|
|
12
|
+
} else {
|
|
13
|
+
console.error(`[createMcpAgent] ERROR: Received a Fetcher object instead of a URL string.`);
|
|
14
|
+
console.error(`[createMcpAgent] Cloudflare Browser Rendering bindings (Fetcher) are not directly compatible with Playwright's connectOverCDP().`);
|
|
15
|
+
console.error(`[createMcpAgent] Please provide a WebSocket CDP endpoint URL string instead.`);
|
|
16
|
+
console.error(`[createMcpAgent] Endpoint type: ${typeof endpoint}`);
|
|
17
|
+
console.error(`[createMcpAgent] Endpoint constructor: ${endpoint?.constructor?.name}`);
|
|
18
|
+
console.error(`[createMcpAgent] Endpoint keys: ${Object.keys(endpoint).join(", ")}`);
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Invalid endpoint type: expected a string URL or URL object, but received a Fetcher object. Cloudflare Browser Rendering bindings are not directly compatible with Playwright's connectOverCDP(). Please provide a WebSocket CDP endpoint URL string (e.g., "ws://localhost:9222") instead.`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
console.log(`[createMcpAgent] Creating connection with cdpEndpoint: ${cdpEndpoint}`);
|
|
6
24
|
const connection = createConnection({
|
|
7
25
|
capabilities: ["core", "tabs", "pdf", "history", "wait", "files", "testing"],
|
|
8
26
|
browser: {
|