[Windows] MCP child exits with `WinError 10106` when `SystemRoot`/`windir` are missing; Codex reports timeout — observed with Python MCP (serena)
What version of Codex is running?
Codex CLI: 0.29.0 , 0.30.0 (both reproduce) and VSCodeExtension 0.4.3
Which model were you using?
GPT-5
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What steps can reproduce the bug?
1) Configure a Python MCP entry (here: serena) in ~/.codex/config.toml without SystemRoot/windir in env:
[mcp_servers.serena]
command = "C:\\Tools\\serena\\.venv\\Scripts\\serena.exe"
args = ["start-mcp-server", "--context", "codex", "--log-level", "ERROR"]
2) Start Codex (CLI or VS Code extension). Codex reports a timeout.
3) To confirm the root cause, wrap the command in a small .bat that dumps the child env and captures stderr:
@echo off
setlocal
set "ENVLOG=C:\Tools\serena\env_from_codex.txt"
set "ERR=C:\Tools\serena\serena_from_codex.err"
set > "%ENVLOG%"
"C:\Tools\serena\.venv\Scripts\serena.exe" start-mcp-server --context codex 2> "%ERR%"
4) Re-run Codex and check results:
- env_from_codex.txt -> SystemRoot and windir are absent
- serena_from_codex.err -> stack trace ends with OSError: [WinError 10106] ... (WSAEPROVIDERFAILEDINIT)
What is the expected behavior?
Codex should start the MCP, complete the STDIO handshake, and allow listing/using tools (e.g., tools/list).
What do you see instead?
Codex shows:
'MCP client 'serena' failed to start: request timed out'
The MCP child process actually exits quickly with code 1; stderr tail includes:
OSError: [WinError 10106] 指定されたサービス プロバイダーの読み込みまたは初期化を行うことができませんでした。
(which means “The specified service provider could not be loaded or initialized.”)
On the same machine, MCP Inspector succeeds (inherits the full shell environment), so the failure appears specific to how Codex spawns child processes on Windows.
Additional information
Workaround (fixes both CLI & VS Code extension):
[mcp_servers.serena]
command = "C:\\Tools\\serena\\.venv\\Scripts\\serena.exe"
args = ["start-mcp-server", "--context", "codex", "--log-level", "ERROR"]
env = { SystemRoot = "C:\\Windows", windir = "C:\\Windows" }
Hypothesis:
On Windows, Winsock initialization (triggered when importing asyncio.windows_events / _overlapped) may rely on system directories resolved via %SystemRoot% / %windir%. Codex appears to spawn MCP children with a minimized environment that omits those vars, causing WSAEPROVIDERFAILEDINIT (WinError 10106), early exit, and Codex timeout.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