From 4b62f68979a8478bd0ca180043c1950f415453bd Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Sun, 25 Jan 2026 11:06:30 -0800 Subject: [PATCH] chore: render nicer config (#1339) --- README.md | 165 ++++++----------------- packages/playwright-mcp/update-readme.js | 34 ++++- 2 files changed, 72 insertions(+), 127 deletions(-) diff --git a/README.md b/README.md index a446f60..d03f244 100644 --- a/README.md +++ b/README.md @@ -324,127 +324,50 @@ Playwright MCP server supports following arguments. They can be provided in the -``` -> npx @playwright/mcp@latest --help - --allowed-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 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 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 or chrome channel to use, - possible values: chrome, firefox, - webkit, msedge. - --caps comma-separated list of additional - capabilities to enable, possible values: - vision, pdf. - --cdp-endpoint CDP endpoint to connect to. - --cdp-header CDP headers to send with the connect - request, multiple can be specified. - --codegen specify the language to use for code - generation, possible values: - "typescript", "none". Default is - "typescript". - --config path to the configuration file. - --console-level level of console messages to return: - "error", "warning", "info", "debug". - Each level includes the messages of more - severe levels. - --device device to emulate, for example: "iPhone - 15" - --executable-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 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 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 to TypeScript file to evaluate on - Playwright page object - --init-script 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 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 to the directory for output files. - --output-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 to listen on for SSE transport. - --proxy-bypass comma-separated domains to bypass proxy, - for example - ".com,chromium.org,.domain.com" - --proxy-server 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 Whether to save the video of the session - into the output directory. For example - "--save-video=800x600" - --secrets 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 when taking snapshots for responses, - specifies the mode to use. Can be - "incremental", "full", or "none". - Default is incremental. - --storage-state path to the storage state file for - isolated sessions. - --test-id-attribute specify the attribute to use for test - ids, defaults to "data-testid" - --timeout-action specify action timeout in milliseconds, - defaults to 5000ms - --timeout-navigation specify navigation timeout in - milliseconds, defaults to 60000ms - --user-agent specify user agent string - --user-data-dir path to the user data directory. If not - specified, a temporary directory will be - created. - --viewport-size specify browser viewport size in pixels, - for example "1280x720" -``` +| Option | Description | +|--------|-------------| +| --allowed-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.
*env* `PLAYWRIGHT_MCP_ALLOWED_HOSTS` | +| --allowed-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.
*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.
*env* `PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS` | +| --blocked-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.
*env* `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` | +| --block-service-workers | block service workers
*env* `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` | +| --browser | browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge.
*env* `PLAYWRIGHT_MCP_BROWSER` | +| --caps | comma-separated list of additional capabilities to enable, possible values: vision, pdf.
*env* `PLAYWRIGHT_MCP_CAPS` | +| --cdp-endpoint | CDP endpoint to connect to.
*env* `PLAYWRIGHT_MCP_CDP_ENDPOINT` | +| --cdp-header | CDP headers to send with the connect request, multiple can be specified.
*env* `PLAYWRIGHT_MCP_CDP_HEADER` | +| --codegen | specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript".
*env* `PLAYWRIGHT_MCP_CODEGEN` | +| --config | path to the configuration file.
*env* `PLAYWRIGHT_MCP_CONFIG` | +| --console-level | level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels.
*env* `PLAYWRIGHT_MCP_CONSOLE_LEVEL` | +| --device | device to emulate, for example: "iPhone 15"
*env* `PLAYWRIGHT_MCP_DEVICE` | +| --executable-path | path to the browser executable.
*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.
*env* `PLAYWRIGHT_MCP_EXTENSION` | +| --grant-permissions | List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write".
*env* `PLAYWRIGHT_MCP_GRANT_PERMISSIONS` | +| --headless | run browser in headless mode, headed by default
*env* `PLAYWRIGHT_MCP_HEADLESS` | +| --host | host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
*env* `PLAYWRIGHT_MCP_HOST` | +| --ignore-https-errors | ignore https errors
*env* `PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS` | +| --init-page | path to TypeScript file to evaluate on Playwright page object
*env* `PLAYWRIGHT_MCP_INIT_PAGE` | +| --init-script | 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.
*env* `PLAYWRIGHT_MCP_INIT_SCRIPT` | +| --isolated | keep the browser profile in memory, do not save it to disk.
*env* `PLAYWRIGHT_MCP_ISOLATED` | +| --image-responses | whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow".
*env* `PLAYWRIGHT_MCP_IMAGE_RESPONSES` | +| --no-sandbox | disable the sandbox for all process types that are normally sandboxed.
*env* `PLAYWRIGHT_MCP_NO_SANDBOX` | +| --output-dir | path to the directory for output files.
*env* `PLAYWRIGHT_MCP_OUTPUT_DIR` | +| --output-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".
*env* `PLAYWRIGHT_MCP_OUTPUT_MODE` | +| --port | port to listen on for SSE transport.
*env* `PLAYWRIGHT_MCP_PORT` | +| --proxy-bypass | comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"
*env* `PLAYWRIGHT_MCP_PROXY_BYPASS` | +| --proxy-server | specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"
*env* `PLAYWRIGHT_MCP_PROXY_SERVER` | +| --save-session | Whether to save the Playwright MCP session into the output directory.
*env* `PLAYWRIGHT_MCP_SAVE_SESSION` | +| --save-trace | Whether to save the Playwright Trace of the session into the output directory.
*env* `PLAYWRIGHT_MCP_SAVE_TRACE` | +| --save-video | Whether to save the video of the session into the output directory. For example "--save-video=800x600"
*env* `PLAYWRIGHT_MCP_SAVE_VIDEO` | +| --secrets | path to a file containing secrets in the dotenv format
*env* `PLAYWRIGHT_MCP_SECRETS` | +| --shared-browser-context | reuse the same browser context between all connected HTTP clients.
*env* `PLAYWRIGHT_MCP_SHARED_BROWSER_CONTEXT` | +| --snapshot-mode | when taking snapshots for responses, specifies the mode to use. Can be "incremental", "full", or "none". Default is incremental.
*env* `PLAYWRIGHT_MCP_SNAPSHOT_MODE` | +| --storage-state | path to the storage state file for isolated sessions.
*env* `PLAYWRIGHT_MCP_STORAGE_STATE` | +| --test-id-attribute | specify the attribute to use for test ids, defaults to "data-testid"
*env* `PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE` | +| --timeout-action | specify action timeout in milliseconds, defaults to 5000ms
*env* `PLAYWRIGHT_MCP_TIMEOUT_ACTION` | +| --timeout-navigation | specify navigation timeout in milliseconds, defaults to 60000ms
*env* `PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION` | +| --user-agent | specify user agent string
*env* `PLAYWRIGHT_MCP_USER_AGENT` | +| --user-data-dir | path to the user data directory. If not specified, a temporary directory will be created.
*env* `PLAYWRIGHT_MCP_USER_DATA_DIR` | +| --viewport-size | specify browser viewport size in pixels, for example "1280x720"
*env* `PLAYWRIGHT_MCP_VIEWPORT_SIZE` | diff --git a/packages/playwright-mcp/update-readme.js b/packages/playwright-mcp/update-readme.js index 01dfc47..77f0794 100644 --- a/packages/playwright-mcp/update-readme.js +++ b/packages/playwright-mcp/update-readme.js @@ -136,14 +136,36 @@ async function updateOptions(content) { 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}
*env* \`${envName}\` |`); + } + const startMarker = ``; const endMarker = ``; - return updateSection(content, startMarker, endMarker, [ - '```', - '> npx @playwright/mcp@latest --help', - ...lines, - '```', - ]); + return updateSection(content, startMarker, endMarker, table); } /**