chrome-devtools-mcp 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -20
- package/build/src/BrowserManager.js +27 -18
- package/build/src/McpContext.js +435 -87
- package/build/src/McpPage.js +189 -59
- package/build/src/McpResponse.js +61 -44
- package/build/src/TextSnapshot.js +37 -18
- package/build/src/ToolHandler.js +256 -135
- package/build/src/bin/chrome-devtools-mcp-main.js +6 -4
- package/build/src/bin/chrome-devtools.js +4 -4
- package/build/src/collectors/PageCollector.js +13 -9
- package/build/src/collectors/ServiceWorkerCollector.js +2 -2
- package/build/src/collectors/constants.js +7 -0
- package/build/src/config/ConfigParser.js +44 -149
- package/build/src/config/ConfigWatcher.js +3 -2
- package/build/src/config/ServerConfig.js +251 -0
- package/build/src/config/browser-options.js +13 -4
- package/build/src/config/cli-options.js +35 -19
- package/build/src/config/mcp-options.js +61 -35
- package/build/src/config/puppeteer-options.js +4 -2
- package/build/src/daemon/client.js +3 -3
- package/build/src/daemon/daemon.js +7 -3
- package/build/src/daemon/utils.js +2 -1
- package/build/src/devtools/DevToolsCommentBridge.js +28 -5
- package/build/src/devtools/DevtoolsUtils.js +49 -12
- package/build/src/formatters/ConsoleFormatter.js +28 -1
- package/build/src/formatters/HeapSnapshotFormatter.js +14 -18
- package/build/src/formatters/NetworkFormatter.js +54 -15
- package/build/src/formatters/RemoteObjectFormatter.js +231 -0
- package/build/src/formatters/SnapshotFormatter.js +13 -3
- package/build/src/index.js +256 -104
- package/build/src/processors/HeapSnapshotManager.js +390 -128
- package/build/src/third_party/THIRD_PARTY_NOTICES +542 -445
- package/build/src/third_party/bundled-packages.json +2 -2
- package/build/src/third_party/cli.js +9239 -0
- package/build/src/third_party/devtools-formatter-worker.js +3089 -2438
- package/build/src/third_party/devtools-heap-snapshot-worker.js +172 -1
- package/build/src/third_party/index.js +52247 -55764
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +54576 -52174
- package/build/src/tools/ToolDefinition.js +90 -12
- package/build/src/tools/comments.js +42 -3
- package/build/src/tools/console.js +6 -4
- package/build/src/tools/css.js +1 -0
- package/build/src/tools/emulation.js +5 -4
- package/build/src/tools/extensions.js +5 -0
- package/build/src/tools/input.js +21 -6
- package/build/src/tools/lighthouse.js +24 -8
- package/build/src/tools/memory.js +59 -53
- package/build/src/tools/network.js +5 -4
- package/build/src/tools/pages.js +48 -6
- package/build/src/tools/performance.js +7 -4
- package/build/src/tools/pwa.js +7 -0
- package/build/src/tools/screencast.js +3 -1
- package/build/src/tools/screenshot.js +23 -7
- package/build/src/tools/script.js +38 -6
- package/build/src/tools/slim/tools.js +21 -5
- package/build/src/tools/snapshot.js +13 -3
- package/build/src/tools/thirdPartyDeveloper.js +3 -1
- package/build/src/tools/webmcp.js +2 -0
- package/build/src/utils/TaskRunner.js +136 -0
- package/build/src/utils/WaitForHelper.js +1 -1
- package/build/src/utils/bytes.js +2 -12
- package/build/src/utils/check-for-updates.js +1 -1
- package/build/src/utils/disclaimers.js +27 -0
- package/build/src/utils/keyboard.js +14 -2
- package/build/src/utils/logger.js +69 -0
- package/build/src/utils/resourceType.js +27 -0
- package/build/src/utils/text.js +29 -0
- package/build/src/utils/timeout.js +14 -0
- package/build/src/utils/url.js +41 -0
- package/build/src/version.js +1 -1
- package/package.json +5 -4
- package/skills/a11y-debugging/SKILL.md +3 -8
package/README.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
[](https://npmjs.org/package/chrome-devtools-mcp)
|
|
4
4
|
|
|
5
5
|
Chrome DevTools for agents (`chrome-devtools-mcp`) lets your coding agent (such as Antigravity, Claude, Cursor or Copilot)
|
|
6
|
-
control and inspect a live Chrome browser. It
|
|
7
|
-
(MCP) server
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
control and inspect a live Chrome browser. It is available as a
|
|
7
|
+
Model-Context-Protocol (MCP) server and as a [CLI][cli]. Both give your AI
|
|
8
|
+
coding assistant access to the full power of Chrome DevTools for reliable
|
|
9
|
+
automation, in-depth debugging, and performance analysis.
|
|
10
10
|
|
|
11
|
-
[Tool reference][tool-reference] | [Changelog][changelog] | [Contributing][contributing] | [Troubleshooting][troubleshooting] | [Design Principles][design-principles]
|
|
11
|
+
[Tool reference][tool-reference] | [CLI][cli] | [Skills][skills] | [Changelog][changelog] | [Contributing][contributing] | [Troubleshooting][troubleshooting] | [Design Principles][design-principles]
|
|
12
12
|
|
|
13
13
|
## Key features
|
|
14
14
|
|
|
@@ -83,21 +83,6 @@ Add the following config to your MCP client:
|
|
|
83
83
|
> [!NOTE]
|
|
84
84
|
> Using `chrome-devtools-mcp@latest` ensures that your MCP client will always use the latest version of the Chrome DevTools MCP server.
|
|
85
85
|
|
|
86
|
-
If you are interested in doing only basic browser tasks, use the `--slim` mode:
|
|
87
|
-
|
|
88
|
-
```json
|
|
89
|
-
{
|
|
90
|
-
"mcpServers": {
|
|
91
|
-
"chrome-devtools": {
|
|
92
|
-
"command": "npx",
|
|
93
|
-
"args": ["-y", "chrome-devtools-mcp@latest", "--slim", "--headless"]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
See [Slim tool reference][slim-tool-reference].
|
|
100
|
-
|
|
101
86
|
### MCP Client configuration
|
|
102
87
|
|
|
103
88
|
For setup instructions specific to your editor or agent (e.g. Antigravity, Claude Code, Cursor, VS Code), please see our [Client Configurations Guide][client-configurations-guide].
|
|
@@ -115,6 +100,70 @@ Your MCP client should open the browser and record a performance trace.
|
|
|
115
100
|
> [!NOTE]
|
|
116
101
|
> The MCP server will start the browser automatically once the MCP client uses a tool that requires a running browser instance. Connecting to the Chrome DevTools MCP server on its own will not automatically start the browser.
|
|
117
102
|
|
|
103
|
+
## CLI
|
|
104
|
+
|
|
105
|
+
The package also includes the `chrome-devtools` CLI. Use it to control the browser from your terminal without MCP:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
npm i chrome-devtools-mcp@latest -g
|
|
109
|
+
chrome-devtools navigate_page 1 --url "https://developers.chrome.com"
|
|
110
|
+
chrome-devtools take_screenshot 1 --filePath screenshot.png
|
|
111
|
+
chrome-devtools stop
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
See the [CLI guide][cli] for all commands and options.
|
|
115
|
+
|
|
116
|
+
## Skills
|
|
117
|
+
|
|
118
|
+
The package includes [skills](./skills) that teach your agent how to use Chrome DevTools:
|
|
119
|
+
|
|
120
|
+
| Skill | Use it to |
|
|
121
|
+
| --------------------------------------------------------- | ----------------------------------------------- |
|
|
122
|
+
| [`chrome-devtools`](./skills/chrome-devtools) | Debug and automate pages with the MCP tools. |
|
|
123
|
+
| [`chrome-devtools-cli`](./skills/chrome-devtools-cli) | Run the CLI and write shell scripts with it. |
|
|
124
|
+
| [`a11y-debugging`](./skills/a11y-debugging) | Audit and fix accessibility issues. |
|
|
125
|
+
| [`cookie-debugging`](./skills/cookie-debugging) | Debug cookies, sessions, and authentication. |
|
|
126
|
+
| [`debug-optimize-lcp`](./skills/debug-optimize-lcp) | Debug and improve Largest Contentful Paint. |
|
|
127
|
+
| [`memory-leak-debugging`](./skills/memory-leak-debugging) | Find and fix memory leaks. |
|
|
128
|
+
| [`troubleshooting`](./skills/troubleshooting) | Fix connection problems between MCP and Chrome. |
|
|
129
|
+
|
|
130
|
+
### Install skills as a plugin
|
|
131
|
+
|
|
132
|
+
A plugin installs the MCP server and all skills, including the CLI skill:
|
|
133
|
+
|
|
134
|
+
- **Claude Code:** Run `/plugin marketplace add ChromeDevTools/chrome-devtools-mcp`, then `/plugin install chrome-devtools-mcp@chrome-devtools-plugins`.
|
|
135
|
+
- **Copilot / VS Code:** Run **Chat: Install Plugin From Source** and enter `ChromeDevTools/chrome-devtools-mcp`.
|
|
136
|
+
- **Gemini CLI:** Run `gemini extensions install --auto-update https://github.com/ChromeDevTools/chrome-devtools-mcp`.
|
|
137
|
+
|
|
138
|
+
See the [Client Configurations Guide][client-configurations-guide] for more information.
|
|
139
|
+
|
|
140
|
+
### Install skills manually
|
|
141
|
+
|
|
142
|
+
If your agent does not support plugins, copy the skill folders into the skills directory of your agent. The npm package contains the skills:
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
npm i chrome-devtools-mcp@latest -g
|
|
146
|
+
# Example for Claude Code. Use the skills directory of your agent.
|
|
147
|
+
mkdir -p ~/.claude/skills
|
|
148
|
+
cp -R "$(npm root -g)/chrome-devtools-mcp/skills/chrome-devtools-cli" ~/.claude/skills/
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
> [!IMPORTANT]
|
|
152
|
+
> The `chrome-devtools-cli` skill requires the CLI. Install the package globally before you use the skill.
|
|
153
|
+
|
|
154
|
+
### Keep skills up to date
|
|
155
|
+
|
|
156
|
+
Skills describe the tools of a specific version. Update the skills each time you update the MCP server or the CLI. Outdated skills can tell your agent to use tools or parameters that changed.
|
|
157
|
+
|
|
158
|
+
- **Plugins:** Use the update command of the plugin manager of your agent. The Gemini CLI command above enables automatic updates with `--auto-update`.
|
|
159
|
+
- **Manual installs:** Update the package, then copy the skill folders again:
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
npm i chrome-devtools-mcp@latest -g
|
|
163
|
+
mkdir -p ~/.claude/skills
|
|
164
|
+
cp -R "$(npm root -g)/chrome-devtools-mcp/skills/chrome-devtools-cli" ~/.claude/skills/
|
|
165
|
+
```
|
|
166
|
+
|
|
118
167
|
## Tools
|
|
119
168
|
|
|
120
169
|
If you run into any issues, checkout our [troubleshooting guide][troubleshooting].
|
|
@@ -124,6 +173,8 @@ See the full [Tool Reference][tool-reference] for a complete list of all support
|
|
|
124
173
|
|
|
125
174
|
Find the complete list of server parameters (e.g., `--headless`, `--isolated`, `--slim`) and how to configure WebSocket connections in the [Configuration Guide][configuration-guide].
|
|
126
175
|
|
|
176
|
+
For basic browser tasks only, the `--slim` flag exposes a reduced set of tools. See the [Slim tool reference][slim-tool-reference].
|
|
177
|
+
|
|
127
178
|
## Advanced Usage
|
|
128
179
|
|
|
129
180
|
For advanced features such as handling concurrent sessions, persistent user data directories, connecting to a running Chrome instance instead of starting a new one, or debugging on Android, see our [Advanced Usage Guide][advanced-usage-guide].
|
|
@@ -141,6 +192,7 @@ For a reference implementation, see the [Gemini CLI browser agent documentation]
|
|
|
141
192
|
[configuration-guide]: ./docs/configuration.md
|
|
142
193
|
[contributing]: ./CONTRIBUTING.md
|
|
143
194
|
[design-principles]: ./docs/design-principles.md
|
|
195
|
+
[skills]: #skills
|
|
144
196
|
[slim-tool-reference]: ./docs/slim-tool-reference.md
|
|
145
197
|
[tool-reference]: ./docs/tool-reference.md
|
|
146
198
|
[troubleshooting]: ./docs/troubleshooting.md
|
|
@@ -60,8 +60,8 @@ import { execSync } from 'node:child_process';
|
|
|
60
60
|
import fs from 'node:fs';
|
|
61
61
|
import os from 'node:os';
|
|
62
62
|
import path from 'node:path';
|
|
63
|
-
import { Mutex, puppeteer } from './third_party/index.js';
|
|
64
|
-
import { logger, puppeteerLogger } from './utils/logger.js';
|
|
63
|
+
import { Mutex, puppeteer, } from './third_party/index.js';
|
|
64
|
+
import { logger, puppeteerLogger, redactConnectOptionsForLogging, } from './utils/logger.js';
|
|
65
65
|
import { isAllowedUrl } from './utils/url.js';
|
|
66
66
|
/**
|
|
67
67
|
* Identity token for an in-flight connect/launch attempt. Instances carry no
|
|
@@ -76,11 +76,11 @@ export class BrowserManager {
|
|
|
76
76
|
#initPromise;
|
|
77
77
|
#mutex = new Mutex();
|
|
78
78
|
#closingCount = 0;
|
|
79
|
-
#
|
|
79
|
+
#config;
|
|
80
80
|
#options;
|
|
81
81
|
#browserAttempt = new BrowserAttempt();
|
|
82
|
-
constructor(
|
|
83
|
-
this.#
|
|
82
|
+
constructor(config, options = {}) {
|
|
83
|
+
this.#config = config;
|
|
84
84
|
this.#options = options;
|
|
85
85
|
}
|
|
86
86
|
static makeTargetFilter(enableExtensions = false) {
|
|
@@ -207,8 +207,9 @@ export class BrowserManager {
|
|
|
207
207
|
* McpContext initialization built on it — if ensureBrowser() already
|
|
208
208
|
* resolved and it's that later step hanging (e.g. a dead CDP transport),
|
|
209
209
|
* the token rotation alone does nothing, since #browser is already
|
|
210
|
-
* cached. Safe to forget unconditionally here:
|
|
211
|
-
*
|
|
210
|
+
* cached. Safe to forget unconditionally here: a tool call that already
|
|
211
|
+
* received a Browser keeps using it, so forgetting the cached value only
|
|
212
|
+
* makes the next ensureBrowser() reconnect.
|
|
212
213
|
*/
|
|
213
214
|
abandonPendingAttempt() {
|
|
214
215
|
this.#browserAttempt = new BrowserAttempt();
|
|
@@ -216,26 +217,28 @@ export class BrowserManager {
|
|
|
216
217
|
this.#forgetCurrentBrowser();
|
|
217
218
|
}
|
|
218
219
|
async #initBrowser() {
|
|
219
|
-
if (this.#
|
|
220
|
-
this.#
|
|
221
|
-
this.#
|
|
220
|
+
if (this.#config.resolved.browserUrl ||
|
|
221
|
+
this.#config.resolved.wsEndpoint ||
|
|
222
|
+
this.#config.resolved.autoConnect) {
|
|
222
223
|
return await this.#connect();
|
|
223
224
|
}
|
|
224
225
|
return await this.#launch();
|
|
225
226
|
}
|
|
226
227
|
async #launch() {
|
|
227
|
-
const { channel, executablePath, headless, isolated = false, categoryExtensions: enableExtensions, viaCli, viewport, acceptInsecureCerts, experimentalDevtools: devtools = false, blockedUrlPattern: blocklist, allowedUrlPattern: allowlist, ignoreDefaultChromeArg, proxyServer, } = this.#
|
|
228
|
+
const { channel, executablePath, headless, isolated = false, categoryExtensions: enableExtensions, viaCli, viewport, acceptInsecureCerts, experimentalDevtools: devtools = false, blockedUrlPattern: blocklist, allowedUrlPattern: allowlist, ignoreDefaultChromeArg, proxyServer, } = this.#config.resolved;
|
|
228
229
|
const profileDirName = channel && channel !== 'stable'
|
|
229
230
|
? `chrome-profile-${channel}`
|
|
230
231
|
: 'chrome-profile';
|
|
231
|
-
let userDataDir = this.#
|
|
232
|
+
let userDataDir = this.#config.resolved.userDataDir;
|
|
232
233
|
if (!isolated && !userDataDir) {
|
|
233
234
|
userDataDir = path.join(os.homedir(), '.cache', viaCli ? 'chrome-devtools-mcp-cli' : 'chrome-devtools-mcp', profileDirName);
|
|
234
235
|
await fs.promises.mkdir(userDataDir, {
|
|
235
236
|
recursive: true,
|
|
236
237
|
});
|
|
237
238
|
}
|
|
238
|
-
const args = [
|
|
239
|
+
const args = [
|
|
240
|
+
...(this.#config.resolved.chromeArg ?? []),
|
|
241
|
+
];
|
|
239
242
|
if (proxyServer) {
|
|
240
243
|
args.push(`--proxy-server=${proxyServer}`);
|
|
241
244
|
}
|
|
@@ -273,6 +276,12 @@ export class BrowserManager {
|
|
|
273
276
|
blocklist,
|
|
274
277
|
allowlist,
|
|
275
278
|
logger: puppeteerLogger,
|
|
279
|
+
// The entry points own signal handling and call close(), which
|
|
280
|
+
// closes the browser gracefully. Puppeteer's handlers would SIGKILL
|
|
281
|
+
// Chrome synchronously on the same signal and win the race.
|
|
282
|
+
handleSIGINT: false,
|
|
283
|
+
handleSIGTERM: false,
|
|
284
|
+
handleSIGHUP: false,
|
|
276
285
|
});
|
|
277
286
|
if (this.#options.logFile) {
|
|
278
287
|
// FIXME: we are probably subscribing too late to catch startup logs. We
|
|
@@ -314,9 +323,9 @@ export class BrowserManager {
|
|
|
314
323
|
}
|
|
315
324
|
}
|
|
316
325
|
async #connect() {
|
|
317
|
-
const { browserUrl: browserURL, wsEndpoint, wsHeaders, autoConnect: isAutoConnect, userDataDir, blockedUrlPattern: blocklist, allowedUrlPattern: allowlist, categoryExtensions: enableExtensions, } = this.#
|
|
326
|
+
const { browserUrl: browserURL, wsEndpoint, wsHeaders, autoConnect: isAutoConnect, userDataDir, blockedUrlPattern: blocklist, allowedUrlPattern: allowlist, categoryExtensions: enableExtensions, } = this.#config.resolved;
|
|
318
327
|
// Important: only pass channel, if autoConnect is true.
|
|
319
|
-
const channel = isAutoConnect ? this.#
|
|
328
|
+
const channel = isAutoConnect ? this.#config.resolved.channel : undefined;
|
|
320
329
|
const connectOptions = {
|
|
321
330
|
targetFilter: _a.makeTargetFilter(enableExtensions),
|
|
322
331
|
defaultViewport: null,
|
|
@@ -329,7 +338,7 @@ export class BrowserManager {
|
|
|
329
338
|
// periodically and terminates it on a missed pong, which rejects the
|
|
330
339
|
// in-flight CDP calls and fires `disconnected` so #evictIfCurrent()
|
|
331
340
|
// drops the stale handle. Without this, such a call would hang until
|
|
332
|
-
// protocolTimeout
|
|
341
|
+
// protocolTimeout inside the context queue.
|
|
333
342
|
wsOptions: {
|
|
334
343
|
keepAlive: true,
|
|
335
344
|
headers: wsHeaders,
|
|
@@ -343,8 +352,8 @@ export class BrowserManager {
|
|
|
343
352
|
connectOptions.browserURL = browserURL;
|
|
344
353
|
}
|
|
345
354
|
else if (channel || userDataDir) {
|
|
355
|
+
autoConnect = true;
|
|
346
356
|
if (userDataDir) {
|
|
347
|
-
autoConnect = true;
|
|
348
357
|
// TODO: re-expose this logic via Puppeteer.
|
|
349
358
|
const portPath = path.join(userDataDir, 'DevToolsActivePort');
|
|
350
359
|
try {
|
|
@@ -384,7 +393,7 @@ export class BrowserManager {
|
|
|
384
393
|
else {
|
|
385
394
|
throw new Error('Either browserURL, wsEndpoint, channel or userDataDir must be provided');
|
|
386
395
|
}
|
|
387
|
-
logger?.('Connecting Puppeteer to ', JSON.stringify(connectOptions));
|
|
396
|
+
logger?.('Connecting Puppeteer to ', JSON.stringify(redactConnectOptionsForLogging(connectOptions)));
|
|
388
397
|
try {
|
|
389
398
|
const connected = await puppeteer.connect(connectOptions);
|
|
390
399
|
logger?.('Connected Puppeteer');
|