Skip to content

Commit a537a8c

Browse files
docs: explain new auto connection feature (ChromeDevTools#664)
1 parent 61ede1c commit a537a8c

File tree

1 file changed

+66
-2
lines changed

1 file changed

+66
-2
lines changed

README.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,73 @@ the browser is closed.
484484

485485
### Connecting to a running Chrome instance
486486

487-
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.
487+
By default, the Chrome DevTools MCP server will start a new Chrome instance with a dedicated profile. This might not be ideal in all situations:
488488

489-
Here is a step-by-step guide on how to connect to a running Chrome Stable instance:
489+
- If you would like to maintain the same application state when alternating between manual site testing and agent-driven testing.
490+
- When the MCP needs to sign into a website. Some accounts may prevent sign-in when the browser is controlled via WebDriver (the default launch mechanism for the Chrome DevTools MCP server).
491+
- If you're running your LLM inside a sandboxed environment, but you would like to connect to a Chrome instance that runs outside the sandbox.
492+
493+
In these cases, start Chrome first and let the Chrome DevTools MCP server connect to it. There are two ways to do so:
494+
495+
- **Automatic connection (available in Chrome 144)**: best for sharing state between manual and agent-driven testing.
496+
- **Manual connection via remote debugging port**: best when running inside a sandboxed environment.
497+
498+
#### Automatically connecting to a running Chrome instance
499+
500+
**Step 1:** Set up remote debugging in Chrome
501+
502+
In Chrome, do the following to set up remote debugging:
503+
504+
1. Navigate to `chrome://inspect/#remote-debugging` to enable remote debugging.
505+
2. Follow the dialog UI to allow or disallow incoming debugging connections.
506+
507+
**Step 2:** Configure Chrome DevTools MCP server to automatically connect to a running Chrome Instance
508+
509+
To connect the `chrome-devtools-mcp` server to the running Chrome instance, use
510+
`--autoConnect` command line argument for the MCP server.
511+
512+
The following code snippet is an example configuration for gemini-cli:
513+
514+
```json
515+
{
516+
"mcpServers": {
517+
"chrome-devtools": {
518+
"command": "npx",
519+
"args": [
520+
"chrome-devtools-mcp@latest",
521+
"--autoConnect",
522+
"--channel=canary"
523+
]
524+
}
525+
}
526+
}
527+
```
528+
529+
Note: you have to specify `--channel=canary` until Chrome M144 has reached the
530+
stable channel.
531+
532+
**Step 3:** Test your setup
533+
534+
Make sure your browser is running. Open gemini-cli and run the following prompt:
535+
536+
```none
537+
Check the performance of https://developers.chrome.com
538+
```
539+
540+
Note: The <code>autoConnect</code> option requires the user to start Chrome.
541+
542+
The Chrome DevTools MCP server will try to connect to your running Chrome
543+
instance. It shows a dialog asking for user permission.
544+
545+
Clicking **Allow** results in the Chrome DevTools MCP server opening
546+
[developers.chrome.com](http://developers.chrome.com) and taking a performance
547+
trace.
548+
549+
#### Manual connection using port forwarding
550+
551+
You can connect to a running Chrome instance by using the `--browser-url` option. This is useful if you are running the MCP server in a sandboxed environment that does not allow starting a new Chrome instance.
552+
553+
Here is a step-by-step guide on how to connect to a running Chrome instance:
490554

491555
**Step 1: Configure the MCP client**
492556

0 commit comments

Comments
 (0)