Skip to content

[Windows] MCP child exits with WinError 10106 when SystemRoot/windir are missing; Codex reports timeout — observed with Python MCP (serena) #3311

Closed

Description

@aonorigomashio

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.

Activity

  1. added
    windows-osIssues related to Codex on Windows systems
    mcpIssues related to the use of model context protocol (MCP) servers
    on Sep 8, 2025
  2. adsqx commented on Sep 8, 2025

    @adsqx

    This isn’t a Windows bug — it’s the same on Ubuntu.
    It’s simply an issue with synchronization and the timeout.
    That’s exactly what I meant by reactive loading. :)

  3. aonorigomashio commented on Sep 8, 2025

    @aonorigomashio
    Author

    Thanks for the context! I agree there’s a cross-platform angle around reactive loading and startup timeouts.
    In this report, though, I’m documenting a separate Windows-specific root cause: the MCP child process environment omits SystemRoot/windir, which makes Python crash immediately with WinError 10106 (Winsock provider init failure).Thank you.
    Evidence:
    • stderr shows WinError 10106 on startup;
    • dumping the child env (spawned by Codex) shows SystemRoot/windir are absent;
    • adding those two vars in the MCP env makes the issue disappear instantly (both CLI and VS Code extension).

  4. x0x0b commented on Sep 11, 2025

    @x0x0b

    I encountered a similar issue with the MCP server in JetBrains IDEs on Windows.
    If SystemRoot is not set, the connection fails.
    Passing SystemRoot=C:\Windows in the env resolved it.

  5. etraut-openai commented on Nov 23, 2025

    @etraut-openai
    Contributor

    I think this is no longer an issue, so I'm going to close the bug. If you see this with the latest version of codex, please open a new bug report and include repro steps.

  6. added a commit that references this issue on Aug 2, 2026
  7. fengxiang1990 commented on Aug 27, 2026

    @fengxiang1990

    java.io.IOException: Unable to establish loopback connection 我遇到了一样的问题,fuck gpt ,sb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmcpIssues related to the use of model context protocol (MCP) serverswindows-osIssues related to Codex on Windows systems

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions