Playwright MCP — Browser Automation for AI Agents
Official Playwright MCP server that gives AI agents full browser control — navigate pages, fill forms, click buttons, take screenshots, and run end-to-end tests. 3,000+ stars.
What it is
Playwright MCP is the official Model Context Protocol server for Playwright browser automation. It gives AI agents like Claude Code full control over web browsers: navigate pages, fill forms, click buttons, extract content, take screenshots, and run end-to-end tests. The agent sees the page structure and can interact with any element through natural language commands.
The server is designed for developers who need AI-assisted web testing, scraping, or workflow automation. It works with Claude Code, Cursor, and any MCP-compatible client. Setup takes under one minute.
How it saves time or tokens
Playwright MCP eliminates the need to write Playwright scripts manually for one-off browser tasks. Instead of writing boilerplate code for navigation, form filling, and assertions, you describe the action in plain English and the agent handles the Playwright API calls. For repetitive QA workflows, this reduces test authoring time significantly. The agent also interprets page structure contextually, reducing the back-and-forth of element selection.
How to use
- Add the Playwright MCP server to your
.mcp.json:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-playwright"]
}
}
}
- Restart Claude Code to load the new server.
- Ask the agent to perform browser tasks in natural language: 'Open https://example.com, take a screenshot, and describe what you see.'
Example
Common interaction patterns with Playwright MCP:
# Navigation
'Open https://github.com/trending'
'Go back to the previous page'
'Wait for the login form to appear'
# Form interaction
'Click the Sign In button'
'Fill the email field with test@example.com'
'Select Monthly from the billing dropdown'
# Content extraction
'Extract all product names and prices from this page'
'Get the text content of the main article'
'List all links on this page'
The agent translates these into Playwright API calls, executes them against the browser, and returns the results.
Related on TokRepo
- MCP Chrome Integration — Alternative browser MCP server using Chrome DevTools Protocol
- AI Tools for Browser Automation — Compare browser automation approaches for AI workflows
Common pitfalls
- The MCP server launches a new browser instance. Websites requiring login will need you to authenticate first or provide session cookies.
- Dynamic SPAs with heavy JavaScript may require explicit wait commands. Tell the agent to 'wait for the content to load' before extracting data.
- Screenshot quality depends on viewport size. Specify dimensions if you need consistent visual output across runs.
Frequently Asked Questions
Playwright MCP uses Playwright under the hood, which supports Chromium, Firefox, and WebKit. By default it launches Chromium, but you can configure it for other browsers depending on your testing needs.
Yes. The content extraction tools let you pull text, links, tables, and structured data from any page. The agent navigates JavaScript-heavy SPAs that static scrapers cannot handle, making it effective for modern web applications.
Playwright MCP uses Microsoft Playwright, which supports multiple browsers and has more robust auto-waiting. Puppeteer MCP uses Google Puppeteer, which is Chromium-only. Playwright MCP generally provides better cross-browser testing support.
Playwright MCP is best for interactive test exploration and one-off automation tasks. For CI/CD pipelines, you would typically generate Playwright scripts from your MCP session and run them directly without the MCP layer.
Yes, but you need to handle authentication. You can ask the agent to fill login forms, or provide pre-authenticated session cookies. For SSO or MFA flows, manual intervention may be needed for the initial authentication step.
Citations (3)
- Playwright MCP GitHub— Playwright MCP server for AI agent browser control
- MCP Documentation— Model Context Protocol specification
- Playwright Docs— Playwright browser automation framework
Related on TokRepo
Source & Thanks
Built on Playwright by Microsoft. Licensed under Apache 2.0.
playwright — ⭐ 70,000+
Thanks to Microsoft and the MCP community for bridging AI agents and browsers.