Loading...
Loading...
Expert guidance for Chrome DevTools MCP server - browser automation, debugging, and performance analysis for AI agents
npx skill4agent add aradotso/mcp-skills chrome-devtools-mcp-automationSkill by ara.so — MCP Skills collection.
chrome-devtools-mcp{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest"]
}
}
}{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": [
"-y",
"chrome-devtools-mcp@latest",
"--headless",
"--no-usage-statistics",
"--no-performance-crux"
]
}
}
}{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest", "--slim", "--headless"]
}
}
}{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": [
"-y",
"chrome-devtools-mcp@latest",
"--browser-url=http://127.0.0.1:9222"
]
}
}
}# Install globally
npm install -g chrome-devtools-mcp
# Run CLI commands
chrome-devtools-mcp navigate --url https://example.com
chrome-devtools-mcp screenshot --output screenshot.png
chrome-devtools-mcp console-logs| Flag | Description |
|---|---|
| Run Chrome in headless mode (no UI) |
| Enable slim mode (basic tools only) |
| Opt out of Google usage statistics collection |
| Disable Chrome UX Report (CrUX) API calls |
| Connect to existing Chrome instance at URL |
| Use custom Chrome profile directory |
# Disable usage statistics
export CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1
# Disable update checks
export CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1
# Use in CI environment (auto-disables statistics)
export CI=true// MCP tool call: navigate
{
"url": "https://example.com",
"waitUntil": "networkidle0"
}// MCP tool call: click
{
"selector": "button.submit",
"waitForNavigation": true
}// MCP tool call: type
{
"selector": "input[name='email']",
"text": "user@example.com",
"delay": 100
}// MCP tool call: evaluate
{
"script": "document.querySelector('h1').textContent",
"returnByValue": true
}// MCP tool call: screenshot
{
"fullPage": true,
"path": "./screenshots/page.png"
}// MCP tool call: screenshot
{
"selector": "div.product-card",
"path": "./element.png"
}// MCP tool call: network-logs
{
"filter": {
"type": "fetch",
"status": 200
}
}// MCP tool call: network-logs
{
"filter": {
"failed": true
}
}// MCP tool call: console-logs
{
"level": "error" // or "warning", "info", "log"
}// MCP tool call: evaluate
{
"script": `
const errors = [];
window.addEventListener('error', (e) => {
errors.push({ message: e.message, stack: e.error.stack });
});
errors;
`,
"returnByValue": true
}// MCP tool call: start-trace
{
"categories": ["devtools.timeline", "v8.execute", "disabled-by-default-v8.cpu_profiler"]
}
// ... perform actions ...
// MCP tool call: stop-trace
{
"path": "./traces/performance.json"
}// MCP tool call: get-metrics
{
"includeMemory": true
}// MCP tool call: web-vitals
{
"url": "https://example.com",
"includeCrux": true // Include real-user data from CrUX
}// 1. Navigate to login page
// Tool: navigate
{ "url": "https://app.example.com/login" }
// 2. Fill credentials
// Tool: type
{ "selector": "#username", "text": "testuser" }
{ "selector": "#password", "text": "secure_password" }
// 3. Submit form
// Tool: click
{ "selector": "button[type='submit']", "waitForNavigation": true }
// 4. Verify success
// Tool: evaluate
{ "script": "window.location.pathname === '/dashboard'" }
// 5. Capture proof
// Tool: screenshot
{ "path": "./test-evidence/login-success.png" }// 1. Start trace recording
// Tool: start-trace
{ "categories": ["devtools.timeline", "loading", "blink.user_timing"] }
// 2. Navigate to page
// Tool: navigate
{ "url": "https://example.com/product/123", "waitUntil": "networkidle0" }
// 3. Stop trace
// Tool: stop-trace
{ "path": "./audits/product-page-trace.json" }
// 4. Get Core Web Vitals
// Tool: web-vitals
{ "url": "https://example.com/product/123", "includeCrux": true }
// 5. Analyze metrics
// Tool: get-metrics
{ "includeMemory": true }// 1. Navigate to problematic page
// Tool: navigate
{ "url": "https://example.com/checkout" }
// 2. Monitor network for failed requests
// Tool: network-logs
{ "filter": { "failed": true } }
// 3. Capture console errors
// Tool: console-logs
{ "level": "error" }
// 4. Get JavaScript errors with stack traces
// Tool: evaluate
{
"script": `
window.__errors = [];
window.addEventListener('error', (e) => {
__errors.push({
message: e.message,
filename: e.filename,
lineno: e.lineno,
colno: e.colno,
stack: e.error?.stack
});
});
setTimeout(() => __errors, 5000);
`,
"returnByValue": true
}
// 5. Screenshot for visual context
// Tool: screenshot
{ "fullPage": true, "path": "./debug/error-state.png" }// 1. Navigate to target page
// Tool: navigate
{ "url": "https://example.com/products" }
// 2. Wait for dynamic content
// Tool: wait-for-selector
{ "selector": "div.product-list", "timeout": 5000 }
// 3. Extract structured data
// Tool: evaluate
{
"script": `
Array.from(document.querySelectorAll('.product-card')).map(card => ({
title: card.querySelector('h3').textContent.trim(),
price: card.querySelector('.price').textContent.trim(),
url: card.querySelector('a').href,
inStock: !card.querySelector('.out-of-stock')
}))
`,
"returnByValue": true
}
// 4. Handle pagination
// Tool: click
{ "selector": "button.next-page", "waitForNavigation": true }// 1. Set consistent viewport
// Tool: set-viewport
{ "width": 1280, "height": 720, "deviceScaleFactor": 1 }
// 2. Navigate to page
// Tool: navigate
{ "url": "https://example.com/landing" }
// 3. Wait for animations to complete
// Tool: wait-for-timeout
{ "timeout": 2000 }
// 4. Take baseline screenshot
// Tool: screenshot
{
"fullPage": true,
"path": "./visual-tests/baseline.png"
}
// 5. Compare against previous baseline (in your test framework)
// Tool: screenshot
{
"fullPage": true,
"path": "./visual-tests/current.png"
}# Specify Chrome executable path
export CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
# Or use Chrome for Testing
npx @puppeteer/browsers install chrome@stable# Find and kill existing Chrome instance
lsof -ti:9222 | xargs kill -9
# Or use custom port
# In MCP config, add: "--remote-debugging-port=9223"// Increase timeout for slow pages
// Tool: navigate
{
"url": "https://slow-site.com",
"timeout": 60000,
"waitUntil": "domcontentloaded" // Less strict than "networkidle0"
}// Remove --headless flag temporarily to debug
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest"]
}
}
}// Close and reopen browser periodically
// Tool: close-browser
{}
// Browser will auto-restart on next tool call# Ensure source maps are deployed with your app
# Check Network tab for .map file requests
# Tool: network-logs
{ "filter": { "type": "other" } }# Set proxy environment variables
export HTTP_PROXY=http://proxy.company.com:8080
export HTTPS_PROXY=http://proxy.company.com:8080
# Disable CrUX if API calls fail
# Add flag: --no-performance-crux--no-usage-statisticsCHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1--no-performance-crux--slim--headlesschrome-devtools-mcp@X.Y.Z@latestnetwork-logs