> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Playwright

> Using Playwright MCP with PraisonAI

# Playwright MCP

[Playwright](https://playwright.dev/) is a powerful browser automation tool that can be used with the Model Context Protocol (MCP) to enable agents to interact with web browsers.

## Quick Start

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, MCP

# Connect to Playwright MCP server (run: npx @playwright/mcp@latest --port 8931)
agent = Agent(
    instructions="You help search the web.",
    llm="gpt-4o-mini",
    tools=MCP("http://localhost:8931/sse")
)

agent.start("Find about Praison AI")
```

## Installation

To use Playwright with MCP, you'll need to install the Playwright MCP package:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install @playwright/mcp
```

## Running the Playwright MCP Server

You need to run the Playwright MCP server in a separate terminal before your agent can use it:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npx @playwright/mcp@latest --port 8931
```

This will start a Playwright MCP server on port 8931 that your agent can connect to.

## Using Playwright MCP with PraisonAI

Once the Playwright MCP server is running, you can create an agent that uses it as a tool:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, MCP

search_agent = Agent(
    instructions="""You help search the web.""",
    llm="gpt-4o-mini",
    tools=MCP("http://localhost:8931/sse")
)

search_agent.start("Find about Praison AI")
```

The agent will be able to use Playwright to automate browser interactions and search the web.

## Advanced Configuration

You can customize the Playwright MCP server by passing additional options:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npx @playwright/mcp@latest --port 8931 --browser chromium
```

For more information on available options, refer to the [Playwright MCP documentation](https://github.com/microsoft/playwright/tree/main/packages/mcp).
