playwright-stealth-mcp-server 0.0.7 → 0.0.9
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/README.md +28 -0
- package/build/index.js +15 -4
- package/package.json +1 -1
- package/shared/server.d.ts +6 -0
- package/shared/server.js +5 -4
- package/shared/tools.js +6 -1
- package/shared/types.d.ts +6 -0
package/README.md
CHANGED
|
@@ -97,6 +97,7 @@ Add to your Claude Desktop config file:
|
|
|
97
97
|
| `PROXY_PASSWORD` | Proxy authentication password | - |
|
|
98
98
|
| `PROXY_BYPASS` | Comma-separated list of hosts to bypass proxy | - |
|
|
99
99
|
| `BROWSER_PERMISSIONS` | Comma-separated list of browser permissions to grant (see below) | All permissions |
|
|
100
|
+
| `IGNORE_HTTPS_ERRORS` | Ignore HTTPS certificate errors (set to `false` for stricter security) | `true` |
|
|
100
101
|
|
|
101
102
|
## Available Tools
|
|
102
103
|
|
|
@@ -277,6 +278,33 @@ The server supports HTTP/HTTPS proxies with optional authentication, making it c
|
|
|
277
278
|
|
|
278
279
|
**Note:** When proxy is configured, the server performs a health check on startup to verify the proxy connection works. If the health check fails, the server will exit with an error.
|
|
279
280
|
|
|
281
|
+
## HTTPS Certificate Errors
|
|
282
|
+
|
|
283
|
+
By default, the server ignores HTTPS certificate errors (`IGNORE_HTTPS_ERRORS=true`). This is convenient for common automation scenarios:
|
|
284
|
+
|
|
285
|
+
- **Docker environments** where SSL certificates may not match hostnames
|
|
286
|
+
- **Corporate networks** with MITM proxies that re-sign certificates
|
|
287
|
+
- **Self-signed certificates** in development or staging environments
|
|
288
|
+
- **Residential proxies** that perform HTTPS inspection
|
|
289
|
+
|
|
290
|
+
To enable strict certificate validation, set `IGNORE_HTTPS_ERRORS=false`:
|
|
291
|
+
|
|
292
|
+
```json
|
|
293
|
+
{
|
|
294
|
+
"mcpServers": {
|
|
295
|
+
"playwright": {
|
|
296
|
+
"command": "npx",
|
|
297
|
+
"args": ["-y", "playwright-stealth-mcp-server"],
|
|
298
|
+
"env": {
|
|
299
|
+
"IGNORE_HTTPS_ERRORS": "false"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Security Note:** For production environments where certificate validation is important, set `IGNORE_HTTPS_ERRORS=false` to protect against man-in-the-middle attacks.
|
|
307
|
+
|
|
280
308
|
## Browser Permissions
|
|
281
309
|
|
|
282
310
|
By default, the server grants **all** browser permissions to the browser context. This enables testing of features that require permissions such as:
|
package/build/index.js
CHANGED
|
@@ -156,6 +156,11 @@ function validateEnvironment() {
|
|
|
156
156
|
description: 'Comma-separated list of browser permissions to grant. If not set, ALL permissions are granted.',
|
|
157
157
|
defaultValue: 'all (notifications, geolocation, camera, microphone, clipboard-read, etc.)',
|
|
158
158
|
},
|
|
159
|
+
{
|
|
160
|
+
name: 'IGNORE_HTTPS_ERRORS',
|
|
161
|
+
description: 'Ignore HTTPS certificate errors (true/false). Set to false for stricter security.',
|
|
162
|
+
defaultValue: 'true',
|
|
163
|
+
},
|
|
159
164
|
];
|
|
160
165
|
// Log configuration
|
|
161
166
|
const stealthMode = process.env.STEALTH_MODE === 'true';
|
|
@@ -196,6 +201,9 @@ function validateEnvironment() {
|
|
|
196
201
|
else {
|
|
197
202
|
logInfo('config', 'Browser permissions: all (default)');
|
|
198
203
|
}
|
|
204
|
+
if (process.env.IGNORE_HTTPS_ERRORS === 'false') {
|
|
205
|
+
logInfo('config', 'HTTPS certificate validation enabled (strict mode)');
|
|
206
|
+
}
|
|
199
207
|
// Show optional configuration if DEBUG is set
|
|
200
208
|
if (process.env.DEBUG) {
|
|
201
209
|
console.error('\nOptional environment variables:');
|
|
@@ -236,14 +244,17 @@ async function main() {
|
|
|
236
244
|
process.exit(1);
|
|
237
245
|
}
|
|
238
246
|
}
|
|
239
|
-
// Step 5:
|
|
247
|
+
// Step 5: Parse IGNORE_HTTPS_ERRORS setting (default: true)
|
|
248
|
+
const ignoreHttpsErrors = process.env.IGNORE_HTTPS_ERRORS !== 'false';
|
|
249
|
+
// Step 6: Create server using factory, passing proxy config, permissions, and HTTPS error handling
|
|
240
250
|
const { server, registerHandlers, cleanup } = createMCPServer({
|
|
241
251
|
proxy: proxyConfig,
|
|
242
252
|
permissions: browserPermissions,
|
|
253
|
+
ignoreHttpsErrors,
|
|
243
254
|
});
|
|
244
|
-
// Step
|
|
255
|
+
// Step 7: Register all handlers (tools)
|
|
245
256
|
await registerHandlers(server);
|
|
246
|
-
// Step
|
|
257
|
+
// Step 8: Set up graceful shutdown
|
|
247
258
|
const handleShutdown = async () => {
|
|
248
259
|
logWarning('shutdown', 'Received shutdown signal, closing browser...');
|
|
249
260
|
await cleanup();
|
|
@@ -251,7 +262,7 @@ async function main() {
|
|
|
251
262
|
};
|
|
252
263
|
process.on('SIGINT', handleShutdown);
|
|
253
264
|
process.on('SIGTERM', handleShutdown);
|
|
254
|
-
// Step
|
|
265
|
+
// Step 9: Start server with stdio transport
|
|
255
266
|
const transport = new StdioServerTransport();
|
|
256
267
|
await server.connect(transport);
|
|
257
268
|
const stealthMode = process.env.STEALTH_MODE === 'true';
|
package/package.json
CHANGED
package/shared/server.d.ts
CHANGED
|
@@ -78,6 +78,12 @@ export interface CreateMCPServerOptions {
|
|
|
78
78
|
proxy?: ProxyConfig;
|
|
79
79
|
/** Browser permissions to grant. If undefined, all permissions are granted. */
|
|
80
80
|
permissions?: BrowserPermission[];
|
|
81
|
+
/**
|
|
82
|
+
* Whether to ignore HTTPS errors (certificate validation failures).
|
|
83
|
+
* Defaults to true for convenience (Docker, staging environments, self-signed certs).
|
|
84
|
+
* Set to false for strict certificate validation in production environments.
|
|
85
|
+
*/
|
|
86
|
+
ignoreHttpsErrors?: boolean;
|
|
81
87
|
}
|
|
82
88
|
export declare function createMCPServer(options?: CreateMCPServerOptions): {
|
|
83
89
|
server: Server<{
|
package/shared/server.js
CHANGED
|
@@ -72,9 +72,9 @@ export class PlaywrightClient {
|
|
|
72
72
|
// In stealth mode, let the plugin's user-agent-override handle the user agent
|
|
73
73
|
// In non-stealth mode, use the provided user agent if any
|
|
74
74
|
userAgent: this.config.stealthMode ? undefined : this.config.stealthUserAgent,
|
|
75
|
-
// Ignore HTTPS errors
|
|
76
|
-
//
|
|
77
|
-
ignoreHTTPSErrors:
|
|
75
|
+
// Ignore HTTPS errors by default (convenient for Docker, staging environments, self-signed certs)
|
|
76
|
+
// Set IGNORE_HTTPS_ERRORS=false for strict certificate validation in production
|
|
77
|
+
ignoreHTTPSErrors: this.config.ignoreHttpsErrors ?? true,
|
|
78
78
|
});
|
|
79
79
|
// Grant browser permissions (defaults to all permissions if not specified)
|
|
80
80
|
const permissionsToGrant = this.config.permissions ?? [...ALL_BROWSER_PERMISSIONS];
|
|
@@ -211,7 +211,7 @@ export function createMCPServer(options) {
|
|
|
211
211
|
const stealthMode = process.env.STEALTH_MODE === 'true';
|
|
212
212
|
const server = new Server({
|
|
213
213
|
name: 'playwright-stealth-mcp-server',
|
|
214
|
-
version: '0.0.
|
|
214
|
+
version: '0.0.9',
|
|
215
215
|
}, {
|
|
216
216
|
capabilities: {
|
|
217
217
|
tools: {},
|
|
@@ -242,6 +242,7 @@ export function createMCPServer(options) {
|
|
|
242
242
|
stealthMaskLinux,
|
|
243
243
|
stealthLocale,
|
|
244
244
|
permissions: options?.permissions,
|
|
245
|
+
ignoreHttpsErrors: options?.ignoreHttpsErrors,
|
|
245
246
|
});
|
|
246
247
|
return activeClient;
|
|
247
248
|
});
|
package/shared/tools.js
CHANGED
|
@@ -88,7 +88,11 @@ Returns information about the current browser session including the URL, page ti
|
|
|
88
88
|
**Returns:**
|
|
89
89
|
- \`currentUrl\`: Current page URL
|
|
90
90
|
- \`title\`: Current page title
|
|
91
|
-
- \`isOpen\`: Whether a browser session is active
|
|
91
|
+
- \`isOpen\`: Whether a browser session is active
|
|
92
|
+
- \`stealthMode\`: Whether stealth mode is enabled
|
|
93
|
+
- \`headless\`: Whether running in headless mode
|
|
94
|
+
- \`proxyEnabled\`: Whether a proxy is configured
|
|
95
|
+
- \`ignoreHttpsErrors\`: Whether HTTPS certificate errors are being ignored`;
|
|
92
96
|
const CLOSE_DESCRIPTION = `Close the browser session.
|
|
93
97
|
|
|
94
98
|
Shuts down the browser and clears all state. A new browser will be launched on the next execute call.`;
|
|
@@ -270,6 +274,7 @@ export function createRegisterTools(clientFactory) {
|
|
|
270
274
|
stealthMode: config.stealthMode,
|
|
271
275
|
headless: config.headless,
|
|
272
276
|
proxyEnabled: !!config.proxy,
|
|
277
|
+
ignoreHttpsErrors: config.ignoreHttpsErrors ?? true,
|
|
273
278
|
}, null, 2),
|
|
274
279
|
},
|
|
275
280
|
],
|
package/shared/types.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ export interface PlaywrightConfig {
|
|
|
39
39
|
* Use BROWSER_PERMISSIONS env var to constrain permissions (comma-separated list).
|
|
40
40
|
*/
|
|
41
41
|
permissions?: BrowserPermission[];
|
|
42
|
+
/**
|
|
43
|
+
* Whether to ignore HTTPS errors (certificate validation failures).
|
|
44
|
+
* Defaults to true for convenience (Docker, staging environments, self-signed certs).
|
|
45
|
+
* Set to false for strict certificate validation in production environments.
|
|
46
|
+
*/
|
|
47
|
+
ignoreHttpsErrors?: boolean;
|
|
42
48
|
}
|
|
43
49
|
export interface ExecuteResult {
|
|
44
50
|
success: boolean;
|