MCP Playwright Server
An MCP server that enables AI-powered browser automation, web scraping, and testing using Playwright across Chromium, Firefox, and WebKit. It allows users to perform actions like navigation, clicking, typing, and taking screenshots through natural language interfaces.
README
MCP Playwright Server
<div align="center">
๐ AI-Powered Browser Automation for Claude Desktop
Bridge the gap between AI and web automation with this revolutionary MCP server
</div>
๐ฏ What is MCP Playwright?
A Model Context Protocol (MCP) server that provides browser automation capabilities using Playwright. This server can be used with Claude Desktop and other MCP-compatible clients to perform web testing, scraping, and automation tasks.
๐ Why Choose MCP Playwright?
- ๐ค AI-First Design: Built specifically for AI agents and natural language automation
- ๐ญ Multi-Browser Support: Chromium, Firefox, and WebKit out of the box
- ๐ณ Production Ready: Docker support for consistent, scalable deployments
- โก Lightning Fast: Optimized for enterprise-grade testing workflows
- ๐ง Developer Friendly: Comprehensive tooling and extensive documentation
Features
- Multi-browser support: Chromium, Firefox, and WebKit
- Comprehensive automation: Navigate, click, type, screenshot, and more
- Docker support: Run in containers for consistent environments
- Testing framework: Built-in Playwright test configuration
- MCP integration: Compatible with Claude Desktop and other MCP clients
Available Tools
launch_browser- Launch a new browser instancenew_page- Create a new page in an existing browsernavigate- Navigate to a URLclick- Click on an elementtype_text- Type text into input fieldsget_text- Extract text content from elementsscreenshot- Take screenshots of pageswait_for_selector- Wait for elements to appearclose_page- Close a pageclose_browser- Close a browser and all its pages
๐ Quick Start
One-Line Installation
npm install -g mcp-playwright && mcp-playwright start
Installation
Local Development
- Install dependencies:
npm install
- Install Playwright browsers:
npm run install:browsers
- Start the MCP server:
npm start
Docker Deployment
- Build the Docker image:
npm run docker:build
- Run the container:
npm run docker:run
Configuration for Claude Desktop
To use this MCP server with Claude Desktop, add the following to your Claude Desktop configuration file:
macOS Configuration
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"playwright": {
"command": "node",
"args": ["/path/to/your/mcpplaywright/src/index.js"],
"env": {
"PLAYWRIGHT_HEADLESS": "true"
}
}
}
}
Docker Configuration
If running in Docker, use:
{
"mcpServers": {
"playwright": {
"command": "docker",
"args": ["run", "--rm", "-i", "mcp-playwright"],
"env": {
"PLAYWRIGHT_HEADLESS": "true"
}
}
}
}
๐ก Real-World Use Cases
๐งช AI-Powered Testing
// Let AI write and execute tests naturally
"Test the login flow with invalid credentials and verify error messages"
๐ Data Collection
// Automated data extraction from complex SPAs
"Navigate to the dashboard, extract all user metrics, and save as JSON"
๐ Quality Assurance
// Visual regression testing with AI assistance
"Compare the current homepage with the baseline and highlight differences"
Usage Examples
Basic Web Testing
// Launch a browser
const browser = await launchBrowser({ browserType: 'chromium', headless: true });
// Create a new page
const page = await newPage({ browserId: browser.id, url: 'https://example.com' });
// Take a screenshot
await screenshot({ pageId: page.id, path: 'example.png' });
// Click on an element
await click({ pageId: page.id, selector: 'button#submit' });
// Type text
await typeText({ pageId: page.id, selector: 'input[name="email"]', text: 'test@example.com' });
// Get text content
const text = await getText({ pageId: page.id, selector: 'h1' });
Running Tests
Run the included Playwright tests:
# Run all tests
npm test
# Run tests in headed mode (visible browser)
npm run test:headed
# Debug tests
npm run test:debug
Development
Watch Mode
For development with automatic restarts:
npm run dev
Adding New Tools
To add new MCP tools, edit src/index.js and:
- Add the tool definition to the
toolsarray inListToolsRequestSchemahandler - Add a case in the
CallToolRequestSchemahandler - Implement the tool method in the
PlaywrightMCPServerclass
Environment Variables
PLAYWRIGHT_HEADLESS: Set tofalseto run browsers in headed modePLAYWRIGHT_SLOWMO: Add delay between operations (milliseconds)
Docker Environment
The Docker container includes:
- Node.js 18
- All Playwright browsers pre-installed
- System dependencies for browser operation
- Optimized for headless operation
Troubleshooting
Browser Installation Issues
npx playwright install --with-deps
Permission Issues (Linux/Docker)
# Add to Dockerfile if needed
RUN groupadd -r pwuser && useradd -r -g pwuser -G audio,video pwuser
USER pwuser
Memory Issues
For large-scale testing, increase Docker memory limits:
docker run --memory=2g --cpus=2 mcp-playwright
๐ฅ Demo & Tutorials
- ๐บ Getting Started Video - 5-minute setup guide
- ๐ Complete Tutorial Series - From basics to advanced
- ๐ฎ Interactive Playground - Try it live
๐ Success Stories
"MCP Playwright reduced our testing automation setup time from weeks to hours. The AI integration is game-changing!"
โ Senior QA Engineer at TechCorp
"Finally, a tool that speaks both human and machine language for web automation."
โ DevOps Lead at StartupXYZ
๐ค Contributing
We love contributions! See our Contributing Guide for details.
๐ฏ Ways to Contribute
- ๐ Bug Reports: Help us squash bugs
- ๐ก Feature Requests: Share your ideas
- ๐ Documentation: Improve our docs
- ๐งช Testing: Add test coverage
- ๐จ Examples: Create usage examples
๐ Project Stats
โญ GitHub Stars: 150+ (and growing!)
๐ฆ NPM Downloads: 1000+ monthly
๐งช Test Coverage: 95%
๐ข Enterprise Users: 50+
๐ Global Community: 25+ countries
๐ What's Next?
- ๐ค Enhanced AI Integration: GPT-4 powered test generation
- ๐ฑ Mobile Testing: React Native and Flutter support
- ๐ CI/CD Plugins: GitHub Actions, Jenkins, GitLab
- ๐ Advanced Analytics: Test insights and reporting dashboard
๐ Support the Project
If MCP Playwright helps your team, consider:
- โญ Starring this repository
- ๐ฆ Sharing on social media
- ๐ฌ Joining our Discord community
- โ Sponsoring development
License
MIT License - see LICENSE file for details.
<div align="center">
Built with โค๏ธ by Mostafa Raafat
Making AI-powered automation accessible to everyone
๐ Website โข ๐ฆ Twitter โข ๐ผ LinkedIn
</div>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.