When to Use the API
Use the programmatic API when you need to:- Integrate Playwright MCP into custom Node.js services
- Create HTTP servers with SSE transport for MCP
- Provide your own browser context management
- Embed browser automation in existing applications
- Deploy Playwright MCP as a standalone service
When to Use CLI Instead
Use the CLI approach when:- Connecting to MCP clients like Claude Desktop, VS Code, or Cursor
- Running browser automation through standard MCP configuration
- You don’t need custom browser context management
- You want the simplest setup process
Basic Usage Pattern
The programmatic API centers around thecreateConnection function, which creates an MCP server instance:
Core Components
createConnection Function
The main entry point for creating an MCP server instance. See createConnection for detailed documentation.Configuration Schema
TheConfig object allows you to customize browser behavior, server settings, timeouts, and capabilities. See Configuration Schema for all available options.
Tool Capabilities
Control which automation features are enabled by specifying capabilities. See Tool Capabilities for details on available capability groups.Integration Example
Here’s how to integrate Playwright MCP into an HTTP server with SSE transport:Next Steps
- createConnection - Learn about the main API function
- Configuration Schema - Explore all configuration options
- Tool Capabilities - Understand capability groups

