Skip to main content
Playwright MCP server can be configured using command-line arguments, environment variables, or a JSON configuration file.

Command-Line Arguments

All configuration options can be provided as command-line arguments in the args array of your MCP server configuration:

Environment Variables

Every command-line option has a corresponding environment variable with the PLAYWRIGHT_MCP_ prefix:

Configuration File

You can use a JSON configuration file for more complex setups. Specify the file path using the --config option:

Configuration File Schema

Available Options

string
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.Environment variable: PLAYWRIGHT_MCP_ALLOWED_HOSTS
string
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.Environment variable: PLAYWRIGHT_MCP_ALLOWED_ORIGINS
boolean
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.Environment variable: PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS
string
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.Environment variable: PLAYWRIGHT_MCP_BLOCKED_ORIGINS
boolean
Block service workers.Environment variable: PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS
string
Browser or chrome channel to use. Possible values: chrome, firefox, webkit, msedge.Environment variable: PLAYWRIGHT_MCP_BROWSER
string
Comma-separated list of additional capabilities to enable. Possible values: vision, pdf, devtools.Environment variable: PLAYWRIGHT_MCP_CAPS
string
CDP endpoint to connect to.Environment variable: PLAYWRIGHT_MCP_CDP_ENDPOINT
string
CDP headers to send with the connect request. Multiple can be specified.Environment variable: PLAYWRIGHT_MCP_CDP_HEADER
number
Timeout in milliseconds for connecting to CDP endpoint. Defaults to 30000ms.Environment variable: PLAYWRIGHT_MCP_CDP_TIMEOUT
string
Specify the language to use for code generation. Possible values: typescript, none. Default is typescript.Environment variable: PLAYWRIGHT_MCP_CODEGEN
string
Path to the configuration file.Environment variable: PLAYWRIGHT_MCP_CONFIG
string
Level of console messages to return: error, warning, info, debug. Each level includes the messages of more severe levels.Environment variable: PLAYWRIGHT_MCP_CONSOLE_LEVEL
string
Device to emulate, for example: “iPhone 15”.Environment variable: PLAYWRIGHT_MCP_DEVICE
string
Path to the browser executable.Environment variable: PLAYWRIGHT_MCP_EXECUTABLE_PATH
boolean
Connect to a running browser instance (Edge/Chrome only). Requires the “Playwright MCP Bridge” browser extension to be installed.Environment variable: PLAYWRIGHT_MCP_EXTENSION
string
List of permissions to grant to the browser context, for example geolocation, clipboard-read, clipboard-write.Environment variable: PLAYWRIGHT_MCP_GRANT_PERMISSIONS
boolean
Run browser in headless mode. Headed by default.Environment variable: PLAYWRIGHT_MCP_HEADLESS
string
Host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.Environment variable: PLAYWRIGHT_MCP_HOST
boolean
Ignore HTTPS errors.Environment variable: PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS
string
Path to TypeScript file to evaluate on Playwright page object.Environment variable: PLAYWRIGHT_MCP_INIT_PAGE
string
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.Environment variable: PLAYWRIGHT_MCP_INIT_SCRIPT
boolean
Keep the browser profile in memory, do not save it to disk.Environment variable: PLAYWRIGHT_MCP_ISOLATED
string
Whether to send image responses to the client. Can be allow or omit. Defaults to allow.Environment variable: PLAYWRIGHT_MCP_IMAGE_RESPONSES
boolean
Disable the sandbox for all process types that are normally sandboxed.Environment variable: PLAYWRIGHT_MCP_NO_SANDBOX
string
Path to the directory for output files.Environment variable: PLAYWRIGHT_MCP_OUTPUT_DIR
string
Whether to save snapshots, console messages, network logs to a file or to the standard output. Can be file or stdout. Default is stdout.Environment variable: PLAYWRIGHT_MCP_OUTPUT_MODE
number
Port to listen on for SSE transport.Environment variable: PLAYWRIGHT_MCP_PORT
string
Comma-separated domains to bypass proxy, for example “.com,chromium.org,.domain.com”.Environment variable: PLAYWRIGHT_MCP_PROXY_BYPASS
string
Specify proxy server, for example “http://myproxy:3128” or “socks5://myproxy:8080”.Environment variable: PLAYWRIGHT_MCP_PROXY_SERVER
boolean
Enable the sandbox for all process types that are normally not sandboxed.Environment variable: PLAYWRIGHT_MCP_SANDBOX
boolean
Whether to save the Playwright MCP session into the output directory.Environment variable: PLAYWRIGHT_MCP_SAVE_SESSION
boolean
Whether to save the Playwright Trace of the session into the output directory.Environment variable: PLAYWRIGHT_MCP_SAVE_TRACE
string
Whether to save the video of the session into the output directory. For example “—save-video=800x600”.Environment variable: PLAYWRIGHT_MCP_SAVE_VIDEO
string
Path to a file containing secrets in the dotenv format.Environment variable: PLAYWRIGHT_MCP_SECRETS
boolean
Reuse the same browser context between all connected HTTP clients.Environment variable: PLAYWRIGHT_MCP_SHARED_BROWSER_CONTEXT
string
When taking snapshots for responses, specifies the mode to use. Can be incremental, full, or none. Default is incremental.Environment variable: PLAYWRIGHT_MCP_SNAPSHOT_MODE
string
Path to the storage state file for isolated sessions.Environment variable: PLAYWRIGHT_MCP_STORAGE_STATE
string
Specify the attribute to use for test ids. Defaults to “data-testid”.Environment variable: PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE
number
Specify action timeout in milliseconds. Defaults to 5000ms.Environment variable: PLAYWRIGHT_MCP_TIMEOUT_ACTION
number
Specify navigation timeout in milliseconds. Defaults to 60000ms.Environment variable: PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION
string
Specify user agent string.Environment variable: PLAYWRIGHT_MCP_USER_AGENT
string
Path to the user data directory. If not specified, a temporary directory will be created.Environment variable: PLAYWRIGHT_MCP_USER_DATA_DIR
string
Specify browser viewport size in pixels, for example “1280x720”.Environment variable: PLAYWRIGHT_MCP_VIEWPORT_SIZE