|
| 1 | +# DevContainer with Playwright MCP Integration |
| 2 | + |
| 3 | +This devcontainer is configured to work with Claude Code and includes the Playwright MCP server for browser automation capabilities. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Claude Code CLI**: Pre-installed and configured |
| 8 | +- **Playwright MCP Server**: Integrated for browser automation and screenshot capabilities |
| 9 | +- **Browser Dependencies**: All required system libraries for running Chromium headless |
| 10 | +- **Network Security**: Firewall configuration for controlled network access |
| 11 | + |
| 12 | +## Playwright MCP Server |
| 13 | + |
| 14 | +The Playwright MCP server is configured in `.claude.json` and provides browser automation tools to Claude Code, including: |
| 15 | + |
| 16 | +- Navigate to URLs |
| 17 | +- Click elements |
| 18 | +- Fill forms |
| 19 | +- Take screenshots |
| 20 | +- Execute JavaScript |
| 21 | +- Interact with page elements |
| 22 | + |
| 23 | +### Usage |
| 24 | + |
| 25 | +Once the devcontainer is rebuilt, Claude Code will automatically have access to Playwright MCP tools. You can use these tools through natural language requests like: |
| 26 | + |
| 27 | +- "Take a screenshot of http://localhost:5173" |
| 28 | +- "Navigate to my site and click the contact button" |
| 29 | +- "Fill out the form with test data" |
| 30 | + |
| 31 | +### Configuration |
| 32 | + |
| 33 | +The MCP server configuration is in `.devcontainer/.claude.json`: |
| 34 | + |
| 35 | +```json |
| 36 | +{ |
| 37 | + "mcpServers": { |
| 38 | + "playwright": { |
| 39 | + "command": "npx", |
| 40 | + "args": ["-y", "@playwright/mcp@latest"] |
| 41 | + } |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +## Rebuilding the Container |
| 47 | + |
| 48 | +After making changes to the Dockerfile or devcontainer configuration: |
| 49 | + |
| 50 | +1. In VS Code: Command Palette → "Dev Containers: Rebuild Container" |
| 51 | +2. Or use the rebuild button in the bottom-left corner |
| 52 | + |
| 53 | +## System Dependencies |
| 54 | + |
| 55 | +The container includes these Playwright browser dependencies: |
| 56 | +- libnspr4, libnss3, libdbus-1-3 |
| 57 | +- libatk1.0-0, libatk-bridge2.0-0 |
| 58 | +- libcups2, libxkbcommon0, libatspi2.0-0 |
| 59 | +- libxcomposite1, libxdamage1, libxfixes3 |
| 60 | +- libxrandr2, libgbm1, libasound2 |
| 61 | +- fonts-liberation, fonts-noto-color-emoji |
| 62 | +- And other required X11 and graphics libraries |
| 63 | + |
| 64 | +## Testing the Integration |
| 65 | + |
| 66 | +To verify Playwright MCP is working: |
| 67 | + |
| 68 | +```bash |
| 69 | +# Check if Playwright MCP can be run |
| 70 | +npx -y @playwright/mcp@latest --version |
| 71 | + |
| 72 | +# The MCP tools will be automatically available in Claude Code sessions |
| 73 | +``` |
| 74 | + |
| 75 | +## Troubleshooting |
| 76 | + |
| 77 | +If browser automation isn't working: |
| 78 | + |
| 79 | +1. Ensure the container has been rebuilt after adding the Dockerfile changes |
| 80 | +2. Check that `.claude.json` is correctly copied to `/home/node/.claude/.claude.json` |
| 81 | +3. Verify browser dependencies are installed: `dpkg -l | grep libnspr4` |
| 82 | +4. Check Claude Code can access the MCP server in the session |
| 83 | + |
| 84 | +## Additional Resources |
| 85 | + |
| 86 | +- [Playwright MCP Documentation](https://github.com/microsoft/playwright-mcp) |
| 87 | +- [Claude Code MCP Integration](https://docs.claude.com/en/docs/claude-code) |
0 commit comments