-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
When using chrome-devtools-mcp on macOS, Chrome steals window focus from the active application (terminal, VS Code, etc.) on virtually every MCP tool call — including read-only operations like take_screenshot, list_pages, and select_page (with bringToFront omitted/false).
This makes the MCP very disruptive to use in AI coding agents (Claude Code, Cursor, etc.) where the user is working in their IDE/terminal while the agent interacts with Chrome in the background.
Environment
- OS: macOS (Sonoma)
- chrome-devtools-mcp: 0.20.3
- Connection mode:
--autoConnect - MCP client: Claude Code (CLI)
Steps to reproduce
- Open Chrome with remote debugging enabled
- Start chrome-devtools-mcp with
--autoConnect - Focus a different application (e.g., VS Code terminal)
- Call any MCP tool (e.g.,
take_screenshot,select_page,list_pages) - Observe: Chrome window activates and steals focus from the current application
What I expected
Read-only CDP operations (screenshots, snapshots, page listing) should not activate the Chrome window. Only explicit user-facing actions (like bringToFront: true) should change window focus.
Workarounds attempted (none worked)
bringToFront: falseonselect_page— helps for that specific call, but other tools still steal focus- macOS Spaces — moving Chrome to a separate virtual desktop; Chrome still gets activated
- PostToolUse hook with
osascriptto refocus the terminal — causes visible blinking (Chrome activates then terminal activates), worse UX than the original problem - Opening a new Chrome window in a separate Space — same result, Chrome as an app gets activated
Root cause
This appears to be a Chromium-level issue where CDP WebSocket communication triggers macOS window activation. Related Chromium bugs (open for 10+ years):
- chromium#223828 — Chrome window steals focus when driven by chromedriver
- chromium#40770130 — Chrome window randomly steals focus
- chromium#40182355 — Chromium steals focus at launch on macOS
Possible solutions
- Add a
--no-activateor--backgroundserver flag that suppresses window activation during CDP communication - Use headless CDP session for read-only operations where possible
- Investigate which specific CDP commands trigger macOS
NSApplication activateand avoid them for non-interactive tools - Add
background: true/focus: falseparameters toTarget.createTargetcalls where applicable