@mcp-b/chrome-devtools-mcp 0.12.0-beta.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.
Files changed (41) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +554 -0
  3. package/build/src/DevToolsConnectionAdapter.js +69 -0
  4. package/build/src/DevtoolsUtils.js +206 -0
  5. package/build/src/McpContext.js +499 -0
  6. package/build/src/McpResponse.js +396 -0
  7. package/build/src/Mutex.js +37 -0
  8. package/build/src/PageCollector.js +283 -0
  9. package/build/src/WaitForHelper.js +139 -0
  10. package/build/src/browser.js +134 -0
  11. package/build/src/cli.js +213 -0
  12. package/build/src/formatters/consoleFormatter.js +121 -0
  13. package/build/src/formatters/networkFormatter.js +77 -0
  14. package/build/src/formatters/snapshotFormatter.js +73 -0
  15. package/build/src/index.js +21 -0
  16. package/build/src/issue-descriptions.js +39 -0
  17. package/build/src/logger.js +27 -0
  18. package/build/src/main.js +130 -0
  19. package/build/src/polyfill.js +7 -0
  20. package/build/src/third_party/index.js +16 -0
  21. package/build/src/tools/ToolDefinition.js +20 -0
  22. package/build/src/tools/categories.js +24 -0
  23. package/build/src/tools/console.js +85 -0
  24. package/build/src/tools/emulation.js +87 -0
  25. package/build/src/tools/input.js +268 -0
  26. package/build/src/tools/network.js +106 -0
  27. package/build/src/tools/pages.js +237 -0
  28. package/build/src/tools/performance.js +147 -0
  29. package/build/src/tools/screenshot.js +84 -0
  30. package/build/src/tools/script.js +71 -0
  31. package/build/src/tools/snapshot.js +52 -0
  32. package/build/src/tools/tools.js +31 -0
  33. package/build/src/tools/webmcp.js +233 -0
  34. package/build/src/trace-processing/parse.js +84 -0
  35. package/build/src/transports/WebMCPBridgeScript.js +196 -0
  36. package/build/src/transports/WebMCPClientTransport.js +276 -0
  37. package/build/src/transports/index.js +7 -0
  38. package/build/src/utils/keyboard.js +296 -0
  39. package/build/src/utils/pagination.js +49 -0
  40. package/build/src/utils/types.js +6 -0
  41. package/package.json +87 -0
