A Complete, Real-World Fix for chrome-devtools MCP Startup Failure in GPT-5.2-Codex Agent Sandbox
Snippet / Summary (50–80 words)
When using GPT-5.2-Codex in Agent Sandbox mode, the chrome-devtools MCP may fail during initialization with a “connection closed” error. In this real troubleshooting case, the root cause was not Chrome or ports, but installing updates under Node.js 18. Reinstalling the environment with Node.js 22 resolved the MCP handshake issue completely and restored normal Sandbox operation.
1. Problem Background: Why Did a Previously Working Environment Suddenly Break?
Many developers using GPT-5.2-Codex with Agent Sandbox encounter a confusing situation:
the same machine, same project, and same workflow worked perfectly before, but suddenly Codex fails to start with an MCP error.
A typical error message looks like this:
At first glance, this appears to be a Chrome DevTools or port configuration issue. In practice, it often leads to repeated checks of Chrome versions, ports, permissions, and firewalls—none of which solve the problem.
This article documents a complete, real, and reproducible troubleshooting process and explains the true technical cause, along with a definitive solution.
2. Who This Article Is For
This guide is written for readers who:
-
☾ Use Codex CLI with GPT-5.2-Codex -
☾ Enable Agent Sandbox -
☾ Rely on chrome-devtoolsMCP for browser capabilities -
☾ Confirm that Chrome remote debugging (for example, port 9222) is already accessible -
☾ Still see MCP initialization failures
By the end, you will clearly understand:
-
☾ How the MCP architecture is actually layered -
☾ Why “Chrome works” does not guarantee MCP will start -
☾ How Node.js versions can silently break MCP initialization -
☾ How to fix the issue in a clean, repeatable way—and avoid it in the future
3. Architecture Overview: Where the Failure Actually Occurs
In Agent Sandbox mode, the execution chain can be simplified as follows:
The critical insight is this:
The error occurs between the MCP Client and the MCP Server—not between Chrome and CDP.
This distinction drives the entire troubleshooting strategy.
4. Verifying the Obvious: Chrome and the Debug Port Are Fine
In this case, the following checks were already completed.
4.1 Chrome Starts Correctly with Remote Debugging
Chrome was launched explicitly with a remote debugging port:
4.2 The DevTools Endpoint Is Reachable
Visiting the following URL in a browser:
returns valid JSON output. This confirms:
-
☾ Chrome is running -
☾ Remote debugging is enabled -
☾ The port is open and reachable -
☾ Local permissions and networking are not the problem
At this point, Chrome and CDP can be conclusively ruled out.
5. Understanding the Key Symptom: “Connection Closed” During initialize
MCP startup is not a simple socket connection. It follows a defined protocol:
-
MCP Client connects to MCP Server -
Client sends an initializerequest (schema, capabilities, metadata) -
Server validates and responds -
Session becomes active
In this case, the behavior was:
-
☾ TCP connection succeeds -
☾ MCP Server closes the connection during initialize -
☾ Client reports connection closed: initialize response
This indicates a very specific condition:
The MCP Server crashes or exits while parsing the
initializepayload.
When that happens, the client receives no structured error—only a closed connection.
6. What Was Already Ruled Out
Through systematic elimination, the following causes were excluded:
Only chrome-devtools MCP was failing.
At this point, the only remaining variable was the runtime environment of the MCP Server itself.
7. Root Cause Identified: Node.js Version Incompatibility
Reviewing recent environment changes revealed one critical detail:
The Codex / Agent Sandbox update had been performed using Node.js 18.
The fix that ultimately resolved the issue was simple but decisive:
-
☾ Switch to Node.js 22 -
☾ Reinstall Codex and MCP components using Node.js 22 -
☾ Do not change any other configuration
Result:
-
☾ chrome-devtoolsMCP initializes successfully -
☾ Agent Sandbox starts normally -
☾ The error disappears completely
This confirms the root cause:
Node.js 18 is runtime-incompatible with the current
chrome-devtoolsMCP Server.
8. Why Node.js 18 Fails in Such a Subtle Way
This issue is particularly misleading because Node.js 18 appears to work at first glance:
-
☾ Dependencies install correctly -
☾ MCP Server process can start -
☾ No explicit “unsupported Node version” error appears -
☾ Failure only occurs during MCP protocol initialization
In other words:
-
☾ No syntax error -
☾ No immediate crash -
☾ Only a silent exit during initialize
From the user’s perspective, this looks like an MCP or Chrome issue—when it is actually a runtime compatibility problem.
9. The Definitive Fix (Step-by-Step)
Step 1: Check the Current Node.js Version
If the result is v18.x.x, continue.
Step 2: Install or Switch to Node.js 22
Ensure that Node.js 22.x is the active runtime in your environment.
Step 3: Reinstall Codex and MCP Components
Using Node.js 22:
-
☾ Reinstall Codex CLI -
☾ Allow MCP components to be rebuilt and reinstalled -
☾ Ensure .codex/mcpis regenerated cleanly
Step 4: Restart Agent Sandbox
At this point:
-
☾ chrome-devtoolsMCP initializes correctly -
☾ No “connection closed” error occurs -
☾ Agent Sandbox works as expected
10. Why This Problem Is Easy to Miss—but Inevitable
From an engineering perspective, this is a classic runtime drift problem:
-
☾ Codex, Agent Sandbox, and MCP evolve continuously -
☾ Node.js 18 remains widely used but sits in a gray compatibility zone -
☾ Newer MCP Servers rely on newer runtime behaviors -
☾ Updates do not always enforce a strict Node version check
The result is an environment that looks stable—but is no longer protocol-compatible.
11. FAQ: Common Questions Developers Ask
Q1: Why doesn’t the error message mention Node.js?
Because the MCP Server exits during the initialize phase, before it can return a structured error to the client.
Q2: Can Node.js 18 still be used with Codex?
It may appear to work in non-Sandbox scenarios, but it is not reliable for Agent Sandbox or chrome-devtools MCP.
Q3: Do Chrome or MCP configurations need to be changed?
No. In this case, the only required change was the Node.js major version.
Q4: Will this happen again?
Yes—if future updates are performed under an older Node.js runtime. Locking the Node.js major version avoids recurrence.
12. Final Takeaway
This case is valuable not just because the issue was fixed, but because it highlights a deeper lesson:
-
☾ In modern AI toolchains with multiple cooperating components, -
☾ the runtime itself is a first-class dependency, -
☾ And “it worked before” does not guarantee future compatibility.
Based on a complete, real-world troubleshooting loop, one conclusion is clear:
For GPT-5.2-Codex + Agent Sandbox +
chrome-devtoolsMCP, Node.js 22 is a proven, stable runtime choice.
This is not speculation—it is an experience-backed result.

