chrome-devtools-mcp icon indicating copy to clipboard operation
chrome-devtools-mcp copied to clipboard

Auto-connect doesn't work on WSL with mirrored networking (Chrome on Windows host)

Open ultism opened this issue 6 months ago • 2 comments

Is your feature request related to a problem? Please describe.

A common Claude Code / Cursor / VSCode setup is: the MCP server runs in WSL2 (Linux), while Chrome runs on the Windows host. WSL2 mirrored networking makes Windows localhost:9222 reachable from inside WSL, so the transport works fine.

In this setup, none of the documented connection paths work cleanly with Chrome 144+'s chrome://inspect/#remote-debugging flow:

  1. --autoConnect — fails. The flag discovers the ws URL by reading Chrome's local user data dir, but from WSL the Windows-side user data dir is invisible, so no Chrome is found even though port 9222 is reachable.
  2. --browserUrl=http://localhost:9222 — fails with HTTP Not Found on /json/version. Per #1194 this is by design: the chrome://inspect flow exposes a WebSocket-only endpoint, no HTTP discovery.
  3. --wsEndpoint=ws://localhost:9222/devtools/browser/<uuid> — works, but the user has to dig the <uuid> out manually each time Chrome restarts; the chrome://inspect UI doesn't surface it.

So WSL users are forced into the manual --remote-debugging-port + non-default --user-data-dir workaround, losing the chrome://inspect connection-confirm UX.

Describe the solution you'd like

Any one of these would unblock the WSL setup. Listed in increasing scope:

(a) Documentation — a short section in README covering the WSL + Windows-host-Chrome case explicitly. Today it implicitly assumes the MCP server and Chrome run on the same OS.

(b) UX — surface the ws URL somewhere the user can copy from (chrome://inspect page, Chrome stderr, or a small helper command), so --wsEndpoint becomes one-shot copy-paste rather than a UUID-hunt.

(c) Cross-host autoConnect — let --autoConnect honor an env var or flag pointing at a remote/Windows-side user data dir (or a discovery URL), so the same auto-connect ergonomics work when Chrome lives on a different host than the MCP server.

Describe alternatives you've considered

  • Manual workaround: launch Windows Chrome with --remote-debugging-port=9222 --user-data-dir="C:\chrome-debug" and use --browserUrl. Works, but forces a separate Chrome profile and bypasses the chrome://inspect connection-confirm prompt.

  • Install Chrome inside WSL itself and let --autoConnect use it. Works, but defeats the purpose for users who already have Chrome on Windows with their normal extensions / sessions / etc.

  • Use --wsEndpoint after manually fishing the UUID out of the WebSocket handshake. Works but is fragile (UUID changes on every Chrome restart) and has poor ergonomics.

Additional context

  • Related: #1194 (closed). That issue hit the --browserUrl 404 case but the WSL side was only mentioned in passing in the comments and the issue closed without addressing it.
  • Confirmed chrome://inspect/#remote-debugging is intentionally ws-only (no /json/version) per maintainer reply on #1194.
  • Repro: Windows 11 + Chrome 144+, WSL2 Ubuntu with mirrored networking, MCP version 0.20.x. From WSL, curl http://localhost:9222/json/version returns 404; raw WS connection to ws://localhost:9222/devtools/browser/<uuid> works.

ultism avatar May 06 '26 16:05 ultism

--auto-connect is meant to discover the instances on the same host. With WSL, the mcp server is running in the virtual machine and, thus, auto-connect would not work. We have documentation for WSL here https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/main/docs/troubleshooting.md#wsl. In --wsEndpoint=ws://localhost:9222/devtools/browser/<uuid>, <uuid> part is not needed if the server is started via chrome://inspect/#remote-debugging.

OrKoN avatar May 06 '26 18:05 OrKoN

For the WSL + Windows-host Chrome case, I would separate three checks:

  1. chrome://inspect/#remote-debugging and manual --remote-debugging-port are not equivalent connection paths. If /json/version returns 404, --browser-url cannot discover the browser and you are in the WebSocket-only path.
  2. For repeatable Claude Code/Codex runs from WSL, the most stable workaround is still a fixed port plus a non-default Windows Chrome profile, then point the MCP server at that browser URL.
  3. Test endpoint reachability from WSL before debugging MCP config:
curl http://127.0.0.1:9222/json/version

If that fails, try the Windows host/gateway IP or mirrored networking settings first. Only after that passes would I change the Claude/Codex MCP config and restart the client so the server list reloads.

I wrote up a WSL-specific checklist here: https://github.com/zdayang/wsl-chrome-bridge-support

Disclosure: that repo supports a small paid package I sell, but the checklist and failure-mode notes are public and should be useful even if you wire this manually.

zdayang avatar May 26 '26 01:05 zdayang