跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 chrome-devtools-mcp-automation

Chrome Devtools Mcp Automation

使用 Chrome DevTools MCP 来控制 Chrome,调试网络应用,分析性能,并通过 MCP 工具实现浏览器任务自动化

263 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

使用 Chrome DevTools MCP 来控制 Chrome,调试网络应用,分析性能,并通过 MCP 工具实现浏览器任务自动化

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Chrome DevTools MCP Automation、Installation、MCP Client Configuration、CLI Usage (Without MCP)、Install globally、Run CLI。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。 正文约 548 行,超过规范建议的 500 行,激活时仍会整份载入。

官方 description(原文)

Use Chrome DevTools MCP to control Chrome, debug web apps, analyze performance, and automate browser tasks via MCP tools

Chrome DevTools MCP AutomationInstallationMCP Client ConfigurationCLI Usage (Without MCP)Install globallyRun CLIRequirementsKey MCP ToolsBrowser ControlPerformance AnalysisDebugging & InspectionCommon Automation Patterns

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
chrome-devtools-mcp-automation
description
Use Chrome DevTools MCP to control Chrome, debug web apps, analyze performance, and automate browser tasks via MCP tools
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「chrome-devtools-mcp-automation」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-389ad6add14b605e-Chrome-Devtools-Mcp-%E8%87%AA%E5%8A%A8%E5%8C%96.html
请存为 .cursor/skills/chrome-devtools-mcp-automation/SKILL.md 或 .claude/skills/chrome-devtools-mcp-automation/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/reason-machines/devtools-skills' --list

npx skills add 'https://github.com/reason-machines/devtools-skills' --skill 'chrome-devtools-mcp-automation'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版

name: chrome-devtools-mcp-automation description: Use Chrome DevTools MCP to control Chrome, debug web apps, analyze performance, and automate browser tasks via MCP tools triggers:

  • automate browser testing with chrome devtools
  • debug web application performance issues
  • take screenshots and analyze network requests
  • record performance traces in chrome
  • inspect browser console errors with source maps
  • control chrome browser for automated testing
  • analyze web vitals and performance metrics
  • interact with web pages using puppeteer automation

Chrome DevTools MCP Automation

Skill by ara.so — Devtools Skills collection.

Chrome DevTools MCP (chrome-devtools-mcp) is an MCP server that gives AI coding agents full control over Chrome browser automation, debugging, and performance analysis. It exposes Chrome DevTools Protocol and Puppeteer capabilities through MCP tools, enabling reliable browser automation, performance profiling, network inspection, and advanced debugging.

Installation

MCP Client Configuration

Add to your MCP client configuration (e.g., Claude Desktop, Cursor, VS Code):

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest"]
    }
  }
}

Slim mode (basic browser tasks only):

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest", "--slim", "--headless"]
    }
  }
}

Disable usage statistics and update checks:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest", "--no-usage-statistics"],
      "env": {
        "CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS": "1"
      }
    }
  }
}

CLI Usage (Without MCP)

# Install globally
npm install -g chrome-devtools-mcp

# Run CLI
chrome-devtools-mcp --help

Requirements

  • Node.js v20.19+ (latest maintenance LTS)
  • Chrome stable or newer
  • npm

Key MCP Tools

Once the MCP server is running, your AI agent has access to these tools:

Browser Control

browser_navigate - Navigate to a URL

// Navigate to a page
await use_mcp_tool("chrome-devtools", "browser_navigate", {
  url: "https://example.com"
});

browser_click - Click an element

// Click by selector
await use_mcp_tool("chrome-devtools", "browser_click", {
  selector: "button.submit"
});

// Click with custom wait
await use_mcp_tool("chrome-devtools", "browser_click", {
  selector: "#login-btn",
  waitUntil: "networkidle2"
});

browser_type - Type text into an input

// Type into a field
await use_mcp_tool("chrome-devtools", "browser_type", {
  selector: "input[name='email']",
  text: "[email protected]"
});

// Type with delay between keystrokes
await use_mcp_tool("chrome-devtools", "browser_type", {
  selector: "#search",
  text: "search query",
  delay: 100
});

browser_screenshot - Capture screenshot

// Full page screenshot
await use_mcp_tool("chrome-devtools", "browser_screenshot", {
  fullPage: true
});

// Element screenshot
await use_mcp_tool("chrome-devtools", "browser_screenshot", {
  selector: ".main-content",
  fullPage: false
});

browser_evaluate - Execute JavaScript in browser

// Get page data
await use_mcp_tool("chrome-devtools", "browser_evaluate", {
  script: "document.title"
});

