Playwright MCP
January 6, 2025 ยท View on GitHub
A Model Context Protocol (MCP) server for controlling Playwright browser automation. This server implements the MCP specification and can be used with any MCP-compatible client.
Installation
You can install directly from GitHub:
pip install -e git+https://github.com/adamdude828/playwright_mcp.git#egg=playwright_mcp
Configuration
The configuration file for mcp-cli should be placed at ~/.mcp-cli/server_config.json.
Create a server_config.json file with the following content:
{
"mcpServers": {
"playwright": {
"command": "python",
"args": [
"-m",
"playwright_mcp",
"--mode",
"server"
],
"logging": {
"level": "DEBUG"
}
}
}
}
Usage
This server can be used with any MCP-compatible client. Here's an example using mcp-cli:
# Install the example client
pip install -e git+https://github.com/adamdude828/mcp-cli.git#egg=mcp-cli
Once installed and configured:
- List available servers:
mcp-cli list-servers
- List available tools:
mcp-cli --server playwright list-tools
- Start the browser daemon:
mcp-cli --server playwright --tool start-daemon call-tool
- Navigate to a page:
mcp-cli --server playwright --tool navigate --tool-args '{"url": "https://example.com"}' call-tool
- Stop the browser daemon:
mcp-cli --server playwright --tool stop-daemon call-tool
Development
To run the integration tests:
pytest tests/integration/test_mcp_cli_setup.py -v
The tests verify:
- MCP CLI availability
- Playwright tool availability
- Browser daemon start/stop functionality
- Navigation capabilities