Skip to content

Commit 7698b89

Browse files
committed
docs: Add step-by-step guide for connecting to running Chrome instance (#140)
1 parent 139ce60 commit 7698b89

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,83 @@ 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, including the port number.
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+
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.
358+
359+
**macOS**
360+
361+
```bash
362+
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
363+
```
364+
365+
**Linux**
366+
367+
```bash
368+
/usr/bin/google-chrome --remote-debugging-port=9222
369+
```
370+
371+
**Windows**
372+
373+
```bash
374+
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
375+
```
376+
377+
**Step 3: Use a non-default user data directory**
378+
379+
For security reasons, Chrome requires you to use a non-default user data directory 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.
380+
381+
**macOS**
382+
383+
```bash
384+
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-profile-stable
385+
```
386+
387+
**Linux**
388+
389+
```bash
390+
/usr/bin/google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-profile-stable
391+
```
392+
393+
**Windows**
394+
395+
```bash
396+
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%TEMP%\chrome-profile-stable"
397+
```
398+
399+
> [!WARNING]
400+
> 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.
401+
402+
**Step 4: Ensure the ports are the same**
403+
404+
The port number in the `--browser-url` option in your MCP client configuration must be the same as the port number you used to start the Chrome browser.
405+
406+
For more details on remote debugging, see the [Chrome DevTools documentation](https://developer.chrome.com/docs/devtools/remote-debugging/).
407+
331408
## Known limitations
332409

333410
### Operating system sandboxes

0 commit comments

Comments
 (0)