Skip to main content
Playwright MCP can be embedded directly into your Node.js applications, allowing you to create custom MCP servers or integrate browser automation into existing services.

Installation

First, install the required packages:

Basic Usage

Create a headless Playwright MCP server with SSE transport:

Configuration Options

The createConnection function accepts the same configuration object as the JSON configuration file.

Browser Configuration

Capabilities

Network Filtering

Timeouts

SSE Transport

Server-Sent Events (SSE) transport is used for HTTP-based communication.

Complete SSE Example

Express.js Integration

Advanced Configuration

Using Configuration File

With CDP Endpoint

With Output Configuration

Client Connection

Connect your MCP client to the programmatic server:

Error Handling

Use Cases

Custom MCP Gateway

Build a gateway service that manages multiple Playwright browser instances for different users or tenants.

Integration Server

Embed Playwright MCP into existing services to add browser automation capabilities.

Testing Infrastructure

Create custom test runners that leverage MCP for browser automation.

Automation Platform

Build automation platforms that expose browser control through MCP to various clients.