@wordbricks/playwright-mcp 0.1.9 → 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 +5 -0
- package/lib/browserServerBackend.js +2 -0
- package/lib/config.js +35 -0
- package/lib/program.js +3 -0
- package/package.json +1 -1
package/config.d.ts
CHANGED
|
@@ -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())
|