Playwright
Using Playwright MCP with PraisonAI
Playwright MCP
Playwright 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
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:
npm install @playwright/mcpRunning the Playwright MCP Server
You need to run the Playwright MCP server in a separate terminal before your agent can use it:
npx @playwright/mcp@latest --port 8931This 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:
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:
npx @playwright/mcp@latest --port 8931 --browser chromiumFor more information on available options, refer to the Playwright MCP documentation.