@wordbricks/playwright-mcp 0.1.9 → 0.1.11

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
@@ -68,6 +68,11 @@ export type Config = {
68
68
  * Path to a JavaScript file to inject into all pages using addInitScript.
69
69
  */
70
70
  initScript?: string;
71
+
72
+ /**
73
+ * URL to launch in Chrome app mode.
74
+ */
75
+ app?: string;
71
76
  },
72
77
 
73
78
  server?: {
@@ -51,6 +51,8 @@ export class BrowserServerBackend {
51
51
  sessionLog: this._sessionLog,
52
52
  clientInfo: { ...server.getClientVersion(), rootPath },
53
53
  });
54
+ if (this._config.browser.app)
55
+ await this._context.ensureTab();
54
56
  }
55
57
  async listTools() {
56
58
  return this._tools.map(tool => toMcpTool(tool.schema));
package/lib/config.js CHANGED
@@ -82,6 +82,42 @@ export function configFromCLIOptions(cliOptions) {
82
82
  // --no-sandbox was passed, disable the sandbox
83
83
  if (cliOptions.sandbox === false)
84
84
  launchOptions.chromiumSandbox = false;
85
+ // Add default Chrome args to avoid automation detection
86
+ if (browserName === 'chromium') {
87
+ launchOptions.args = launchOptions.args || [];
88
+ launchOptions.args.push('--disable-blink-features=AutomationControlled');
89
+ }
90
+ // --app was passed, add app mode argument
91
+ if (cliOptions.app) {
92
+ launchOptions.args = launchOptions.args || [];
93
+ launchOptions.args.push(`--app=${cliOptions.app}`);
94
+ }
95
+ // --window-position was passed, add window position argument
96
+ if (cliOptions.windowPosition) {
97
+ try {
98
+ const [x, y] = cliOptions.windowPosition.split(',').map(n => +n);
99
+ if (isNaN(x) || isNaN(y))
100
+ throw new Error('bad values');
101
+ launchOptions.args = launchOptions.args || [];
102
+ launchOptions.args.push(`--window-position=${x},${y}`);
103
+ }
104
+ catch (e) {
105
+ throw new Error('Invalid window position format: use "x,y", for example --window-position="100,200"');
106
+ }
107
+ }
108
+ // --window-size was passed, add window size argument
109
+ if (cliOptions.windowSize) {
110
+ try {
111
+ const [width, height] = cliOptions.windowSize.split(',').map(n => +n);
112
+ if (isNaN(width) || isNaN(height))
113
+ throw new Error('bad values');
114
+ launchOptions.args = launchOptions.args || [];
115
+ launchOptions.args.push(`--window-size=${width},${height}`);
116
+ }
117
+ catch (e) {
118
+ throw new Error('Invalid window size format: use "width,height", for example --window-size="1280,720"');
119
+ }
120
+ }
85
121
  if (cliOptions.proxyServer) {
86
122
  launchOptions.proxy = {
87
123
  server: cliOptions.proxyServer
@@ -121,6 +157,7 @@ export function configFromCLIOptions(cliOptions) {
121
157
  contextOptions,
122
158
  cdpEndpoint: cliOptions.cdpEndpoint,
123
159
  initScript: cliOptions.initScript,
160
+ app: cliOptions.app,
124
161
  },
125
162
  server: {
126
163
  port: cliOptions.port,
@@ -141,6 +178,7 @@ export function configFromCLIOptions(cliOptions) {
141
178
  function configFromEnv() {
142
179
  const options = {};
143
180
  options.allowedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_ALLOWED_ORIGINS);
181
+ options.app = envToString(process.env.PLAYWRIGHT_MCP_APP);
144
182
  options.blockedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_BLOCKED_ORIGINS);
145
183
  options.blockServiceWorkers = envToBoolean(process.env.PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS);
146
184
  options.browser = envToString(process.env.PLAYWRIGHT_MCP_BROWSER);
@@ -166,6 +204,8 @@ function configFromEnv() {
166
204
  options.userAgent = envToString(process.env.PLAYWRIGHT_MCP_USER_AGENT);
167
205
  options.userDataDir = envToString(process.env.PLAYWRIGHT_MCP_USER_DATA_DIR);
168
206
  options.viewportSize = envToString(process.env.PLAYWRIGHT_MCP_VIEWPORT_SIZE);
207
+ options.windowPosition = envToString(process.env.PLAYWRIGHT_MCP_WINDOW_POSITION);
208
+ options.windowSize = envToString(process.env.PLAYWRIGHT_MCP_WINDOW_SIZE);
169
209
  return configFromCLIOptions(options);
170
210
  }
171
211
  async function loadConfig(configFile) {
package/lib/program.js CHANGED
@@ -53,6 +53,9 @@ program
53
53
  .option('--user-agent <ua string>', 'specify user agent string')
54
54
  .option('--user-data-dir <path>', 'path to the user data directory. If not specified, a temporary directory will be created.')
55
55
  .option('--viewport-size <size>', 'specify browser viewport size in pixels, for example "1280, 720"')
56
+ .option('--window-position <x,y>', 'specify Chrome window position in pixels, for example "100,200"')
57
+ .option('--window-size <width,height>', 'specify Chrome window size in pixels, for example "1280,720"')
58
+ .option('--app <url>', 'launch browser in app mode with the specified URL')
56
59
  .addOption(new Option('--extension', 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').hideHelp())
57
60
  .addOption(new Option('--connect-tool', 'Allow to switch between different browser connection methods.').hideHelp())
58
61
  .addOption(new Option('--loop-tools', 'Run loop tools').hideHelp())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordbricks/playwright-mcp",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Playwright Tools for MCP",
5
5
  "type": "module",
6
6
  "repository": {