mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2026-01-30 06:22:03 +00:00
Compare commits
4 Commits
79111366a9
...
f531b2c9cb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f531b2c9cb | ||
|
|
4b62f68979 | ||
|
|
5b497bcca8 | ||
|
|
00b9c54515 |
167
README.md
167
README.md
@@ -324,127 +324,50 @@ Playwright MCP server supports following arguments. They can be provided in the
|
||||
|
||||
<!--- Options generated by update-readme.js -->
|
||||
|
||||
```
|
||||
> npx @playwright/mcp@latest --help
|
||||
--allowed-hosts <hosts...> comma-separated list of hosts this
|
||||
server is allowed to serve from.
|
||||
Defaults to the host the server is bound
|
||||
to. Pass '*' to disable the host check.
|
||||
--allowed-origins <origins> semicolon-separated list of TRUSTED
|
||||
origins to allow the browser to request.
|
||||
Default is to allow all.
|
||||
Important: *does not* serve as a
|
||||
security boundary and *does not* affect
|
||||
redirects.
|
||||
--allow-unrestricted-file-access allow access to files outside of the
|
||||
workspace roots. Also allows
|
||||
unrestricted access to file:// URLs. By
|
||||
default access to file system is
|
||||
restricted to workspace root directories
|
||||
(or cwd if no roots are configured)
|
||||
only, and navigation to file:// URLs is
|
||||
blocked.
|
||||
--blocked-origins <origins> semicolon-separated list of origins to
|
||||
block the browser from requesting.
|
||||
Blocklist is evaluated before allowlist.
|
||||
If used without the allowlist, requests
|
||||
not matching the blocklist are still
|
||||
allowed.
|
||||
Important: *does not* serve as a
|
||||
security boundary and *does not* affect
|
||||
redirects.
|
||||
--block-service-workers block service workers
|
||||
--browser <browser> browser or chrome channel to use,
|
||||
possible values: chrome, firefox,
|
||||
webkit, msedge.
|
||||
--caps <caps> comma-separated list of additional
|
||||
capabilities to enable, possible values:
|
||||
vision, pdf.
|
||||
--cdp-endpoint <endpoint> CDP endpoint to connect to.
|
||||
--cdp-header <headers...> CDP headers to send with the connect
|
||||
request, multiple can be specified.
|
||||
--codegen <lang> specify the language to use for code
|
||||
generation, possible values:
|
||||
"typescript", "none". Default is
|
||||
"typescript".
|
||||
--config <path> path to the configuration file.
|
||||
--console-level <level> level of console messages to return:
|
||||
"error", "warning", "info", "debug".
|
||||
Each level includes the messages of more
|
||||
severe levels.
|
||||
--device <device> device to emulate, for example: "iPhone
|
||||
15"
|
||||
--executable-path <path> path to the browser executable.
|
||||
--extension Connect to a running browser instance
|
||||
(Edge/Chrome only). Requires the
|
||||
"Playwright MCP Bridge" browser
|
||||
extension to be installed.
|
||||
--grant-permissions <permissions...> List of permissions to grant to the
|
||||
browser context, for example
|
||||
"geolocation", "clipboard-read",
|
||||
"clipboard-write".
|
||||
--headless run browser in headless mode, headed by
|
||||
default
|
||||
--host <host> host to bind server to. Default is
|
||||
localhost. Use 0.0.0.0 to bind to all
|
||||
interfaces.
|
||||
--ignore-https-errors ignore https errors
|
||||
--init-page <path...> path to TypeScript file to evaluate on
|
||||
Playwright page object
|
||||
--init-script <path...> path to JavaScript file to add as an
|
||||
initialization script. The script will
|
||||
be evaluated in every page before any of
|
||||
the page's scripts. Can be specified
|
||||
multiple times.
|
||||
--isolated keep the browser profile in memory, do
|
||||
not save it to disk.
|
||||
--image-responses <mode> whether to send image responses to the
|
||||
client. Can be "allow" or "omit",
|
||||
Defaults to "allow".
|
||||
--no-sandbox disable the sandbox for all process
|
||||
types that are normally sandboxed.
|
||||
--output-dir <path> path to the directory for output files.
|
||||
--output-mode <mode> whether to save snapshots, console
|
||||
messages, network logs to a file or to
|
||||
the standard output. Can be "file" or
|
||||
"stdout". Default is "stdout".
|
||||
--port <port> port to listen on for SSE transport.
|
||||
--proxy-bypass <bypass> comma-separated domains to bypass proxy,
|
||||
for example
|
||||
".com,chromium.org,.domain.com"
|
||||
--proxy-server <proxy> specify proxy server, for example
|
||||
"http://myproxy:3128" or
|
||||
"socks5://myproxy:8080"
|
||||
--save-session Whether to save the Playwright MCP
|
||||
session into the output directory.
|
||||
--save-trace Whether to save the Playwright Trace of
|
||||
the session into the output directory.
|
||||
--save-video <size> Whether to save the video of the session
|
||||
into the output directory. For example
|
||||
"--save-video=800x600"
|
||||
--secrets <path> path to a file containing secrets in the
|
||||
dotenv format
|
||||
--shared-browser-context reuse the same browser context between
|
||||
all connected HTTP clients.
|
||||
--snapshot-mode <mode> when taking snapshots for responses,
|
||||
specifies the mode to use. Can be
|
||||
"incremental", "full", or "none".
|
||||
Default is incremental.
|
||||
--storage-state <path> path to the storage state file for
|
||||
isolated sessions.
|
||||
--test-id-attribute <attribute> specify the attribute to use for test
|
||||
ids, defaults to "data-testid"
|
||||
--timeout-action <timeout> specify action timeout in milliseconds,
|
||||
defaults to 5000ms
|
||||
--timeout-navigation <timeout> specify navigation timeout in
|
||||
milliseconds, defaults to 60000ms
|
||||
--user-agent <ua string> specify user agent string
|
||||
--user-data-dir <path> path to the user data directory. If not
|
||||
specified, a temporary directory will be
|
||||
created.
|
||||
--viewport-size <size> specify browser viewport size in pixels,
|
||||
for example "1280x720"
|
||||
```
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| --allowed-hosts <hosts...> | comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check.<br>*env* `PLAYWRIGHT_MCP_ALLOWED_HOSTS` |
|
||||
| --allowed-origins <origins> | semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all. Important: *does not* serve as a security boundary and *does not* affect redirects.<br>*env* `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` |
|
||||
| --allow-unrestricted-file-access | allow access to files outside of the workspace roots. Also allows unrestricted access to file:// URLs. By default access to file system is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked.<br>*env* `PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS` |
|
||||
| --blocked-origins <origins> | semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: *does not* serve as a security boundary and *does not* affect redirects.<br>*env* `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` |
|
||||
| --block-service-workers | block service workers<br>*env* `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` |
|
||||
| --browser <browser> | browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.<br>*env* `PLAYWRIGHT_MCP_BROWSER` |
|
||||
| --caps <caps> | comma-separated list of additional capabilities to enable, possible values: vision, pdf.<br>*env* `PLAYWRIGHT_MCP_CAPS` |
|
||||
| --cdp-endpoint <endpoint> | CDP endpoint to connect to.<br>*env* `PLAYWRIGHT_MCP_CDP_ENDPOINT` |
|
||||
| --cdp-header <headers...> | CDP headers to send with the connect request, multiple can be specified.<br>*env* `PLAYWRIGHT_MCP_CDP_HEADER` |
|
||||
| --codegen <lang> | specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript".<br>*env* `PLAYWRIGHT_MCP_CODEGEN` |
|
||||
| --config <path> | path to the configuration file.<br>*env* `PLAYWRIGHT_MCP_CONFIG` |
|
||||
| --console-level <level> | level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels.<br>*env* `PLAYWRIGHT_MCP_CONSOLE_LEVEL` |
|
||||
| --device <device> | device to emulate, for example: "iPhone 15"<br>*env* `PLAYWRIGHT_MCP_DEVICE` |
|
||||
| --executable-path <path> | path to the browser executable.<br>*env* `PLAYWRIGHT_MCP_EXECUTABLE_PATH` |
|
||||
| --extension | Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.<br>*env* `PLAYWRIGHT_MCP_EXTENSION` |
|
||||
| --grant-permissions <permissions...> | List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".<br>*env* `PLAYWRIGHT_MCP_GRANT_PERMISSIONS` |
|
||||
| --headless | run browser in headless mode, headed by default<br>*env* `PLAYWRIGHT_MCP_HEADLESS` |
|
||||
| --host <host> | host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.<br>*env* `PLAYWRIGHT_MCP_HOST` |
|
||||
| --ignore-https-errors | ignore https errors<br>*env* `PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS` |
|
||||
| --init-page <path...> | path to TypeScript file to evaluate on Playwright page object<br>*env* `PLAYWRIGHT_MCP_INIT_PAGE` |
|
||||
| --init-script <path...> | path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times.<br>*env* `PLAYWRIGHT_MCP_INIT_SCRIPT` |
|
||||
| --isolated | keep the browser profile in memory, do not save it to disk.<br>*env* `PLAYWRIGHT_MCP_ISOLATED` |
|
||||
| --image-responses <mode> | whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".<br>*env* `PLAYWRIGHT_MCP_IMAGE_RESPONSES` |
|
||||
| --no-sandbox | disable the sandbox for all process types that are normally sandboxed.<br>*env* `PLAYWRIGHT_MCP_NO_SANDBOX` |
|
||||
| --output-dir <path> | path to the directory for output files.<br>*env* `PLAYWRIGHT_MCP_OUTPUT_DIR` |
|
||||
| --output-mode <mode> | whether to save snapshots, console messages, network logs to a file or to the standard output. Can be "file" or "stdout". Default is "stdout".<br>*env* `PLAYWRIGHT_MCP_OUTPUT_MODE` |
|
||||
| --port <port> | port to listen on for SSE transport.<br>*env* `PLAYWRIGHT_MCP_PORT` |
|
||||
| --proxy-bypass <bypass> | comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"<br>*env* `PLAYWRIGHT_MCP_PROXY_BYPASS` |
|
||||
| --proxy-server <proxy> | specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"<br>*env* `PLAYWRIGHT_MCP_PROXY_SERVER` |
|
||||
| --save-session | Whether to save the Playwright MCP session into the output directory.<br>*env* `PLAYWRIGHT_MCP_SAVE_SESSION` |
|
||||
| --save-trace | Whether to save the Playwright Trace of the session into the output directory.<br>*env* `PLAYWRIGHT_MCP_SAVE_TRACE` |
|
||||
| --save-video <size> | Whether to save the video of the session into the output directory. For example "--save-video=800x600"<br>*env* `PLAYWRIGHT_MCP_SAVE_VIDEO` |
|
||||
| --secrets <path> | path to a file containing secrets in the dotenv format<br>*env* `PLAYWRIGHT_MCP_SECRETS` |
|
||||
| --shared-browser-context | reuse the same browser context between all connected HTTP clients.<br>*env* `PLAYWRIGHT_MCP_SHARED_BROWSER_CONTEXT` |
|
||||
| --snapshot-mode <mode> | when taking snapshots for responses, specifies the mode to use. Can be "incremental", "full", or "none". Default is incremental.<br>*env* `PLAYWRIGHT_MCP_SNAPSHOT_MODE` |
|
||||
| --storage-state <path> | path to the storage state file for isolated sessions.<br>*env* `PLAYWRIGHT_MCP_STORAGE_STATE` |
|
||||
| --test-id-attribute <attribute> | specify the attribute to use for test ids, defaults to "data-testid"<br>*env* `PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE` |
|
||||
| --timeout-action <timeout> | specify action timeout in milliseconds, defaults to 5000ms<br>*env* `PLAYWRIGHT_MCP_TIMEOUT_ACTION` |
|
||||
| --timeout-navigation <timeout> | specify navigation timeout in milliseconds, defaults to 60000ms<br>*env* `PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION` |
|
||||
| --user-agent <ua string> | specify user agent string<br>*env* `PLAYWRIGHT_MCP_USER_AGENT` |
|
||||
| --user-data-dir <path> | path to the user data directory. If not specified, a temporary directory will be created.<br>*env* `PLAYWRIGHT_MCP_USER_DATA_DIR` |
|
||||
| --viewport-size <size> | specify browser viewport size in pixels, for example "1280x720"<br>*env* `PLAYWRIGHT_MCP_VIEWPORT_SIZE` |
|
||||
|
||||
<!--- End of options generated section -->
|
||||
|
||||
@@ -492,7 +415,7 @@ state [here](https://playwright.dev/docs/auth).
|
||||
|
||||
**Browser Extension**
|
||||
|
||||
The Playwright MCP Chrome Extension allows you to connect to existing browser tabs and leverage your logged-in sessions and browser state. See [extension/README.md](extension/README.md) for installation and setup instructions.
|
||||
The Playwright MCP Chrome Extension allows you to connect to existing browser tabs and leverage your logged-in sessions and browser state. See [packages/extension/README.md](packages/extension/README.md) for installation and setup instructions.
|
||||
|
||||
### Initial state
|
||||
|
||||
|
||||
36
package-lock.json
generated
36
package-lock.json
generated
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"name": "playwright-mcp-internal",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "playwright-mcp-internal",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"license": "Apache-2.0",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.25.2",
|
||||
"@playwright/test": "1.59.0-alpha-1769217009000",
|
||||
"@playwright/test": "1.59.0-alpha-1769364499000",
|
||||
"@types/node": "^24.3.0"
|
||||
}
|
||||
},
|
||||
@@ -411,13 +411,13 @@
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.59.0-alpha-1769217009000",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.0-alpha-1769217009000.tgz",
|
||||
"integrity": "sha512-6w4Cc5mBxPYPTWR7u7ZKUbpysycKwlLOuKKkzaVpeUGBYi5UVUWFwA0kiHH0sLLfpLoasY9KLUG2uiqNfmi8Aw==",
|
||||
"version": "1.59.0-alpha-1769364499000",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.0-alpha-1769364499000.tgz",
|
||||
"integrity": "sha512-ZJdUgf2B76ph/EML8o4vKmrEIKHHz4Gziqdko7Wfvi69DW3QBXYEs4q3OfwjzK087OQgg961NJeLNV5JMDjZIQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.59.0-alpha-1769217009000"
|
||||
"playwright": "1.59.0-alpha-1769364499000"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
@@ -2120,12 +2120,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.59.0-alpha-1769217009000",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.0-alpha-1769217009000.tgz",
|
||||
"integrity": "sha512-A3TJU5XFNGH7urDr7o170352oCVmlLeo5kJSNeLGtzxcejgIdpBWA2WGP01Fw2WhRk1OrXroAEWD7iA8cMrahg==",
|
||||
"version": "1.59.0-alpha-1769364499000",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.0-alpha-1769364499000.tgz",
|
||||
"integrity": "sha512-b2VEOW/15RnMinGu2Pya3IZIqvhvXv0umx8e+CSpmPeDgA5++MZUNP3glxD+KmeRXY7d8xCktL12P4DTr0PgHA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.59.0-alpha-1769217009000"
|
||||
"playwright-core": "1.59.0-alpha-1769364499000"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
@@ -2138,9 +2138,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.59.0-alpha-1769217009000",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.0-alpha-1769217009000.tgz",
|
||||
"integrity": "sha512-SgO5N9ekEmHnLZh8aTgYt8oA0kaX5aoTbWopLdgJRYYoFPYudcT2a+7yYaVV/hykfVRUXWf+e2lOmr+wl9m8eg==",
|
||||
"version": "1.59.0-alpha-1769364499000",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.0-alpha-1769364499000.tgz",
|
||||
"integrity": "sha512-rztGMf7lfwzVReQrmSXxYhGB3Lnn0b7+YS0O2eR1xnu/KGIJmzy+0ikWO94DbTmG5NtyQNDWhgXbW72VWhc1vg==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
@@ -3320,7 +3320,7 @@
|
||||
},
|
||||
"packages/extension": {
|
||||
"name": "@playwright/mcp-extension",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/chrome": "^0.0.315",
|
||||
@@ -3356,12 +3356,12 @@
|
||||
},
|
||||
"packages/playwright-mcp": {
|
||||
"name": "@playwright/mcp",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.5",
|
||||
"playwright": "1.59.0-alpha-1769217009000",
|
||||
"playwright-core": "1.59.0-alpha-1769217009000"
|
||||
"playwright": "1.59.0-alpha-1769364499000",
|
||||
"playwright-core": "1.59.0-alpha-1769364499000"
|
||||
},
|
||||
"bin": {
|
||||
"mcp": "cli.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "playwright-mcp-internal",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"private": true,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,7 +24,7 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.25.2",
|
||||
"@playwright/test": "1.59.0-alpha-1769217009000",
|
||||
"@playwright/test": "1.59.0-alpha-1769364499000",
|
||||
"@types/node": "^24.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Playwright MCP Bridge",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"description": "Share browser tabs with Playwright MCP server",
|
||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA9nMS2b0WCohjVHPGb8D9qAdkbIngDqoAjTeSccHJijgcONejge+OJxOQOMLu7b0ovt1c9BiEJa5JcpM+EHFVGL1vluBxK71zmBy1m2f9vZF3HG0LSCp7YRkum9rAIEthDwbkxx6XTvpmAY5rjFa/NON6b9Hlbo+8peUSkoOK7HTwYnnI36asZ9eUTiveIf+DMPLojW2UX33vDWG2UKvMVDewzclb4+uLxAYshY7Mx8we/b44xu+Anb/EBLKjOPk9Yh541xJ5Ozc8EiP/5yxOp9c/lRiYUHaRW+4r0HKZyFt0eZ52ti2iM4Nfk7jRXR7an3JPsUIf5deC/1cVM/+1ZQIDAQAB",
|
||||
"permissions": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@playwright/mcp-extension",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"description": "Playwright MCP Browser Extension",
|
||||
"private": true,
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@playwright/mcp",
|
||||
"version": "0.0.58",
|
||||
"version": "0.0.59",
|
||||
"description": "Playwright Tools for MCP",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -35,8 +35,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.5",
|
||||
"playwright": "1.59.0-alpha-1769217009000",
|
||||
"playwright-core": "1.59.0-alpha-1769217009000"
|
||||
"playwright": "1.59.0-alpha-1769364499000",
|
||||
"playwright-core": "1.59.0-alpha-1769364499000"
|
||||
},
|
||||
"bin": {
|
||||
"mcp": "cli.js",
|
||||
|
||||
@@ -128,20 +128,56 @@ async function updateTools(content) {
|
||||
*/
|
||||
async function updateOptions(content) {
|
||||
console.log('Listing options...');
|
||||
const output = execSync('node cli.js --help');
|
||||
execSync('node cli.js --help > help.txt');
|
||||
const output = fs.readFileSync('help.txt');
|
||||
fs.unlinkSync('help.txt');
|
||||
const lines = output.toString().split('\n');
|
||||
const firstLine = lines.findIndex(line => line.includes('--version'));
|
||||
lines.splice(0, firstLine + 1);
|
||||
const lastLine = lines.findIndex(line => line.includes('--help'));
|
||||
lines.splice(lastLine);
|
||||
|
||||
/**
|
||||
* @type {{ name: string, value: string }[]}
|
||||
*/
|
||||
const options = [];
|
||||
for (let line of lines) {
|
||||
if (line.startsWith(' --')) {
|
||||
const l = line.substring(' --'.length);
|
||||
const gapIndex = l.indexOf(' ');
|
||||
const name = l.substring(0, gapIndex).trim();
|
||||
const value = l.substring(gapIndex).trim();
|
||||
options.push({ name, value });
|
||||
} else {
|
||||
const value = line.trim();
|
||||
options[options.length - 1].value += ' ' + value;
|
||||
}
|
||||
}
|
||||
|
||||
const table = [];
|
||||
table.push(`| Option | Description |`);
|
||||
table.push(`|--------|-------------|`);
|
||||
for (const option of options) {
|
||||
const prefix = option.name.split(' ')[0];
|
||||
const envName = `PLAYWRIGHT_MCP_` + prefix.toUpperCase().replace(/-/g, '_');
|
||||
table.push(`| --${option.name} | ${option.value}<br>*env* \`${envName}\` |`);
|
||||
}
|
||||
|
||||
if (process.env.PRINT_ENV) {
|
||||
const envTable = [];
|
||||
envTable.push(`| Environment |`);
|
||||
envTable.push(`|-------------|`);
|
||||
for (const option of options) {
|
||||
const prefix = option.name.split(' ')[0];
|
||||
const envName = `PLAYWRIGHT_MCP_` + prefix.toUpperCase().replace(/-/g, '_');
|
||||
envTable.push(`| \`${envName}\` ${option.value} |`);
|
||||
}
|
||||
console.log(envTable.join('\n'));
|
||||
}
|
||||
|
||||
const startMarker = `<!--- Options generated by ${path.basename(__filename)} -->`;
|
||||
const endMarker = `<!--- End of options generated section -->`;
|
||||
return updateSection(content, startMarker, endMarker, [
|
||||
'```',
|
||||
'> npx @playwright/mcp@latest --help',
|
||||
...lines,
|
||||
'```',
|
||||
]);
|
||||
return updateSection(content, startMarker, endMarker, table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user