Enables browser automation to interact with Google and other websites through natural language commands, including searching, navigation, and taking screenshots.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Playwright MCP AutomationOpen GitHub, search for Playwright docs, and take a screenshot of the results"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π Playwright MCP Automation
Bridge the gap between AI assistants and browser automation β Control Playwright directly from natural language prompts using the Model Context Protocol (MCP).
π Overview
This project integrates Playwright with the Model Context Protocol (MCP), enabling AI tools like GitHub Copilot, Claude Desktop, or Cursor to perform browser automation tasks through simple conversational prompts.
Why MCP + Playwright?
Natural Language Control: Describe what you want instead of writing test code
AI-Powered Testing: Let AI assistants handle browser interactions
Rapid Prototyping: Test ideas without manual script writing
Flexible Automation: Combine vision-based clicking, PDF generation, and assertions
β¨ What You Can Do
Simply ask your AI assistant:
"Open Google and search for Playwright"
"Verify the title contains 'Playwright' and take a screenshot"
"Click the Docs tab and generate a PDF of the page"
"Find the download button using visual recognition and click it"The AI translates your request β MCP Protocol β Browser Actions β Results β¨
No need to run
π Project Structure
Playwright_MCP/
βββ tests/
β βββ mcp-playwright.spec.ts # Example Playwright test suite
βββ scripts/
β βββ run-via-mcp.js # Manual MCP client (optional)
βββ mcp.config.json # MCP server configuration
βββ playwright.config.ts # Playwright configuration
βββ package.json # Dependencies
βββ README.md # This fileπ Getting Started
Prerequisites
Ensure you have the following installed:
Tool | Check Version | Required Version |
Node.js |
| v18.0.0 or higher |
npm |
| Latest stable |
Playwright |
| Latest |
Installation
Clone or navigate to your project directory
Install dependencies
npm installInstall Playwright browsers (if not already installed)
npx playwright install
βοΈ Configuration
MCP Server Setup
The MCP configuration is defined in mcp.config.json:
{
"servers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--caps=vision,pdf,testing,tracing"
],
"env": {}
}
}
}Enabled Capabilities
Capability | Description |
vision | Use coordinates and OCR for element interaction |
Generate PDF snapshots of web pages | |
testing | Run assertions (visibility, text content, values) |
tracing | Collect debug traces for troubleshooting |
π― Usage
Method 1: AI Assistant Integration (Recommended)
Start the MCP server in a terminal:
npx @playwright/mcp@latest --caps=vision,pdf,testing,tracing --output-dir=playwright-mcp-outputYou should see:
Listening on http://localhost:8931β οΈ Keep this terminal running β the MCP server must stay active
Open your AI tool (Claude Desktop, Cursor, GitHub Copilot, etc.)
Issue natural language commands:
"Open google.com, search 'Playwright', verify results appear, and take a screenshot"Watch the magic happen β the AI will:
Connect to your MCP server
Control the browser
Execute the automation
Return results/screenshots
Method 2: Manual MCP Client (Testing)
If you want to test MCP functionality without an AI assistant:
node scripts/run-via-mcp.jsThis script will:
Launch a browser via MCP
Navigate to Google
Search for "Playwright"
Save a screenshot locally
Method 3: Traditional Playwright Tests
Run Playwright tests the standard way (without MCP):
npx playwright test tests/mcp-playwright.spec.tsπ¦ Output & Artifacts
All generated files are saved to:
playwright-mcp-output/Example artifacts:
google-playwright-search.pngβ Screenshotspage.pdfβ PDF exportstrace.zipβ Playwright trace files
π§ Troubleshooting
Issue | Solution |
| Ensure the MCP server is running in a separate terminal |
| Restart the MCP server terminal window |
| Run |
| Kill the existing MCP process or change the port |
| Ensure |
Debug Mode
Run the MCP server with verbose logging:
DEBUG=* npx @playwright/mcp@latest --caps=vision,pdf,testing,tracingπ― Roadmap & Future Enhancements
Automate complex login flows via MCP
Advanced cursor-based interactions
File download verification
Trace log streaming to AI assistants
Multi-browser support (Chromium, Firefox, WebKit)
CI/CD pipeline integration
π€ Contributing
Contributions are welcome! Feel free to:
Report bugs
Suggest new features
Submit pull requests
π License
This project is licensed under the MIT License.
π Resources
Built with β€οΈ using Playwright & MCP
This server cannot be installed
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.