|
1 |
| -# mcp-playwright |
2 |
| -Repository contains Model Context Protocol support of Playwright for Claude |
| 1 | +# Playwright |
| 2 | + |
| 3 | +A Model Context Protocol server that provides browser automation capabilities using Playwright. This server enables LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment. |
| 4 | + |
| 5 | + |
| 6 | +## Here is how you need to build the code in your local machine |
| 7 | + |
| 8 | +**Clone the repository** |
| 9 | +```bash |
| 10 | +git clone https://github.com/executeautomation/mcp-playwright.git |
| 11 | +``` |
| 12 | + |
| 13 | +**Build the code** |
| 14 | +```bash |
| 15 | +npm run build |
| 16 | +npm link |
| 17 | +``` |
| 18 | + |
| 19 | +## Configuration to use Playwright Server |
| 20 | +Here's the Claude Desktop configuration to use the Playwright server: |
| 21 | + |
| 22 | +```json |
| 23 | +{ |
| 24 | + "mcpServers": { |
| 25 | + "playwright": { |
| 26 | + "command": "npx", |
| 27 | + "args": ["-y", "@modelcontextprotocol/server-playwright"] |
| 28 | + } |
| 29 | + } |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +## Components |
| 35 | + |
| 36 | +### Tools |
| 37 | + |
| 38 | +- **playwright_navigate** |
| 39 | + - Navigate to any URL in the browser |
| 40 | + - Input: `url` (string) |
| 41 | + |
| 42 | +- **playwright_screenshot** |
| 43 | + - Capture screenshots of the entire page or specific elements |
| 44 | + - Inputs: |
| 45 | + - `name` (string, required): Name for the screenshot |
| 46 | + - `selector` (string, optional): CSS selector for element to screenshot |
| 47 | + - `width` (number, optional, default: 800): Screenshot width |
| 48 | + - `height` (number, optional, default: 600): Screenshot height |
| 49 | + |
| 50 | +- **playwright_click** |
| 51 | + - Click elements on the page |
| 52 | + - Input: `selector` (string): CSS selector for element to click |
| 53 | + |
| 54 | +- **playwright_hover** |
| 55 | + - Hover elements on the page |
| 56 | + - Input: `selector` (string): CSS selector for element to hover |
| 57 | + |
| 58 | +- **playwright_fill** |
| 59 | + - Fill out input fields |
| 60 | + - Inputs: |
| 61 | + - `selector` (string): CSS selector for input field |
| 62 | + - `value` (string): Value to fill |
| 63 | + |
| 64 | +- **playwright_select** |
| 65 | + - Select an element with SELECT tag |
| 66 | + - Inputs: |
| 67 | + - `selector` (string): CSS selector for element to select |
| 68 | + - `value` (string): Value to select |
| 69 | + |
| 70 | +- **playwright_evaluate** |
| 71 | + - Execute JavaScript in the browser console |
| 72 | + - Input: `script` (string): JavaScript code to execute |
| 73 | + |
| 74 | +### Resources |
| 75 | + |
| 76 | +The server provides access to two types of resources: |
| 77 | + |
| 78 | +1. **Console Logs** (`console://logs`) |
| 79 | + - Browser console output in text format |
| 80 | + - Includes all console messages from the browser |
| 81 | + |
| 82 | +2. **Screenshots** (`screenshot://<name>`) |
| 83 | + - PNG images of captured screenshots |
| 84 | + - Accessible via the screenshot name specified during capture |
| 85 | + |
| 86 | +## Key Features |
| 87 | + |
| 88 | +- Browser automation |
| 89 | +- Console log monitoring |
| 90 | +- Screenshot capabilities |
| 91 | +- JavaScript execution |
| 92 | +- Basic web interaction (navigation, clicking, form filling) |
0 commit comments