深夜提醒

现在是深夜,建议您注意休息,不要熬夜哦~

🏮 🏮 🏮

新年快乐

祝君万事如意心想事成!

share-image
中
ESC

Chrome DevTools MCP: Letting AI Directly Control the Browser for Performance Analysis and Debugging

English 阅读中文版

Last week, while browsing tech news, I noticed Google released an exciting new tool—Chrome DevTools MCP. As a frontend developer who deals with browsers all year round, this tool immediately caught my interest. It lets AI coding assistants directly control the Chrome browser to achieve automated testing, performance analysis, and deep debugging.

Chrome DevTools MCP: letting AI directly control the browser for performance analysis and debugging

What Is MCP?

Before introducing Chrome DevTools MCP, it’s worth understanding MCP (Model Context Protocol) first.

MCP is an open standard introduced by Anthropic in 2024, aimed at letting AI assistants securely connect to various data sources and tools. Simply put, it’s like the AI’s “USB port”—through a unified protocol, different AI clients can plug into all kinds of external capabilities.

Traditional AI conversations are a closed “question-and-answer” mode, but MCP breaks that limitation. It allows AI to call external tools, fetch real-time data, and perform concrete operations during a conversation. This turns AI from a mere “chatbot” into an “intelligent agent” that can actually get things done.

What Is Chrome DevTools MCP?

Chrome DevTools MCP is an MCP server officially released by Google’s Chrome team. It lets AI coding assistants (such as Claude, Cursor, Copilot, Gemini, etc.) control and inspect a live Chrome browser instance.

In other words, you can just tell the AI:

“Analyze the performance bottlenecks of https://example.com for me”

The AI will automatically open Chrome, visit the site, record a performance trace, analyze the data, and then give you a detailed performance report.

You don’t need to manually open DevTools, click the Performance panel, start recording, stop recording, and analyze the results—the AI does all of it automatically.

Why Do We Need This Tool?

1. Performance Analysis Has Never Been This Simple

In the past, doing performance optimization you had to:

  • Manually open Chrome DevTools
  • Switch to the Performance panel
  • Click the record button
  • Perform the operations to be analyzed
  • Stop recording
  • Hunt for bottlenecks in the waterfall chart

Now you only need one sentence:

“Check the performance problems on this page for me”

2. Automated Testing Is More Reliable

Many frontend developers have used Selenium or Puppeteer for automated testing, but writing test scripts is often time-consuming and laborious. Chrome DevTools MCP provides 29 dedicated tools covering input automation, navigation, network monitoring, debugging, and more, letting AI directly operate the browser.

3. Debugging Efficiency Is Greatly Improved

When you hit a production bug, you can have the AI simulate the user’s action path, automatically capture console errors and failed network requests, and even screenshot the problem scene. The AI integrates all the information to help you quickly locate the root cause.

4. No Context Switching Needed

The best part is—you don’t need to leave the conversation interface. While discussing a technical solution with the AI, you have it verify ideas directly in the browser. The whole flow happens in one go.

Core Features at a Glance

Chrome DevTools MCP provides 6 categories, 29 tools in total:

Category Number of tools Typical features
Input automation 9 Click, type, scroll, form submission
Navigation automation 6 Page navigation, forward/back, refresh
Emulation 2 Device emulation, geolocation emulation
Performance 4 Record performance traces, analyze Core Web Vitals
Network 2 Intercept requests, analyze network waterfall
Debugging 6 View console logs, screenshots, execute JavaScript

Performance Analysis Capabilities

This is the feature I value most. Chrome DevTools MCP uses the real Chrome DevTools to record performance traces, and retrieves real-user data through Google’s CrUX (Chrome User Experience Report) API, combining lab data and field data to give a comprehensive performance analysis.

Smart Waiting Mechanism

Unlike simple script execution, MCP has a built-in smart waiting mechanism. When you have the AI perform a “click button” operation, it automatically waits for the page response to complete, ensuring each step is stable and reliable.

Installation and Configuration

Requirements

  • Node.js v20.19 or newer
  • Chrome stable or newer
  • npm

Basic Installation

The simplest config (works for Claude, Cursor, VS Code, etc.):

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

Configuration for Each Client

Claude Code:

claude mcp add chrome-devtools --scope user npx chrome-devtools-mcp@latest

Cursor:
Go to Settings → MCP → New MCP Server, and enter:

  • Name: “chrome-devtools”
  • Command: “npx -y chrome-devtools-mcp@latest”

VS Code / Copilot:

code --add-mcp '{"name":"io.github.ChromeDevTools/chrome-devtools-mcp","command":"npx","args":["-y","chrome-devtools-mcp"],"env":{}}'

Gemini CLI:

gemini mcp add chrome-devtools npx chrome-devtools-mcp@latest

Advanced Configuration Options

{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": [
"chrome-devtools-mcp@latest",
"--headless", // headless mode
"--isolated", // use a temporary user directory
"--channel=canary", // use Chrome Canary
"--viewport=1280x720" // set viewport size
]
}
}
}

Slim Mode

If you only need basic browser operations (navigation, executing scripts, screenshots), you can use slim mode:

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

Slim mode exposes only 3 tools, starts faster, and uses fewer resources.

Connecting to an Already-Running Chrome

If you want the AI to operate the Chrome instance you’re currently browsing (for example, to keep your login state):

Option 1: Auto-connect (Chrome 144+):

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

Then visit “chrome://inspect/#remote-debugging” in Chrome to enable remote debugging.

Option 2: Manually specify the debug port:

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

Launch Chrome with the parameters:

# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--user-data-dir=/tmp/chrome-profile

