| name | playwright-mcp-manual-interaction |
| description | Manual Playwright MCP setup and JSON-RPC usage; use when interacting with Playwright MCP without automatic integration. |
Playwright MCP - Manual Interaction Guide
Status
Playwright MCP is DISABLED BY DEFAULT in Claude Code CLI and Codex CLI for context optimization.
Location: Can be run locally but not installed to CLI by default
Why Disabled by Default
- Context Optimization: Reduces token usage during normal operations
- Manual Control: Available when explicitly needed for browser automation tasks
- Local Availability: Server can still be started manually for testing
Enabling Playwright MCP
Option 1: Enable in mcp_common.sh (Global)
export PLAYWRIGHT_ENABLED=true
bash scripts/mcp_common.sh
Option 2: Manual Server Installation
npm install -g @playwright/mcp
npx -y @playwright/mcp --help
Manual Interaction via Bash Commands
Starting the Playwright MCP Server Manually
Direct Node Execution:
node "$(npm root -g)/@playwright/mcp/dist/index.js"
Using npx:
npx -y @playwright/mcp
Server Communication Protocol
The Playwright MCP server uses JSON-RPC over stdio. Here's how to interact manually:
⚠️ Note on Protocol Version: The examples use protocol version "2024-11-05" which is current as of this writing. To verify the latest supported protocol version, consult the MCP specification or check the server's initialization response.
⚠️ Note on One-Shot Commands: The examples below use piped echo commands for demonstration. Each npx -y @playwright/mcp invocation starts a new server instance that exits after processing one message. For persistent sessions with multiple commands, use the Interactive Testing Script or Node.js REPL approaches shown later in this document.
1. Initialize the Server (one-shot example):
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"manual-test","version":"1.0.0"}}}' | npx -y @playwright/mcp
2. List Available Tools (one-shot example):
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | npx -y @playwright/mcp
3. Execute Browser Actions (one-shot examples):
echo '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "browser_navigate",
"arguments": {
"url": "https://example.com"
}
}
}' | npx -y @playwright/mcp
echo '{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "browser_click",
"arguments": {
"selector": "button#submit"
}
}
}' | npx -y @playwright/mcp
echo '{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "browser_screenshot",
"arguments": {
"path": "docs/screenshot.png"
}
}
}' | npx -y @playwright/mcp
Integration with Claude Code (When Enabled)
If you enable Playwright MCP in your CLI configuration, it will be available as:
MCP Tool Pattern: mcp__playwright__*
Common Tools Available:
browser_navigate - Navigate to URL
browser_click - Click element by selector
browser_screenshot - Capture screenshot
browser_evaluate - Execute JavaScript in browser context
browser_fill - Fill form fields
browser_press - Press keyboard keys
Testing Locally Without CLI Installation
Interactive Testing Script
#!/bin/bash
PIPE_PATH=$(mktemp -u)
mkfifo "$PIPE_PATH"
npx -y @playwright/mcp < "$PIPE_PATH" > /tmp/mcp-output.log 2>&1 &
SERVER_PID=$!
exec 3> "$PIPE_PATH"
sleep 2
echo "Initializing..."
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' >&3
echo "Listing tools..."
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' >&3
sleep 2
exec 3>&-
kill $SERVER_PID 2>/dev/null
rm -f "$PIPE_PATH"
echo "Server output:"
cat /tmp/mcp-output.log
Using Node.js REPL
const { spawn } = require('child_process');
const mcp = spawn('npx', ['-y', '@playwright/mcp']);
function sendRequest(method, params = {}, id = 1) {
const request = JSON.stringify({
jsonrpc: '2.0',
id: id,
method: method,
params: params
});
mcp.stdin.write(request + '\n');
}
mcp.stdout.on('data', (data) => {
console.log('Response:', data.toString());
});
sendRequest('initialize', {
protocolVersion: '2024-11-05',
capabilities: {},
clientInfo: { name: 'node-test', version: '1.0.0' }
});
sendRequest('tools/list', {}, 2);
Configuration Files
Where Playwright MCP Would Be Registered (If Enabled)
{
"mcpServers": {
"playwright-mcp": {
"command": "npx",
"args": ["-y", "@playwright/mcp"]
}
}
}
{
"mcpServers": {
"playwright-mcp": {
"command": "npx",
"args": ["-y", "@playwright/mcp"]
}
}
}
Use Cases for Manual Interaction
- Testing Browser Automation: Test Playwright scripts without full CLI integration
- Debugging: Manually send commands to debug browser automation issues
- CI/CD Integration: Run Playwright MCP in headless mode for automated testing
- Development: Develop and test new browser automation workflows
Re-enabling for Specific Projects
If you need Playwright MCP for a specific project:
cd /path/to/project
export PLAYWRIGHT_ENABLED=true
bash scripts/mcp_common.sh
Troubleshooting
Server Not Starting
npm list -g @playwright/mcp
npm install -g @playwright/mcp
node --version
Communication Issues
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | npx -y @playwright/mcp
Browser Launch Failures
npx playwright install
npx playwright install-deps
Alternative: Use Chrome Superpowers MCP
For simple browser automation needs, consider using Chrome Superpowers MCP which is enabled by default:
Tool: mcp__chrome-superpower__use_browser
See: .claude/skills/chrome-superpowers-reference.md
Related Files
- Installation Script:
scripts/mcp_common.sh (PLAYWRIGHT_ENABLED flag)
- Chrome Alternative:
.claude/skills/chrome-superpowers-reference.md
- Browser Testing:
.claude/skills/browser-testing-ocr-validation.md
Notes
- Playwright MCP is a system-level MCP server, not a user-created skill
- Disabled by default to optimize context usage in normal operations
- Can be manually started and controlled via bash commands and JSON-RPC
- Full CLI integration available by setting
PLAYWRIGHT_ENABLED=true