@wordbricks/playwright-mcp 0.1.8 → 0.1.10

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,37 @@ 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
+ // --app was passed, add app mode argument
86
+ if (cliOptions.app) {
87
+ launchOptions.args = launchOptions.args || [];
88
+ launchOptions.args.push(`--app=${cliOptions.app}`);
89
+ }
90
+ // --window-position was passed, add window position argument
91
+ if (cliOptions.windowPosition) {
92
+ try {
93
+ const [x, y] = cliOptions.windowPosition.split(',').map(n => +n);
94
+ if (isNaN(x) || isNaN(y))
95
+ throw new Error('bad values');
96
+ launchOptions.args = launchOptions.args || [];
97
+ launchOptions.args.push(`--window-position=${x},${y}`);
98
+ }
99
+ catch (e) {
100
+ throw new Error('Invalid window position format: use "x,y", for example --window-position="100,200"');
101
+ }
102
+ }
103
+ // --window-size was passed, add window size argument
104
+ if (cliOptions.windowSize) {
105
+ try {
106
+ const [width, height] = cliOptions.windowSize.split(',').map(n => +n);
107
+ if (isNaN(width) || isNaN(height))
108
+ throw new Error('bad values');
109
+ launchOptions.args = launchOptions.args || [];
110
+ launchOptions.args.push(`--window-size=${width},${height}`);
111
+ }
112
+ catch (e) {
113
+ throw new Error('Invalid window size format: use "width,height", for example --window-size="1280,720"');
114
+ }
115
+ }
85
116
  if (cliOptions.proxyServer) {
86
117
  launchOptions.proxy = {
87
118
  server: cliOptions.proxyServer
@@ -121,6 +152,7 @@ export function configFromCLIOptions(cliOptions) {
121
152
  contextOptions,
122
153
  cdpEndpoint: cliOptions.cdpEndpoint,
123
154
  initScript: cliOptions.initScript,
155
+ app: cliOptions.app,
124
156
  },
125
157
  server: {
126
158
  port: cliOptions.port,
@@ -141,6 +173,7 @@ export function configFromCLIOptions(cliOptions) {
141
173
  function configFromEnv() {
142
174
  const options = {};
143
175
  options.allowedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_ALLOWED_ORIGINS);
176
+ options.app = envToString(process.env.PLAYWRIGHT_MCP_APP);
144
177
  options.blockedOrigins = semicolonSeparatedList(process.env.PLAYWRIGHT_MCP_BLOCKED_ORIGINS);
145
178
  options.blockServiceWorkers = envToBoolean(process.env.PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS);
146
179
  options.browser = envToString(process.env.PLAYWRIGHT_MCP_BROWSER);
@@ -166,6 +199,8 @@ function configFromEnv() {
166
199
  options.userAgent = envToString(process.env.PLAYWRIGHT_MCP_USER_AGENT);
167
200
  options.userDataDir = envToString(process.env.PLAYWRIGHT_MCP_USER_DATA_DIR);
168
201
  options.viewportSize = envToString(process.env.PLAYWRIGHT_MCP_VIEWPORT_SIZE);
202
+ options.windowPosition = envToString(process.env.PLAYWRIGHT_MCP_WINDOW_POSITION);
203
+ options.windowSize = envToString(process.env.PLAYWRIGHT_MCP_WINDOW_SIZE);
169
204
  return configFromCLIOptions(options);
170
205
  }
171
206
  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.8",
3
+ "version": "0.1.10",
4
4
  "description": "Playwright Tools for MCP",
5
5
  "type": "module",
6
6
  "repository": {
@@ -61,7 +61,7 @@
61
61
  "mime": "^4.0.7",
62
62
  "ms": "^2.1.3",
63
63
  "playwright": "npm:rebrowser-playwright@1.52.0",
64
- "playwright-core": "npm:rebrowser-playwright@1.52.0",
64
+ "playwright-core": "1.52.0",
65
65
  "raw-body": "^3.0.0",
66
66
  "typescript-parsec": "0.3.4",
67
67
  "ws": "^8.18.1",