Ensure you have these installed on macOS:
- Git
- Node.js (version 18 or higher)
- Google Chrome (stable version)
- Claude Code CLI (installed and authenticated)
# Clone and build the project
git clone https://github.com/ChromeDevTools/chrome-devtools-mcp.git
cd chrome-devtools-mcp
npm install
npm run buildVerify the build created the build/ directory with compiled JavaScript files:
ls build/
# Should show: index.js, tool-handler.js, url-utils.js, tools/Prepare your extension for debugging:
# Ensure your extension is unpacked in a directory
# Example structure:
# /path/to/your-extension/
# ├── manifest.json
# ├── background.js (or service_worker.js)
# ├── options.html
# ├── popup.html
# └── sidebar.htmlSet up the dedicated Chrome profile for MCP:
# Create the profile directory
mkdir -p ~/.cache/chrome-devtools-mcp/mcp-profile
# Launch Chrome Canary with the profile (keep this running)
/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary \
--user-data-dir=$HOME/.cache/chrome-devtools-mcp/mcp-profileImportant Setup in Chrome:
- Sign into Chrome with your Google account
- Open DevTools (F12 or right-click → Inspect)
- Go to DevTools Settings (⚙️) → Experiments or AI innovations
- Enable "AI assistance"
- Close Chrome completely
Create a .cursor/mcp.json file with the following content:
{
"mcpServers": {
"chrome-devtools-mcp-pwai": {
"type": "stdio",
"command": "node",
"args": [
"/Users/yourusername/path/to/chrome-devtools-mcp/build/index.js",
"--channel=canary",
"--extensionPath=/Users/yourusername/path/to/extension_project/build/folder",
"--log-file=/Users/yourusername/path/to/extension_project/logs.txt"
]
}
}
}# Add the MCP server to Claude Code
claude mcp add chrome-devtools-mcp --scope project \
-- npx -y @privatewebai/chrome-devtools-mcp --channel=dev --extensionPath=/Users/yourusername/path/to/extension_project/build/folder --log-file=/Users/yourusername/path/to/extension_project/logs.txtReplace the paths:
/Users/yourusername/path/to/chrome-devtools-mcp/build/index.jswith your actual project path/Users/yourusername/path/to/your-extensionwith your extension's directory path
This will effectively create a .mcp.json file in the root of your project, you can also manually create this file as an alternative method:
{
"mcpServers": {
"chrome-devtools-mcp-pwai": {
"type": "stdio",
"command": "npx",
"args": [
"@privatewebai/chrome-devtools-mcp",
"--channel=dev",
"--extensionPath=/Users/yourusername/path/to/extension_project/build/folder",
"--log-file=/Users/yourusername/path/to/extension_project/logs.txt"
]
}
}
}# Start Claude Code
claude-code
# The MCP server will automatically:
# 1. Connect to your running Chrome instance
# 2. Access your loaded extension
# 3. Enable extension debugging featuresOnce Claude Code starts, verify the connection works:
Get extension logs for [your-extension-id]
You should see logs from your extension's contexts.
Get console logs from extension mnhjigbdgnofilmnjhodpbggbpoibkof background context
Test the extension with ID mnhjigbdgnofilmnjhodpbggbpoibkof and check if it's working properly
# Standard launch with debugging enabled
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--remote-debugging-address=127.0.0.1# Launch Chrome with your extension pre-loaded
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--remote-debugging-address=127.0.0.1 \
--load-extension=/path/to/your-extension# Use a dedicated profile for extension development
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--remote-debugging-address=127.0.0.1 \
--user-data-dir=$HOME/.chrome-extension-dev \
--load-extension=/path/to/your-extension1. "Cannot connect to Chrome"
# Check if Chrome is running with debugging enabled
curl http://127.0.0.1:9222/json/version
# Should return Chrome version info
# If not working, restart Chrome with the debugging command2. "Extension not found"
# Verify extension is loaded in Chrome
# Go to chrome://extensions/ and check your extension is there
# Copy the extension ID and use it in Claude Code commands3. "No logs available"
# Make sure your extension is actively running
# Check browser console in extension pages (right-click → Inspect)
# Try triggering extension functionality to generate logsOnce everything is set up:
User: Check the console logs from my extension's background script
Claude: I'll retrieve the console logs from your extension's background context.
[Retrieves and analyzes logs using cdp_extension_get_logs]
I found several log entries from your background script. Here's what I see:
- 3 info messages about initialization
- 1 warning about deprecated API usage
- 2 error messages related to storage permissions
The errors suggest your extension needs additional permissions for chrome.storage.local access...
[Provides specific debugging guidance based on actual console output]
Retrieve captured console logs from an extension's development log sink stored in chrome.storage.local.
The extension must store logs in chrome.storage.local under the __dev_logs key in this format:
{
"ctx": "background",
"level": "info",
"msg": ["message"],
"sid": "session_id",
"t": "2025-01-01T00:00:00.000Z"
}Parameters:
extensionId(required): Chrome extension ID (32-character string)contextType(optional): Filter by context (background,options,popup,sidebar,all)logLevel(optional): Filter by level (log,info,warn,error,all)maxEntries(optional): Maximum entries to return (1-1000, default: 100)since(optional): Only return logs after this timestamp (Unix timestamp in ms)sessionId(optional): Filter by specific session ID
Perform basic functionality testing on a Chrome extension.
Parameters:
extensionId(required): Chrome extension ID (32-character string)
This tool tests whether an extension is properly loaded and accessible, checks its basic functionality, and reports on its status across different contexts.
- Background scripts/Service workers - Monitor background processes and API calls
- Options pages - Debug extension settings and configuration interfaces
- Popup pages - Debug extension popup interfaces
- Sidebar/Sidepanel pages - Debug sidebar panels and content