// Interact with page
await use_mcp_tool("chrome-devtools", "browser_evaluate", {
  script: `
    const items = Array.from(document.querySelectorAll('.item'));
    return items.map(el => ({
      text: el.textContent,
      href: el.querySelector('a')?.href
    }));
  `
});

Performance Analysis

performance_record - Record performance trace

// Record a page load
await use_mcp_tool("chrome-devtools", "performance_record", {
  url: "https://example.com",
  duration: 10000, // 10 seconds
  throttling: "4g" // Simulate 4G network
});

performance_analyze - Analyze performance metrics

// Get performance insights
await use_mcp_tool("chrome-devtools", "performance_analyze", {
  traceUrl: "trace-data-url",
  includeFieldData: true // Include CrUX data
});

Debugging & Inspection

browser_console - Get console messages

// Fetch console logs
await use_mcp_tool("chrome-devtools", "browser_console", {});

browser_network - Inspect network requests

// Get network activity
await use_mcp_tool("chrome-devtools", "browser_network", {});

// Filter by resource type
await use_mcp_tool("chrome-devtools", "browser_network", {
  resourceType: "xhr"
});

browser_cookies - Manage cookies

// Get all cookies
await use_mcp_tool("chrome-devtools", "browser_cookies", {
  action: "get"
});

// Set a cookie
await use_mcp_tool("chrome-devtools", "browser_cookies", {
  action: "set",
  name: "session_id",
  value: "abc123",
  domain: "example.com"
});

// Delete cookies
await use_mcp_tool("chrome-devtools", "browser_cookies", {
  action: "delete",
  name: "session_id"
});

Common Automation Patterns

Form Submission Testing

// Navigate to login page
await use_mcp_tool("chrome-devtools", "browser_navigate", {
  url: "https://app.example.com/login"
});

// Fill in credentials
await use_mcp_tool("chrome-devtools", "browser_type", {
  selector: "input[name='email']",
  text: "[email protected]"
});

await use_mcp_tool("chrome-devtools", "browser_type", {
  selector: "input[name='password']",
  text: process.env.TEST_PASSWORD
});

// Submit form
await use_mcp_tool("chrome-devtools", "browser_click", {
  selector: "button[type='submit']",
  waitUntil: "networkidle0"
});

// Verify success
const result = await use_mcp_tool("chrome-devtools", "browser_evaluate", {
  script: "document.querySelector('.success-message')?.textContent"
});

Web Scraping

// Navigate to page
await use_mcp_tool("chrome-devtools", "browser_navigate", {
  url: "https://news.example.com"
});

// Extract data
const articles = await use_mcp_tool("chrome-devtools", "browser_evaluate", {
  script: `
    Array.from(document.querySelectorAll('article')).map(article => ({
      title: article.querySelector('h2')?.textContent?.trim(),
      link: article.querySelector('a')?.href,
      date: article.querySelector('time')?.getAttribute('datetime'),
      summary: article.querySelector('p')?.textContent?.trim()
    }))
  `
});

Performance Audit

// Record trace with throttling
const trace = await use_mcp_tool("chrome-devtools", "performance_record", {
  url: "https://example.com",
  duration: 15000,
  throttling: "3g",
  deviceEmulation: "mobile"
});

// Analyze metrics
const analysis = await use_mcp_tool("chrome-devtools", "performance_analyze", {
  traceUrl: trace.url,
  includeFieldData: true
});

// Check Core Web Vitals
console.log(`LCP: ${analysis.lcp}ms`);
console.log(`FID: ${analysis.fid}ms`);
console.log(`CLS: ${analysis.cls}`);

Network Monitoring

// Navigate and monitor network
await use_mcp_tool("chrome-devtools", "browser_navigate", {
  url: "https://api.example.com/dashboard"
});

// Get network requests
const requests = await use_mcp_tool("chrome-devtools", "browser_network", {});

// Filter failed requests
const failed = requests.filter(r => r.status >= 400);

// Find slow requests
const slow = requests.filter(r => r.time > 1000);

Screenshot Comparison

// Baseline screenshot
await use_mcp_tool("chrome-devtools", "browser_navigate", {
  url: "https://example.com"
});

const baseline = await use_mcp_tool("chrome-devtools", "browser_screenshot", {
  fullPage: true
});

// Make changes via evaluate
await use_mcp_tool("chrome-devtools", "browser_evaluate", {
  script: "document.body.classList.add('dark-mode')"
});

// Comparison screenshot
const comparison = await use_mcp_tool("chrome-devtools", "browser_screenshot", {
  fullPage: true
});

Console Error Debugging

// Navigate to page
await use_mcp_tool("chrome-devtools", "browser_navigate", {
  url: "https://app.example.com"
});

