← Back to Home

AI coding browser automation

Chrome DevTools MCPClaude CodeBrowser AutomationMCP ToolsPuppeteer

Problem Context

Chrome DevTools MCP is Google's official Model Context Protocol server that lets AI coding tools (Claude Code, Cursor, Copilot) control Chrome directly for automation. I hit 5 traps during configuration and spent 3 hours solving all of them.

Core Concepts

Chrome DevTools MCP is built on Chrome DevTools Protocol (CDP) and uses Puppeteer under the hood to control the browser. It provides two operation modes:

Key tools include: new_page, navigate_page, click, fill_form, screenshot, performance_analyze_insight — 40+ tools in total.

Pitfall 1: Node.js Version Mismatch

Error message:

Error: Command failed with exit code 1: npm ERR! code EBADENGINE
npm ERR! Unsupported engine and requires Node.js >=v20.19.0

Root cause: chrome-devtools-mcp requires Node.js >= v20.19.0, but many systems ship with v18.x or earlier.

Solution:

# Check current Node version
node --version

# Switch to v20 using nvm
nvm install 20
nvm use 20

# Verify
node --version  # Should show v20.19.0 or higher

Verification:

node --version  # >= v20.19.0
npm --version   # >= 10.x

Pitfall 2: Missing X Server (Linux/WSL)

Error message:

Missing X server to start the headful browser.
Either set headless to true or use xvfb-run to run your Puppeteer script.

Root cause: Default mode is headful (visible browser), which requires a display server. Server environments typically have no X server.

**Solution**: Add --headless flag

// In Claude Code config (~/.claude.json or settings):
{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": [
        "-y",
        "chrome-devtools-mcp@latest",
        "--headless"
      ]
    }
  }
}

Or use xvfb-run (requires xvfb installed):

xvfb-run --auto-servernum npx -y chrome-devtools-mcp@latest

WSL-specific treatment: Wayland environment needs extra args:

npx -y chrome-devtools-mcp@latest \
  --chromeArg=--ozone-platform=wayland \
  --chromeArg=--no-first-run \
  --chromeArg=--no-default-browser-check

Pitfall 3: Chrome Version Mismatch

Error message:

Chrome version mismatch. Expected Chrome current stable,
got 120.0.6099.109. Please update Chrome.

Root cause: Chrome DevTools MCP requires Chrome current stable, but system has an outdated version.

Solution:

# 1. Check current Chrome version
google-chrome --version

# 2. Ubuntu/Debian: update Chrome
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list'
sudo apt update && sudo apt install google-chrome-stable

# 3. Verify
google-chrome --version

Windows: Download latest stable from https://www.google.com/chrome/

Pitfall 4: --autoConnect Requires Prepared Chrome Instance

Error message:

Error: No Chrome instance found for autoConnect.
Please start Chrome with --remote-debugging-port=9222

**Root cause**: --autoConnect mode requires Chrome to already be running with remote debugging port enabled.

Solution:

# 1. Start Chrome first (Mac)
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=9222 \
  --user-data-dir=/tmp/chrome-mcp

# Linux
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-mcp

# Windows
"C:\Program Files\Google\Chrome\Application\chrome.exe" \
  --remote-debugging-port=9222 \
  --user-data-dir=C:\temp\chrome-mcp

# 2. Then start MCP server
npx -y chrome-devtools-mcp@latest --autoConnect

Verify connection:

# Open http://localhost:9222/json to see available browser instances
curl http://localhost:9222/json

Pitfall 5: Chrome Profile Lock

Error message:

Error: Failed to launch chrome!
chrome-devtools-mcp cannot be used with another Chrome DevTools MCP or Chrome instance using the same profile.

Root cause: Previous Chrome instance didn't shut down properly; profile is locked.

Solution:

# 1. Kill residual Chrome processes
pkill -f chrome-devtools-mcp
pkill -f "chrome.*remote-debugging"

# 2. Remove lock files
rm -rf ~/.cache/chrome-devtools-mcp/chrome-profile/SingletonLock
rm -rf ~/.cache/chrome-devtools-mcp/chrome-profile/SingletonSocket

# 3. Use --isolated flag (new profile)
npx -y chrome-devtools-mcp@latest --headless --isolated

**What --isolated does**: uses a separate Chrome profile to avoid conflicts with other instances.

Complete Configuration Examples

Claude Code Configuration

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": [
        "-y",
        "chrome-devtools-mcp@latest",
        "--headless",
        "--viewport=1920x1080"
      ]
    }
  }
}

Verify Installation

# Test new_page tool
claude
# Then type /mcp to check server status
# Use new_page to create a new tab as a test

Verification Commands Summary

# Node.js version check
node --version  # >= v20.19.0

# Chrome version check
google-chrome --version  # must be current stable

# MCP server startup test
npx -y chrome-devtools-mcp@latest --help

# Chrome debugging port check
curl http://localhost:9222/json  # should return available instances

Summary and Next Steps

The core of Chrome DevTools MCP configuration is three preparations: Node.js version, Chrome version, and isolated profile. After solving these 5 traps, AI coding tools can control the browser for automation.

Recommended practices:

Related tools:

Recommended Reading

If you are interested in browser automation and AI coding tools, consider:

Related Reading

Want to learn more about AI coding tool configuration?

👉 Try AI coding tools now: https://platform.minimaxi.com/subscribe/token-plan?code=E5yur9NOub&source=link

📌 This article was AI-assisted generated and human-reviewed | TechPassive — An AI-driven content testing site focused on real tool reviews

🔗 Recommended Tools

These are carefully selected tools. Using our affiliate links supports us to keep producing quality content:

☁️ DigitalOcean Cloud ⚡ Vultr VPS 📚 WordPress Books 🔍 WordPress SEO Books 🌐 Web Hosting Books 🐳 Docker Books 🐧 Linux Books 🐍 Python Books 💰 Affiliate Marketing 💵 Passive Income Books 🖥️ Server Books ☁️ Cloud Computing Books 🚀 DevOps Books ⭐ MiniMax Token Plan
← Back to Home