-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Problem
When MCP clients reconnect (e.g. running /mcp in Claude Code, or restarting the client), each reconnect spawns a new chrome-devtools-mcp process without killing the previous one. Multiple CDP clients on the same debug port fight over protocol sessions, causing Network.enable timed out errors.
Root cause
There's no mechanism to prevent or clean up duplicate connections to the same browser endpoint. Running lsof -i :9222 after a few reconnects shows 3-4 node processes all connected to port 9222.
The existing in-process guard in browser.ts (if (browser?.connected)) only prevents reconnections within the same process. It does nothing for separate processes.
Reproduction
- Configure chrome-devtools-mcp with
--browserUrl=http://127.0.0.1:9222 - Start an MCP session (connect from Claude Code, Gemini CLI, etc.)
- Reconnect the MCP session (e.g.
/mcpin Claude Code) - Repeat 2-3 times
- Run
lsof -i :9222 | grep nodeand observe multiple processes - Any tool call now fails with
Network.enable timed out
Fix
Draft PR: #1761
Adds endpoint-based PID lock files. On startup, the server checks if another instance is already connected to the same endpoint, kills it, waits for it to die, then acquires the lock.