// Check console for errors
const console = await use_mcp_tool("chrome-devtools", "browser_console", {});

// Filter errors with source maps
const errors = console.filter(msg => 
  msg.type === 'error' && msg.stackTrace
);

// Log error details
errors.forEach(error => {
  console.log(`Error: ${error.text}`);
  console.log(`Source: ${error.stackTrace?.[0]?.url}`);
  console.log(`Line: ${error.stackTrace?.[0]?.lineNumber}`);
});

Configuration Options

Command-Line Flags

# Run in headless mode
npx chrome-devtools-mcp@latest --headless

# Slim mode (basic tools only)
npx chrome-devtools-mcp@latest --slim

# Disable performance CrUX data
npx chrome-devtools-mcp@latest --no-performance-crux

# Disable usage statistics
npx chrome-devtools-mcp@latest --no-usage-statistics

# Connect to existing browser
npx chrome-devtools-mcp@latest --browser-url=http://127.0.0.1:9222

# Custom Chrome path
npx chrome-devtools-mcp@latest --chrome-path=/path/to/chrome

Environment Variables

# Disable usage statistics
export CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=1

# Disable update checks
export CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1

# CI mode (disables stats collection)
export CI=true

MCP Server Configuration Examples

Headless with custom timeout:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": ["-y", "chrome-devtools-mcp@latest", "--headless"],
      "env": {
        "CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS": "1"
      }
    }
  }
}

Connect to existing browser (Antigravity):

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "npx",
      "args": [
        "-y",
        "chrome-devtools-mcp@latest",
        "--browser-url=http://127.0.0.1:9222"
      ]
    }
  }
}

Windows configuration:

{
  "mcpServers": {
    "chrome-devtools": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "chrome-devtools-mcp@latest"
      ],
      "env": {
        "SystemRoot": "C:\\Windows",
        "PROGRAMFILES": "C:\\Program Files"
      }
    }
  }
}

Troubleshooting

Browser Won't Start

Issue: Chrome fails to launch

Solution:

  1. Verify Chrome is installed: chrome --version or google-chrome --version
  2. Check Node.js version: node --version (must be 20.19+)
  3. Use explicit Chrome path:
    {
      "args": ["-y", "chrome-devtools-mcp@latest", "--chrome-path=/usr/bin/google-chrome"]
    }
    

Connection Timeout

Issue: MCP server fails to connect to browser

Solution:

  1. Increase startup timeout in config:
    {
      "startup_timeout_ms": 20000
    }
    
  2. Check if another Chrome instance is using port 9222
  3. Kill existing Chrome processes: pkill chrome (Linux/Mac)

Selector Not Found

Issue: browser_click or browser_type fails to find element

Solution:

  1. Wait for element to appear:
    await use_mcp_tool("chrome-devtools", "browser_evaluate", {
      script: `
        await new Promise(resolve => {
          const check = setInterval(() => {
            if (document.querySelector('#my-element')) {
              clearInterval(check);
              resolve();
            }
          }, 100);
        });
      `
    });
    
  2. Use more specific selectors (ID > class > tag)
  3. Check if element is in iframe (not currently supported)

Performance Trace Fails

Issue: performance_record returns incomplete trace

Solution:

  1. Increase duration: duration: 30000
  2. Disable throttling for local testing: remove throttling parameter
  3. Check network connectivity for remote URLs

Source Maps Not Loading

Issue: Console errors don't show source-mapped stack traces

Solution:

  1. Ensure source maps are published with your build
  2. Verify source map URLs are accessible
  3. Check CORS headers on source map files

High Memory Usage

Issue: Chrome consumes excessive memory

Solution:

  1. Use --headless mode
  2. Close browser between test runs
  3. Use --slim mode if you don't need performance tools
  4. Limit trace duration in performance_record

Rate Limiting (CrUX API)

Issue: Performance analysis fails with rate limit error

Solution:

  1. Disable CrUX: --no-performance-crux
  2. Cache analysis results for repeated URLs
  3. Add delay between performance audits

Best Practices

  1. Always use headless mode in CI/CD: Add --headless flag
  2. Use environment variables for sensitive data: Never hardcode credentials
  3. Wait for navigation: Use waitUntil: "networkidle0" for SPAs
  4. Cache selectors: Store frequently used selectors as constants
  5. Clean up resources: Close browser instances after automation completes
  6. Enable source maps: For better debugging of console errors
  7. Use slim mode for simple tasks: Faster startup, lower memory usage
  8. Throttle performance tests: Simulate real-world conditions with throttling: "4g"

Additional Resources

相关技能

Agent 工作流

Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…