> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/microsoft/playwright-mcp/llms.txt
> Use this file to discover all available pages before exploring further.

# API Overview

> Learn about the Playwright MCP programmatic API

The Playwright MCP server provides a programmatic API for integrating browser automation capabilities directly into your Node.js applications. This allows you to embed MCP server functionality without relying on the CLI.

## 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](/installation) 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 the `createConnection` function, which creates an MCP server instance:

```typescript theme={null}
import { createConnection } from '@playwright/mcp';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';

// Create connection with default configuration
const server = await createConnection();

// Create connection with custom configuration
const server = await createConnection({
  browser: {
    launchOptions: { headless: true }
  }
});
```

## Core Components

### createConnection Function

The main entry point for creating an MCP server instance. See [createConnection](/api/create-connection) for detailed documentation.

### Configuration Schema

The `Config` object allows you to customize browser behavior, server settings, timeouts, and capabilities. See [Configuration Schema](/api/configuration) for all available options.

### Tool Capabilities

Control which automation features are enabled by specifying capabilities. See [Tool Capabilities](/api/capabilities) for details on available capability groups.

## Integration Example

Here's how to integrate Playwright MCP into an HTTP server with SSE transport:

```typescript theme={null}
import http from 'http';
import { createConnection } from '@playwright/mcp';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';

http.createServer(async (req, res) => {
  // Create a headless Playwright MCP server with SSE transport
  const connection = await createConnection({
    browser: { launchOptions: { headless: true } }
  });
  const transport = new SSEServerTransport('/messages', res);
  await connection.connect(transport);
}).listen(8931);
```

## Next Steps

* [createConnection](/api/create-connection) - Learn about the main API function
* [Configuration Schema](/api/configuration) - Explore all configuration options
* [Tool Capabilities](/api/capabilities) - Understand capability groups
