Answer
What is Playwright MCP?
Playwright MCP is an MCP server that gives AI models (like Claude) the ability to control a real web browser using Microsoft's Playwright automation library. It enables AI agents to browse websites, fill forms, click buttons, and extract content.
What It Enables
With Playwright MCP, Claude can:
- Navigate to URLs
- Click buttons and links
- Fill in form fields
- Take screenshots
- Extract text from web pages
- Run JavaScript in the browser
- Automate end-to-end testing
Setup
bashnpm install -g @modelcontextprotocol/server-playwright
json// ~/.claude.json { "mcpServers": { "playwright": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-playwright"] } } }
Available Tools (exposed to Claude)
| Tool | Description |
|---|---|
text | Go to a URL |
text | Click an element by selector |
text | Type text into an input field |
text | Capture current page as image |
text | Extract text content from page |
text | Run JavaScript in browser |
text | Select an option from dropdown |
Example: Claude Using Playwright MCP
textUser: "Go to example.com and tell me what the main heading says" Claude: 1. Calls playwright_navigate({url: "https://example.com"}) 2. Calls playwright_get_text({selector: "h1"}) 3. Returns: "The heading says 'Example Domain'"
textUser: "Search for 'AI engineering' on DuckDuckGo and summarize the first 3 results" Claude: 1. playwright_navigate({url: "https://duckduckgo.com"}) 2. playwright_fill({selector: "input[name='q']", value: "AI engineering"}) 3. playwright_click({selector: "button[type='submit']"}) 4. playwright_get_text({selector: ".results"}) 5. Summarizes the extracted text
Use Cases
| Use Case | Description |
|---|---|
| Web scraping | Extract data from websites that block direct requests |
| E2E testing | Claude writes and runs browser tests |
| Form automation | Fill and submit web forms |
| Research | Browse and summarize multiple pages |
| UI verification | Check that pages render correctly |
| Web workflows | Automate repetitive browser tasks |
Security Note
Playwright MCP gives Claude full browser control — only enable it for trusted workflows. Configure with allowed domains if needed:
json{ "mcpServers": { "playwright": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-playwright", "--allowed-origins", "https://yoursite.com"] } } }
Playwright MCP vs Direct Playwright
| Direct Playwright Code | Playwright MCP | |
|---|---|---|
| Control | You write automation code | Claude writes + executes |
| Flexibility | Full programming control | Natural language instructions |
| Speed | Faster for known tasks | Faster for ad-hoc tasks |
| Best for | Known, repeatable workflows | Exploratory, conversational automation |