Skip to main content
The Config type defines all configuration options for customizing the Playwright MCP server behavior. All fields are optional.

Browser Configuration

browser
object
Browser-related configuration options.

Extension Mode

extension
boolean
Connect to a running browser instance (Edge/Chrome only). If specified, browser config is ignored.Requires the “Playwright MCP Bridge” browser extension to be installed.

Server Configuration

server
object
HTTP server configuration for SSE or MCP transport.

Capabilities

capabilities
ToolCapability[]
List of enabled tool capabilities. See Tool Capabilities for details.Possible values:
  • 'config' - Configuration tools
  • 'core' - Core browser automation features
  • 'core-navigation' - Navigation tools
  • 'core-tabs' - Tab management
  • 'core-input' - Input and interaction tools
  • 'core-install' - Browser installation
  • 'network' - Network request inspection
  • 'pdf' - PDF generation
  • 'storage' - Storage management
  • 'testing' - Test assertions and verification
  • 'vision' - Coordinate-based interactions
  • 'devtools' - Developer tools features

Session Recording

saveSession
boolean
Whether to save the Playwright session into the output directory.
saveTrace
boolean
Whether to save the Playwright trace of the session into the output directory.
saveVideo
object
If specified, saves the Playwright video of the session into the output directory.

Browser Context Sharing

sharedBrowserContext
boolean
Reuse the same browser context between all connected HTTP clients.

Secrets Management

secrets
Record<string, string>
Secrets are used to prevent LLM from getting sensitive data while automating scenarios such as authentication.Note: Prefer browser.contextOptions.storageState over secrets file as a more secure alternative.

Output Configuration

outputDir
string
The directory to save output files (screenshots, PDFs, traces, etc.).
outputMode
'file' | 'stdout'
Whether to save snapshots, console messages, network logs and other session logs to a file or to the standard output. Defaults to 'stdout'.

Console Messages

console
object
Console message configuration.

Network Configuration

network
object
Network request filtering configuration.

Test ID Attribute

testIdAttribute
string
Specify the attribute to use for test ids. Defaults to 'data-testid'.

Timeouts

timeouts
object
Timeout configuration for actions and navigation.

Image Responses

imageResponses
'allow' | 'omit'
Whether to send image responses to the client. Defaults to 'allow'.

Snapshot Configuration

snapshot
object
Page snapshot configuration.

File Access

allowUnrestrictedFileAccess
boolean
Whether to allow file uploads from anywhere on the file system. By default (false), file uploads are restricted to paths within the MCP roots only.

Code Generation

codegen
'typescript' | 'none'
Specify the language to use for code generation. Defaults to 'typescript'.

Complete Example

import { createConnection } from '@playwright/mcp';

const server = await createConnection({
  browser: {
    browserName: 'chromium',
    isolated: false,
    userDataDir: './browser-profile',
    launchOptions: {
      headless: true,
      args: ['--no-sandbox']
    },
    contextOptions: {
      viewport: { width: 1920, height: 1080 },
      userAgent: 'Custom MCP Agent'
    }
  },
  server: {
    port: 8931,
    host: '0.0.0.0'
  },
  capabilities: ['core', 'pdf', 'vision', 'testing'],
  saveTrace: true,
  saveVideo: {
    width: 1280,
    height: 720
  },
  outputDir: './output',
  outputMode: 'file',
  console: {
    level: 'info'
  },
  network: {
    blockedOrigins: ['https://ads.example.com:*']
  },
  timeouts: {
    action: 10000,
    navigation: 30000
  },
  imageResponses: 'allow',
  snapshot: {
    mode: 'incremental'
  },
  codegen: 'typescript'
});