Skip to content

Commit 1674c09

Browse files
authored
docs: Add step-by-step guide for connecting to running Chrome instance (#140) (#330)
1 parent 9ad7cbb commit 1674c09

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,69 @@ all instances of `chrome-devtools-mcp`. Set the `isolated` option to `true`
328328
to use a temporary user data dir instead which will be cleared automatically after
329329
the browser is closed.
330330

331+
### Connecting to a running Chrome instance
332+
333+
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.
334+
335+
Here is a step-by-step guide on how to connect to a running Chrome Stable instance:
336+
337+
**Step 1: Configure the MCP client**
338+
339+
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://localhost:9222` is a common default.
340+
341+
```json
342+
{
343+
"mcpServers": {
344+
"chrome-devtools": {
345+
"command": "npx",
346+
"args": [
347+
"chrome-devtools-mcp@latest",
348+
"--browser-url=http://localhost:9222"
349+
]
350+
}
351+
}
352+
}
353+
```
354+
355+
**Step 2: Start the Chrome browser**
356+
357+
> [!WARNING]
358+
> 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.
359+
360+
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.
361+
362+
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.
363+
364+
**macOS**
365+
366+
```bash
367+
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-profile-stable
368+
```
369+
370+
**Linux**
371+
372+
```bash
373+
/usr/bin/google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-profile-stable
374+
```
375+
376+
**Windows**
377+
378+
```bash
379+
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%TEMP%\chrome-profile-stable"
380+
```
381+
382+
**Step 3: Test your setup**
383+
384+
After configuring the MCP client and starting the Chrome browser, you can test your setup by running a simple prompt in your MCP client:
385+
386+
```
387+
Check the performance of https://developers.chrome.com
388+
```
389+
390+
Your MCP client should connect to the running Chrome instance and receive a performance report.
391+
392+
For more details on remote debugging, see the [Chrome DevTools documentation](https://developer.chrome.com/docs/devtools/remote-debugging/).
393+
331394
## Known limitations
332395

333396
### Operating system sandboxes

0 commit comments

Comments
 (0)