package/README.md ADDED
@@ -0,0 +1,554 @@
1
+ # Chrome DevTools MCP
2
+
3
+ [![npm chrome-devtools-mcp package](https://img.shields.io/npm/v/chrome-devtools-mcp.svg)](https://npmjs.org/package/chrome-devtools-mcp)
4
+
5
+ `chrome-devtools-mcp` lets your coding agent (such as Gemini, Claude, Cursor or Copilot)
6
+ control and inspect a live Chrome browser. It acts as a Model-Context-Protocol
7
+ (MCP) server, giving your AI coding assistant access to the full power of
8
+ Chrome DevTools for reliable automation, in-depth debugging, and performance analysis.
9
+
10
+ ## [Tool reference](./docs/tool-reference.md) | [Changelog](./CHANGELOG.md) | [Contributing](./CONTRIBUTING.md) | [Troubleshooting](./docs/troubleshooting.md) | [Design Principles](./docs/design-principles.md)
11
+
12
+ ## Key features
13
+
14
+ - **Get performance insights**: Uses [Chrome
15
+ DevTools](https://github.com/ChromeDevTools/devtools-frontend) to record
16
+ traces and extract actionable performance insights.
17
+ - **Advanced browser debugging**: Analyze network requests, take screenshots and
18
+ check the browser console.
19
+ - **Reliable automation**. Uses
20
+ [puppeteer](https://github.com/puppeteer/puppeteer) to automate actions in
21
+ Chrome and automatically wait for action results.
22
+
23
+ ## Disclaimers
24
+
25
+ `chrome-devtools-mcp` exposes content of the browser instance to the MCP clients
26
+ allowing them to inspect, debug, and modify any data in the browser or DevTools.
27
+ Avoid sharing sensitive or personal information that you don't want to share with
28
+ MCP clients.
29
+
30
+ ## Requirements
31
+
32
+ - [Node.js](https://nodejs.org/) v20.19 or a newer [latest maintenance LTS](https://github.com/nodejs/Release#release-schedule) version.
33
+ - [Chrome](https://www.google.com/chrome/) current stable version or newer.
34
+ - [npm](https://www.npmjs.com/).
35
+
36
+ ## Getting started
37
+
38
+ Add the following config to your MCP client:
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "chrome-devtools": {
44
+ "command": "npx",
45
+ "args": ["-y", "chrome-devtools-mcp@latest"]
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ > [!NOTE]
52
+ > Using `chrome-devtools-mcp@latest` ensures that your MCP client will always use the latest version of the Chrome DevTools MCP server.
53
+
54
+ ### MCP Client configuration
55
+
56
+ <details>
57
+ <summary>Amp</summary>
58
+ Follow https://ampcode.com/manual#mcp and use the config provided above. You can also install the Chrome DevTools MCP server using the CLI:
59
+
60
+ ```bash
61
+ amp mcp add chrome-devtools -- npx chrome-devtools-mcp@latest
62
+ ```
63
+
64
+ </details>
65
+
66
+ <details>
67
+ <summary>Antigravity</summary>
68
+
69
+ To use the Chrome DevTools MCP server follow the instructions from <a href="https://antigravity.google/docs/mcp">Antigravity's docs<a/> to install a custom MCP server. Add the following config to the MCP servers config:
70
+
71
+ ```bash
72
+ {
73
+ "mcpServers": {
74
+ "chrome-devtools": {
75
+ "command": "npx",
76
+ "args": [
77
+ "chrome-devtools-mcp@latest",
78
+ "--browser-url=http://127.0.0.1:9222",
79
+ "-y"
80
+ ]
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ This will make the Chrome DevTools MCP server automatically connect to the browser that Antigravity is using. If you are not using port 9222, make sure to adjust accordingly.
87
+
88
+ Chrome DevTools MCP will not start the browser instance automatically using this approach as as the Chrome DevTools MCP server runs in Antigravity's built-in browser. If the browser is not already running, you have to start it first by clicking the Chrome icon at the top right corner.
89
+
90
+ </details>
91
+
92
+ <details>
93
+ <summary>Claude Code</summary>
94
+ Use the Claude Code CLI to add the Chrome DevTools MCP server (<a href="https://docs.anthropic.com/en/docs/claude-code/mcp">guide</a>):
95
+
96
+ ```bash
97
+ claude mcp add chrome-devtools npx chrome-devtools-mcp@latest
98
+ ```
99
+
100
+ </details>
101
+
102
+ <details>
103
+ <summary>Cline</summary>
104
+ Follow https://docs.cline.bot/mcp/configuring-mcp-servers and use the config provided above.
105
+ </details>
106
+
107
+ <details>
108
+ <summary>Codex</summary>
109
+ Follow the <a href="https://github.com/openai/codex/blob/main/docs/advanced.md#model-context-protocol-mcp">configure MCP guide</a>
110
+ using the standard config from above. You can also install the Chrome DevTools MCP server using the Codex CLI:
111
+
112
+ ```bash
113
+ codex mcp add chrome-devtools -- npx chrome-devtools-mcp@latest
114
+ ```
115
+
116
+ **On Windows 11**
117
+
118
+ Configure the Chrome install location and increase the startup timeout by updating `.codex/config.toml` and adding the following `env` and `startup_timeout_ms` parameters:
119
+
120
+ ```
121
+ [mcp_servers.chrome-devtools]
122
+ command = "cmd"
123
+ args = [
124
+ "/c",
125
+ "npx",
126
+ "-y",
127
+ "chrome-devtools-mcp@latest",
128
+ ]
129
+ env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" }
130
+ startup_timeout_ms = 20_000
131
+ ```
132
+
133
+ </details>
134
+
135
+ <details>
136
+ <summary>Copilot CLI</summary>
137
+
138
+ Start Copilot CLI:
139
+
140
+ ```
141
+ copilot
142
+ ```
143
+
144
+ Start the dialog to add a new MCP server by running:
145
+
146
+ ```
147
+ /mcp add
148
+ ```
149
+
150
+ Configure the following fields and press `CTRL+S` to save the configuration:
151
+
152
+ - **Server name:** `chrome-devtools`
153
+ - **Server Type:** `[1] Local`
154
+ - **Command:** `npx -y chrome-devtools-mcp@latest`
155
+
156
+ </details>
157
+
158
+ <details>
159
+ <summary>Copilot / VS Code</summary>
160
+
161
+ **Click the button to install:**
162
+
163
+ [<img src="https://mcpbadge.dev/badge-install-in-vs-code-stable-dark" alt="Install in VS Code">](https://vscode.dev/redirect/mcp/install?name=io.github.ChromeDevTools%2Fchrome-devtools-mcp&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22chrome-devtools-mcp%22%5D%2C%22env%22%3A%7B%7D%7D)
164
+
165
+ [<img src="https://mcpbadge.dev/badge-install-in-vs-code-insiders-dark" alt="Install in VS Code Insiders">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522io.github.ChromeDevTools%252Fchrome-devtools-mcp%2522%252C%2522config%2522%253A%257B%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522chrome-devtools-mcp%2522%255D%252C%2522env%2522%253A%257B%257D%257D%257D)
166
+
167
+ **Or install manually:**
168
+
169
+ Follow the MCP install <a href="https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server">guide</a>,
170
+ with the standard config from above. You can also install the Chrome DevTools MCP server using the VS Code CLI:
171
+
172
+ ```bash
173
+ code --add-mcp '{"name":"io.github.ChromeDevTools/chrome-devtools-mcp","command":"npx","args":["-y","chrome-devtools-mcp"],"env":{}}'
174
+ ```
175
+
176
+ </details>
177
+
178
+ <details>
179
+ <summary>Cursor</summary>
180
+
181
+ **Click the button to install:**
182
+
183
+ [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=chrome-devtools&config=eyJjb21tYW5kIjoibnB4IC15IGNocm9tZS1kZXZ0b29scy1tY3BAbGF0ZXN0In0%3D)
184
+
185
+ **Or install manually:**
186
+
187
+ Go to `Cursor Settings` -> `MCP` -> `New MCP Server`. Use the config provided above.
188
+
189
+ </details>
190
+
191
+ <details>
192
+ <summary>Factory CLI</summary>
193
+ Use the Factory CLI to add the Chrome DevTools MCP server (<a href="https://docs.factory.ai/cli/configuration/mcp">guide</a>):
194
+
195
+ ```bash
196
+ droid mcp add chrome-devtools "npx -y chrome-devtools-mcp@latest"
197
+ ```
198
+
199
+ </details>
200
+
201
+ <details>
202
+ <summary>Gemini CLI</summary>
203
+ Install the Chrome DevTools MCP server using the Gemini CLI.
204
+
205
+ **Project wide:**
206
+
207
+ ```bash
208
+ gemini mcp add chrome-devtools npx chrome-devtools-mcp@latest
209
+ ```
210
+
211
+ **Globally:**
212
+
213
+ ```bash
214
+ gemini mcp add -s user chrome-devtools npx chrome-devtools-mcp@latest
215
+ ```
216
+
217
+ Alternatively, follow the <a href="https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md#how-to-set-up-your-mcp-server">MCP guide</a> and use the standard config from above.
218
+
219
+ </details>
220
+
221
+ <details>
222
+ <summary>Gemini Code Assist</summary>
223
+ Follow the <a href="https://cloud.google.com/gemini/docs/codeassist/use-agentic-chat-pair-programmer#configure-mcp-servers">configure MCP guide</a>
224
+ using the standard config from above.
225
+ </details>
226
+
227
+ <details>
228
+ <summary>JetBrains AI Assistant & Junie</summary>
229
+
230
+ Go to `Settings | Tools | AI Assistant | Model Context Protocol (MCP)` -> `Add`. Use the config provided above.
231
+ The same way chrome-devtools-mcp can be configured for JetBrains Junie in `Settings | Tools | Junie | MCP Settings` -> `Add`. Use the config provided above.
232
+
233
+ </details>
234
+
235
+ <details>
236
+ <summary>Kiro</summary>
237
+
238
+ In **Kiro Settings**, go to `Configure MCP` > `Open Workspace or User MCP Config` > Use the configuration snippet provided above.
239
+
240
+ Or, from the IDE **Activity Bar** > `Kiro` > `MCP Servers` > `Click Open MCP Config`. Use the configuration snippet provided above.
241
+
242
+ </details>
243
+
244
+ <details>
245
+ <summary>Qoder</summary>
246
+
247
+ In **Qoder Settings**, go to `MCP Server` > `+ Add` > Use the configuration snippet provided above.
248
+
249
+ Alternatively, follow the <a href="https://docs.qoder.com/user-guide/chat/model-context-protocol">MCP guide</a> and use the standard config from above.
250
+
251
+ </details>
252
+
253
+ <details>
254
+ <summary>Qoder CLI</summary>
255
+
256
+ Install the Chrome DevTools MCP server using the Qoder CLI (<a href="https://docs.qoder.com/cli/using-cli#mcp-servsers">guide</a>):
257
+
258
+ **Project wide:**
259
+
260
+ ```bash
261
+ qodercli mcp add chrome-devtools -- npx chrome-devtools-mcp@latest
262
+ ```
263
+
264
+ **Globally:**
265
+
266
+ ```bash
267
+ qodercli mcp add -s user chrome-devtools -- npx chrome-devtools-mcp@latest
268
+ ```
269
+
270
+ </details>
271
+
272
+ <details>
273
+ <summary>Visual Studio</summary>
274
+
275
+ **Click the button to install:**
276
+
277
+ [<img src="https://img.shields.io/badge/Visual_Studio-Install-C16FDE?logo=visualstudio&logoColor=white" alt="Install in Visual Studio">](https://vs-open.link/mcp-install?%7B%22name%22%3A%22chrome-devtools%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22chrome-devtools-mcp%40latest%22%5D%7D)
278
+ </details>
279
+
280
+ <details>
281
+ <summary>Warp</summary>
282
+
283
+ Go to `Settings | AI | Manage MCP Servers` -> `+ Add` to [add an MCP Server](https://docs.warp.dev/knowledge-and-collaboration/mcp#adding-an-mcp-server). Use the config provided above.
284
+
285
+ </details>
286
+
287
+ <details>
288
+ <summary>Windsurf</summary>
289
+ Follow the <a href="https://docs.windsurf.com/windsurf/cascade/mcp#mcp-config-json">configure MCP guide</a>
290
+ using the standard config from above.
291
+ </details>
292
+
293
+ ### Your first prompt
294
+
295
+ Enter the following prompt in your MCP Client to check if everything is working:
296
+
297
+ ```
298
+ Check the performance of https://developers.chrome.com
299
+ ```
300
+
301
+ Your MCP client should open the browser and record a performance trace.
302
+
303
+ > [!NOTE]
304
+ > 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.
305
+
306
+ ## Tools
307
+
308
+ If you run into any issues, checkout our [troubleshooting guide](./docs/troubleshooting.md).
309
+
310
+ <!-- BEGIN AUTO GENERATED TOOLS -->
311
+
312
+ - **Input automation** (8 tools)
313
+ - [`click`](docs/tool-reference.md#click)
314
+ - [`drag`](docs/tool-reference.md#drag)
315
+ - [`fill`](docs/tool-reference.md#fill)
316
+ - [`fill_form`](docs/tool-reference.md#fill_form)
317
+ - [`handle_dialog`](docs/tool-reference.md#handle_dialog)
318
+ - [`hover`](docs/tool-reference.md#hover)
319
+ - [`press_key`](docs/tool-reference.md#press_key)
320
+ - [`upload_file`](docs/tool-reference.md#upload_file)
321
+ - **Navigation automation** (6 tools)
322
+ - [`close_page`](docs/tool-reference.md#close_page)
323
+ - [`list_pages`](docs/tool-reference.md#list_pages)
324
+ - [`navigate_page`](docs/tool-reference.md#navigate_page)
325
+ - [`new_page`](docs/tool-reference.md#new_page)
326
+ - [`select_page`](docs/tool-reference.md#select_page)
327
+ - [`wait_for`](docs/tool-reference.md#wait_for)
328
+ - **Emulation** (2 tools)
329
+ - [`emulate`](docs/tool-reference.md#emulate)
330
+ - [`resize_page`](docs/tool-reference.md#resize_page)
331
+ - **Performance** (3 tools)
332
+ - [`performance_analyze_insight`](docs/tool-reference.md#performance_analyze_insight)
333
+ - [`performance_start_trace`](docs/tool-reference.md#performance_start_trace)
334
+ - [`performance_stop_trace`](docs/tool-reference.md#performance_stop_trace)
335
+ - **Network** (2 tools)
336
+ - [`get_network_request`](docs/tool-reference.md#get_network_request)
337
+ - [`list_network_requests`](docs/tool-reference.md#list_network_requests)
338
+ - **Debugging** (5 tools)
339
+ - [`evaluate_script`](docs/tool-reference.md#evaluate_script)
340
+ - [`get_console_message`](docs/tool-reference.md#get_console_message)
341
+ - [`list_console_messages`](docs/tool-reference.md#list_console_messages)
342
+ - [`take_screenshot`](docs/tool-reference.md#take_screenshot)
343
+ - [`take_snapshot`](docs/tool-reference.md#take_snapshot)
344
+
345
+ <!-- END AUTO GENERATED TOOLS -->
346
+
347
+ ## Configuration
348
+
349
+ The Chrome DevTools MCP server supports the following configuration option:
350
+
351
+ <!-- BEGIN AUTO GENERATED OPTIONS -->
352
+
353
+ - **`--browserUrl`, `-u`**
354
+ Connect to a running, debuggable Chrome instance (e.g. `http://127.0.0.1:9222`). For more details see: https://github.com/ChromeDevTools/chrome-devtools-mcp#connecting-to-a-running-chrome-instance.
355
+ - **Type:** string
356
+
357
+ - **`--wsEndpoint`, `-w`**
358
+ WebSocket endpoint to connect to a running Chrome instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.
359
+ - **Type:** string
360
+
361
+ - **`--wsHeaders`**
362
+ Custom headers for WebSocket connection in JSON format (e.g., '{"Authorization":"Bearer token"}'). Only works with --wsEndpoint.
363
+ - **Type:** string
364
+
365
+ - **`--headless`**
366
+ Whether to run in headless (no UI) mode.
367
+ - **Type:** boolean
368
+ - **Default:** `false`
369
+
370
+ - **`--executablePath`, `-e`**
371
+ Path to custom Chrome executable.
372
+ - **Type:** string
373
+
374
+ - **`--isolated`**
375
+ If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to false.
376
+ - **Type:** boolean
377
+
378
+ - **`--userDataDir`**
379
+ Path to the user data directory for Chrome. Default is $HOME/.cache/chrome-devtools-mcp/chrome-profile$CHANNEL_SUFFIX_IF_NON_STABLE
380
+ - **Type:** string
381
+
382
+ - **`--channel`**
383
+ Specify a different Chrome channel that should be used. The default is the stable channel version.
384
+ - **Type:** string
385
+ - **Choices:** `stable`, `canary`, `beta`, `dev`
386
+
387
+ - **`--logFile`**
388
+ Path to a file to write debug logs to. Set the env variable `DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.
389
+ - **Type:** string
390
+
391
+ - **`--viewport`**
392
+ Initial viewport size for the Chrome instances started by the server. For example, `1280x720`. In headless mode, max size is 3840x2160px.
393
+ - **Type:** string
394
+
395
+ - **`--proxyServer`**
396
+ Proxy server configuration for Chrome passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.
397
+ - **Type:** string
398
+
399
+ - **`--acceptInsecureCerts`**
400
+ If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.
401
+ - **Type:** boolean
402
+
403
+ - **`--chromeArg`**
404
+ Additional arguments for Chrome. Only applies when Chrome is launched by chrome-devtools-mcp.
405
+ - **Type:** array
406
+
407
+ - **`--categoryEmulation`**
408
+ Set to false to exclude tools related to emulation.
409
+ - **Type:** boolean
410
+ - **Default:** `true`
411
+
412
+ - **`--categoryPerformance`**
413
+ Set to false to exclude tools related to performance.
414
+ - **Type:** boolean
415
+ - **Default:** `true`
416
+
417
+ - **`--categoryNetwork`**
418
+ Set to false to exclude tools related to network.
419
+ - **Type:** boolean
420
+ - **Default:** `true`
421
+
422
+ <!-- END AUTO GENERATED OPTIONS -->
423
+
424
+ Pass them via the `args` property in the JSON configuration. For example:
425
+
426
+ ```json
427
+ {
428
+ "mcpServers": {
429
+ "chrome-devtools": {
430
+ "command": "npx",
431
+ "args": [
432
+ "chrome-devtools-mcp@latest",
433
+ "--channel=canary",
434
+ "--headless=true",
435
+ "--isolated=true"
436
+ ]
437
+ }
438
+ }
439
+ }
440
+ ```
441
+
442
+ ### Connecting via WebSocket with custom headers
443
+
444
+ You can connect directly to a Chrome WebSocket endpoint and include custom headers (e.g., for authentication):
445
+
446
+ ```json
447
+ {
448
+ "mcpServers": {
449
+ "chrome-devtools": {
450
+ "command": "npx",
451
+ "args": [
452
+ "chrome-devtools-mcp@latest",
453
+ "--wsEndpoint=ws://127.0.0.1:9222/devtools/browser/<id>",
454
+ "--wsHeaders={\"Authorization\":\"Bearer YOUR_TOKEN\"}"
455
+ ]
456
+ }
457
+ }
458
+ }
459
+ ```
460
+
461
+ To get the WebSocket endpoint from a running Chrome instance, visit `http://127.0.0.1:9222/json/version` and look for the `webSocketDebuggerUrl` field.
462
+
463
+ You can also run `npx chrome-devtools-mcp@latest --help` to see all available configuration options.
464
+
465
+ ## Concepts
466
+
467
+ ### User data directory
468
+
469
+ `chrome-devtools-mcp` starts a Chrome's stable channel instance using the following user
470
+ data directory:
471
+
472
+ - Linux / macOS: `$HOME/.cache/chrome-devtools-mcp/chrome-profile-$CHANNEL`
473
+ - Windows: `%HOMEPATH%/.cache/chrome-devtools-mcp/chrome-profile-$CHANNEL`
474
+
475
+ The user data directory is not cleared between runs and shared across
476
+ all instances of `chrome-devtools-mcp`. Set the `isolated` option to `true`
477
+ to use a temporary user data dir instead which will be cleared automatically after
478
+ the browser is closed.
479
+
480
+ ### Connecting to a running Chrome instance
481
+
482
+ You can connect to a running Chrome instance by using the `--browser-url` option. This is useful if you want to use your existing Chrome profile or if you are running the MCP server in a sandboxed environment that does not allow starting a new Chrome instance.
483
+
484
+ Here is a step-by-step guide on how to connect to a running Chrome Stable instance:
485
+
486
+ **Step 1: Configure the MCP client**
487
+
488
+ Add the `--browser-url` option to your MCP client configuration. The value of this option should be the URL of the running Chrome instance. `http://127.0.0.1:9222` is a common default.
489
+
490
+ ```json
491
+ {
492
+ "mcpServers": {
493
+ "chrome-devtools": {
494
+ "command": "npx",
495
+ "args": [
496
+ "chrome-devtools-mcp@latest",
497
+ "--browser-url=http://127.0.0.1:9222"
498
+ ]
499
+ }
500
+ }
501
+ }
502
+ ```
503
+
504
+ **Step 2: Start the Chrome browser**
505
+
506
+ > [!WARNING]
507
+ > Enabling the remote debugging port opens up a debugging port on the running browser instance. Any application on your machine can connect to this port and control the browser. Make sure that you are not browsing any sensitive websites while the debugging port is open.
508
+
509
+ Start the Chrome browser with the remote debugging port enabled. Make sure to close any running Chrome instances before starting a new one with the debugging port enabled. The port number you choose must be the same as the one you specified in the `--browser-url` option in your MCP client configuration.
510
+
511
+ For security reasons, [Chrome requires you to use a non-default user data directory](https://developer.chrome.com/blog/remote-debugging-port) when enabling the remote debugging port. You can specify a custom directory using the `--user-data-dir` flag. This ensures that your regular browsing profile and data are not exposed to the debugging session.
512
+
513
+ **macOS**
514
+
515
+ ```bash
516
+ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-profile-stable
517
+ ```
518
+
519
+ **Linux**
520
+
521
+ ```bash
522
+ /usr/bin/google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-profile-stable
523
+ ```
524
+
525
+ **Windows**
526
+
527
+ ```bash
528
+ "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%TEMP%\chrome-profile-stable"
529
+ ```
530
+
531
+ **Step 3: Test your setup**
532
+
533
+ After configuring the MCP client and starting the Chrome browser, you can test your setup by running a simple prompt in your MCP client:
534
+
535
+ ```
536
+ Check the performance of https://developers.chrome.com
537
+ ```
538
+
539
+ Your MCP client should connect to the running Chrome instance and receive a performance report.
540
+
541
+ If you hit VM-to-host port forwarding issues, see the “Remote debugging between virtual machine (VM) and host fails” section in [`docs/troubleshooting.md`](./docs/troubleshooting.md#remote-debugging-between-virtual-machine-vm-and-host-fails).
542
+
543
+ For more details on remote debugging, see the [Chrome DevTools documentation](https://developer.chrome.com/docs/devtools/remote-debugging/).
544
+
545
+ ## Known limitations
546
+
547
+ ### Operating system sandboxes
548
+
549
+ Some MCP clients allow sandboxing the MCP server using macOS Seatbelt or Linux
550
+ containers. If sandboxes are enabled, `chrome-devtools-mcp` is not able to start
551
+ Chrome that requires permissions to create its own sandboxes. As a workaround,
552
+ either disable sandboxing for `chrome-devtools-mcp` in your MCP client or use
553
+ `--browser-url` to connect to a Chrome instance that you start manually outside
554
+ of the MCP client sandbox.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { CDPSessionEvent } from './third_party/index.js';
7
+ /**
8
+ * This class makes a puppeteer connection look like DevTools CDPConnection.
9
+ *
10
+ * Since we connect "root" DevTools targets to specific pages, we scope everything to a puppeteer CDP session.
11
+ *
12
+ * We don't have to recursively listen for 'sessionattached' as the "root" CDP session sees all child session attached
13
+ * events, regardless how deeply nested they are.
14
+ */
15
+ export class PuppeteerDevToolsConnection {
16
+ #connection;
17
+ #observers = new Set();
18
+ #sessionEventHandlers = new Map();
19
+ constructor(session) {
20
+ this.#connection = session.connection();
21
+ session.on(CDPSessionEvent.SessionAttached, this.#startForwardingCdpEvents.bind(this));
22
+ session.on(CDPSessionEvent.SessionDetached, this.#stopForwardingCdpEvents.bind(this));
23
+ this.#startForwardingCdpEvents(session);
24
+ }
25
+ send(method, params, sessionId) {
26
+ if (sessionId === undefined) {
27
+ throw new Error('Attempting to send on the root session. This must not happen');
28
+ }
29
+ const session = this.#connection.session(sessionId);
30
+ if (!session) {
31
+ throw new Error('Unknown session ' + sessionId);
32
+ }
33
+ // Rolled protocol version between puppeteer and DevTools doesn't necessarily match
34
+ /* eslint-disable @typescript-eslint/no-explicit-any */
35
+ return session
36
+ .send(method, params)
37
+ .then(result => ({ result }))
38
+ .catch(error => ({ error }));
39
+ /* eslint-enable @typescript-eslint/no-explicit-any */
40
+ }
41
+ observe(observer) {
42
+ this.#observers.add(observer);
43
+ }
44
+ unobserve(observer) {
45
+ this.#observers.delete(observer);
46
+ }
47
+ #startForwardingCdpEvents(session) {
48
+ const handler = this.#handleEvent.bind(this, session.id());
49
+ this.#sessionEventHandlers.set(session.id(), handler);
50
+ session.on('*', handler);
51
+ }
52
+ #stopForwardingCdpEvents(session) {
53
+ const handler = this.#sessionEventHandlers.get(session.id());
54
+ if (handler) {
55
+ session.off('*', handler);
56
+ }
57
+ }
58
+ #handleEvent(sessionId, type, event) {
59
+ if (typeof type === 'string' &&
60
+ type !== CDPSessionEvent.SessionAttached &&
61
+ type !== CDPSessionEvent.SessionDetached) {
62
+ this.#observers.forEach(observer => observer.onEvent({
63
+ method: type,
64
+ sessionId,
65
+ params: event,
66
+ }));
67
+ }
68
+ }
69
+ }