@wordbricks/playwright-mcp 0.1.12 → 0.1.13

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/config.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import type * as playwright from 'playwright';
17
+ import type * as playwright from 'playwright-core';
18
18
 
19
19
  export type ToolCapability = 'core' | 'core-tabs' | 'core-install' | 'vision' | 'pdf';
20
20
 
package/index.d.ts CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
19
19
  import type { Config } from './config.js';
20
- import type { BrowserContext } from 'playwright';
20
+ import type { BrowserContext } from 'playwright-core';
21
21
 
22
22
  export declare function createConnection(config?: Config, contextGetter?: () => Promise<BrowserContext>): Promise<Server>;
23
23
  export {};
@@ -16,7 +16,7 @@
16
16
  import fs from 'fs';
17
17
  import net from 'net';
18
18
  import path from 'path';
19
- import * as playwright from 'playwright';
19
+ import * as playwright from 'playwright-core';
20
20
  import ms from 'ms';
21
21
  // @ts-ignore
22
22
  import { registryDirectory } from 'playwright-core/lib/server/registry/index';
@@ -146,6 +146,35 @@ class IsolatedContextFactory extends BaseContextFactory {
146
146
  async _doCreateContext(browser) {
147
147
  const browserContext = await browser.newContext(this.config.browser.contextOptions);
148
148
  await applyInitScript(browserContext, this.config);
149
+ await browserContext.addInitScript(() => {
150
+ // Delete the property if it exists
151
+ delete window.__pwInitScripts;
152
+ // Redefine `Object.getOwnPropertyNames`
153
+ const originalGetOwnPropertyNames = Object.getOwnPropertyNames;
154
+ Object.getOwnPropertyNames = (obj) => {
155
+ const props = originalGetOwnPropertyNames(obj);
156
+ return props.filter((prop) => prop !== '__pwInitScripts');
157
+ };
158
+ // Use a Proxy to handle access to `window`
159
+ const windowHandler = {
160
+ get(target, prop) {
161
+ if (prop === '__pwInitScripts')
162
+ return undefined; // Hide the property
163
+ return Reflect.get(target, prop);
164
+ },
165
+ has(target, prop) {
166
+ if (prop === '__pwInitScripts')
167
+ return false; // Prevent detection via "in" operator
168
+ return Reflect.has(target, prop);
169
+ },
170
+ };
171
+ const proxiedWindow = new Proxy(window, windowHandler);
172
+ Object.defineProperty(globalThis, 'window', {
173
+ value: proxiedWindow,
174
+ configurable: false,
175
+ writable: false,
176
+ });
177
+ });
149
178
  return browserContext;
150
179
  }
151
180
  }
package/lib/config.js CHANGED
@@ -16,7 +16,7 @@
16
16
  import fs from 'fs';
17
17
  import os from 'os';
18
18
  import path from 'path';
19
- import { devices } from 'playwright';
19
+ import { devices } from 'playwright-core';
20
20
  import { sanitizeForFilePath } from './utils/fileUtils.js';
21
21
  const defaultConfig = {
22
22
  browser: {
@@ -83,11 +83,9 @@ export function configFromCLIOptions(cliOptions) {
83
83
  if (cliOptions.sandbox === false)
84
84
  launchOptions.chromiumSandbox = false;
85
85
  // Add default Chrome args to avoid automation detection
86
- if (browserName === 'chromium') {
87
- launchOptions.args = launchOptions.args || [];
88
- launchOptions.args.push('--disable-infobars');
89
- launchOptions.args.push('--disable-blink-features=AutomationControlled');
90
- }
86
+ launchOptions.args = launchOptions.args || [];
87
+ launchOptions.args.push('--disable-infobars');
88
+ launchOptions.args.push('--disable-blink-features=AutomationControlled');
91
89
  // --app was passed, add app mode argument
92
90
  if (cliOptions.app) {
93
91
  launchOptions.args = launchOptions.args || [];
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import debug from 'debug';
17
- import * as playwright from 'playwright';
17
+ import * as playwright from 'playwright-core';
18
18
  import { startHttpServer } from '../utils/httpServer.js';
19
19
  import { CDPRelayServer } from './cdpRelay.js';
20
20
  const debugLogger = debug('pw:mcp:relay');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordbricks/playwright-mcp",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Playwright Tools for MCP",
5
5
  "type": "module",
6
6
  "repository": {
@@ -19,12 +19,12 @@
19
19
  "build": "tsc",
20
20
  "build:extension": "tsc --project extension",
21
21
  "dev": "concurrently --raw prefix none \"tsc --watch\" \"DEBUG=pw:mcp:* node --watch=lib cli.js --port 9224\"",
22
- "dev:isolated": "concurrently --raw prefix none \"tsc --watch\" \"DEBUG=pw:mcp:* node --watch=lib cli.js --port 9224 --isolated --viewport-size=1280,720\"",
23
- "dev:isolated:headless": "concurrently --raw prefix none \"tsc --watch\" \"DEBUG=pw:mcp:* node --watch=lib cli.js --port 9224 --isolated --headless --viewport-size=1280,720\"",
22
+ "dev:isolated": "concurrently --raw prefix none \"tsc --watch\" \"DEBUG=pw:mcp:* node --watch=lib cli.js --port 9224 --isolated\"",
23
+ "dev:isolated:headless": "concurrently --raw prefix none \"tsc --watch\" \"DEBUG=pw:mcp:* node --watch=lib cli.js --port 9224 --isolated --headless\"",
24
24
  "dev:vision": "concurrently --raw prefix none \"tsc --watch\" \"DEBUG=pw:mcp:* node --watch=lib cli.js --port 9224 --caps=vision\"",
25
- "start": "node cli.js --port 9224 --viewport-size=1280,720",
26
- "start:isolated": "node cli.js --port 9224 --viewport-size=1280,720 --isolated",
27
- "start:vision": "node cli.js --port 9224 --viewport-size=1280,720 --caps=vision",
25
+ "start": "node cli.js --port 9224",
26
+ "start:isolated": "node cli.js --port 9224 --isolated",
27
+ "start:vision": "node cli.js --port 9224 --caps=vision",
28
28
  "lint": "npm run update-readme && npm run check-deps && eslint . && tsc --noEmit",
29
29
  "lint-fix": "eslint . --fix",
30
30
  "check-deps": "node utils/check-deps.js",
@@ -60,8 +60,7 @@
60
60
  "lodash": "^4.17.21",
61
61
  "mime": "^4.0.7",
62
62
  "ms": "^2.1.3",
63
- "playwright": "npm:rebrowser-playwright@1.52.0",
64
- "playwright-core": "1.52.0",
63
+ "playwright-core": "npm:rebrowser-playwright-core@1.52.0",
65
64
  "raw-body": "^3.0.0",
66
65
  "typescript-parsec": "0.3.4",
67
66
  "ws": "^8.18.1",
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@ import { contextFactory } from './browserContextFactory.js';
20
20
  import * as mcpServer from './mcp/server.js';
21
21
 
22
22
  import type { Config } from '../config.js';
23
- import type { BrowserContext } from 'playwright';
23
+ import type { BrowserContext } from 'playwright-core';
24
24
  import type { BrowserContextFactory } from './browserContextFactory.js';
25
25
  import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
26
26