# Linux
/usr/bin/google-chrome \
--remote-debugging-port=9222 \
--user-data-dir=/tmp/chrome-profile

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

Real-World Use Cases

Scenario 1: Performance Optimization

Me: Analyze the performance of https://my-site.com and find out why it loads slowly

The AI will:

  1. Open the browser and visit the site
  2. Record a performance trace
  3. Analyze Core Web Vitals metrics like LCP, FID, CLS
  4. Identify resource-loading bottlenecks
  5. Give optimization suggestions

Scenario 2: Debugging a Bug

Me: After the user clicks the submit button, the page freezes. Reproduce this problem for me

The AI will:

  1. Open the target page
  2. Simulate the user’s action flow
  3. Monitor console errors
  4. Capture network request status
  5. Screenshot the problem scene
  6. Analyze and provide fix suggestions

Scenario 3: Automated Testing

Me: Test the login flow for me and verify the full path from the homepage to the personal center

The AI will:

  1. Visit the homepage
  2. Click the login button
  3. Enter the test account and password
  4. Submit the form
  5. Verify the redirect is correct
  6. Check the elements on the personal center page

Scenario 4: Competitor Analysis

Me: Compare the homepage loading performance of https://competitor.com and our product

The AI will:

  1. Visit both websites separately
  2. Record performance traces
  3. Compare key metrics
  4. Generate a comparison report

Privacy and Security Notes

When using Chrome DevTools MCP, note the following:

  1. Browser data exposure: the MCP client can access all data in the browser, including cookies, localStorage, etc. Don’t keep sensitive information in the browser.

  2. CrUX data sharing: by default, the performance tools send URLs to Google’s CrUX API to fetch real user experience data. This can be disabled via .

  3. Usage statistics: Google collects usage statistics to improve the tool. This can be disabled via or by running in a CI environment.

  4. Remote debugging risks: after enabling , any application that can reach that port can control the browser. Don’t enable the debug port while visiting sensitive websites.

Verifying the Installation

Once configured, you can test with this prompt:

Check the performance of https://developers.chrome.com

If everything works, the AI will open the browser, visit the site, record a performance trace, and return an analysis report.

Final Words

Chrome DevTools MCP represents a new direction in AI-assisted development—from “showing code to the AI” to “letting the AI directly operate tools.” It combines the power of Chrome DevTools with the AI’s intelligent analysis, making frontend development and debugging more efficient.

This tool is still in a phase of rapid development, and the Google team keeps adding new features. If you often use an AI coding assistant, I strongly recommend trying Chrome DevTools MCP—it may well change your workflow.

GitHub repository: https://github.com/ChromeDevTools/chrome-devtools-mcp


This article partly references the Chrome DevTools MCP official documentation. Tool features may change with version updates; please refer to the official documentation.

文章作者:阿文
文章链接: https://www.awen.me/post/5690fd3e.html
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 阿文的博客!
本文于 2026-03-09 13:16 发布,已超过半年(221天),请注意甄别内容是否已过期。

评论

0 条评论
😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️✋ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐⛎ ♈♉♊ ♋♌♍ ♎♏♐ ♑♒♓ 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘❌⭕ 🛑⛔📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭❗ ❕❓❔ ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️✅ 🈯💹❇️ ✳️❎🌐 💠Ⓜ️🌀 💤🏧🚾 ♿🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️
加载中...

留言反馈

😀😃😄 😁😅😂 🤣😊😇 🙂🙃😉 😌😍🥰 😘😗😙 😚😋😛 😝😜🤪 🤨🧐🤓 😎🥸🤩 🥳😏😒 😞😔😟 😕🙁☹️ 😣😖😫 😩🥺😢 😭😤😠 😡🤬🤯 😳🥵🥶 😱😨😰 😥😓🤗 🤔🤭🤫 🤥😶😐 😑😬🙄 😯😦😧 😮😲🥱 😴🤤😪 😵🤐🥴 🤢🤮🤧 😷🤒🤕 🤑🤠😈 👿👹👺 🤡💩👻 💀☠️👽 👾🤖🎃 😺😸😹 😻😼😽 🙀😿😾 👍👎👏 🙌👐🤲 🤝🤜🤛 ✌️🤞🤟 🤘👌🤏 👈👉👆 👇☝️✋ 🤚🖐️🖖 👋🤙💪 🦾🖕✍️ 🙏💅🤳 💯💢💥 💫💦💨 🕳️💣💬 👁️‍🗨️🗨️🗯️ 💭💤❤️ 🧡💛💚 💙💜🖤 🤍🤎💔 ❣️💕💞 💓💗💖 💘💝💟 ☮️✝️☪️ 🕉️☸️✡️ 🔯🕎☯️ ☦️🛐⛎ ♈♉♊ ♋♌♍ ♎♏♐ ♑♒♓ 🆔⚛️🉑 ☢️☣️📴 📳🈶🈚 🈸🈺🈷️ ✴️🆚💮 🉐㊙️㊗️ 🈴🈵🈹 🈲🅰️🅱️ 🆎🆑🅾️ 🆘❌⭕ 🛑⛔📛 🚫💯💢 ♨️🚷🚯 🚳🚱🔞 📵🚭❗ ❕❓❔ ‼️⁉️🔅 🔆〽️⚠️ 🚸🔱⚜️ 🔰♻️✅ 🈯💹❇️ ✳️❎🌐 💠Ⓜ️🌀 💤🏧🚾 ♿🅿️🈳 🈂🛂🛃 🛄🛅🛗 🚀🛸🚁 🚉🚆🚅 ✈️🛫🛬 🛩️💺🛰️