MCP servers are not working on windows
What version of Codex is running?
codex-cli 0.31.0
Which model were you using?
gpt5
What platform is your computer?
windows 11 pro
What steps can reproduce the bug?
the npx is not working
tool running...
firebase-afterdark.firebase_query({"target":"firestore","operation":"list_collections","params":{}})
tool failed, duration: 1m20s
firebase-afterdark.firebase_query({"target":"firestore","operation":"list_collections","params":{}})
Error: tool call error: tool call failed for `firebase-afterdark/firebase_query`
tool running...
context7.resolve-library-id({"libraryName":"Next.js 14.1.1"})
tool success, duration: 3ms
context7.resolve-library-id({"libraryName":"Next.js 14.1.1"})
Error searching libraries: TypeError: fetch failed
> Network is still restricted, so Context7 lookups are failing.
[mcp_servers.context7]
command = "node"
args = ["C:/Users/NATH/Documents/Cline/MCP/context7/dist/index.js"]
type = "stdio"
[mcp_servers.playwright]
command = "node"
args = ["C:/Users/NATH/Documents/Cline/MCP/playwright-mcp/lib/index.js"]
type = "stdio"
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
There's a good way to do this: check the configuration paths for your commands. This way, you can configure multiple MCPs for uv, uvx, and npx. Here are some examples:
[mcp_servers.context7]
type = "stdio"
command = 'C:\Program Files\nodejs\npx.cmd'
args = ["-y", "@upstash/context7-mcp@latest"]
env = { APPDATA = 'C:\Users\lenovo\AppData\Roaming', LOCALAPPDATA = 'C:\Users\lenovo\AppData\Local', HOME = 'C:\Users\lenovo', SystemRoot = 'C:\Windows' }
startup_timeout_ms = 20_000
[mcp_servers."perplexity-mcp"] type = "stdio" command = 'C:\Users\lenovo.local\bin\uvx.exe' args = ["perplexity-mcp"] env = { PERPLEXITY_API_KEY = "XXXXXXX", PERPLEXITY_MODEL = "sonar", APPDATA = 'C:\Users\lenovo\AppData\Roaming', LOCALAPPDATA = 'C:\Users\lenovo\AppData\Local', HOME = 'C:\Users\lenovo', SystemRoot = 'C:\Windows' }
[mcp_servers.serena] type = "stdio" command = 'C:\Users\lenovo\.local\bin\uv.exe' args = ["run", "--directory", "F:\Homework\MyMCP\serena", "serena-mcp-server"] env = { APPDATA = 'C:\Users\lenovo\AppData\Roaming', LOCALAPPDATA = 'C:\Users\lenovo\AppData\Local', HOME = 'C:\Users\lenovo', SystemRoot = 'C:\Windows' } startup_timeout_ms = 20_000
Of course, if you are sse please use this uv tool install mcp-proxy, here is an example: [mcp_servers."graphiti-memory-stdio-via-proxy"] type = "stdio" command = 'C:\Users\lenovo\.local\bin\uvx.exe' args = ["mcp-proxy", "http://127.0.0.1:15627/sse"] env = { APPDATA = 'C:\Users\lenovo\AppData\Roaming', LOCALAPPDATA = 'C:\Users\lenovo\AppData\Local', HOME = 'C:\Users\lenovo', SystemRoot = 'C:\Windows' } startup_timeout_ms = 20_000
I'm not able to run any MCPs on codex in native windows due to a winsocket error; switching to WSL resolves the issue
File "C:\Users\...\AppData\Roaming\uv\tools\serena-agent\Lib\site-packages\typing_extensions.py", line 2997, in call
import asyncio.coroutines
File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.11.13-windows-x86_64-none\Lib\asyncio\init.py", line 42, in <module>
from .windows_events import *
File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.11.13-windows-x86_64-none\Lib\asyncio\windows_events.py", line 8, in <module>
import _overlapped
OSError: [WinError 10106] The requested service provider could not be loaded or initialized
This is working in my end this is really cool
May help someone here. Also posted in #3408. Works for me on Windows 11 Pro/VSC/Codex CLI.
This config assumes MCP servers are installed globally with npm and launched via the global shims under %APPDATA%\npm.
Most servers weren't working - including Context7 - due to problems with outbound connections. Fixed by adding NODE_OPTIONS.
####################################
# MCP Servers (SANITIZED TEMPLATE)
# Replace <USER> and <..._API_KEY> placeholders before use.
# Tip: prefer setting keys via OS env vars instead of hard-coding.
####################################
# sequential-thinking
[mcp_servers.sequential-thinking]
command = "C:\\Users\\<USER>\\AppData\\Roaming\\npm\\mcp-server-sequential-thinking.cmd"
args = []
transport = "stdio"
startup_timeout_ms = 20000
[mcp_servers.sequential-thinking.env]
APPDATA = "C:\\Users\\<USER>\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\<USER>\\AppData\\Local"
HOME = "C:\\Users\\<USER>"
SystemRoot = "C:\\Windows"
NODE_OPTIONS = "--dns-result-order=ipv4first"
# playwright (uses installed Chrome; headless)
[mcp_servers.playwright]
command = "C:\\Users\\<USER>\\AppData\\Roaming\\npm\\mcp-server-playwright.cmd"
args = ["--browser","chrome","--headless","--executable-path","C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"]
transport = "stdio"
startup_timeout_ms = 45000
[mcp_servers.playwright.env]
APPDATA = "C:\\Users\\<USER>\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\<USER>\\AppData\\Local"
HOME = "C:\\Users\\<USER>"
SystemRoot = "C:\\Windows"
NODE_OPTIONS = "--dns-result-order=ipv4first"
# context7 (optional CONTEXT7_API_KEY)
[mcp_servers.context7]
command = "C:\\Users\\<USER>\\AppData\\Roaming\\npm\\context7-mcp.cmd"
args = []
transport = "stdio"
startup_timeout_ms = 60000
[mcp_servers.context7.env]
APPDATA = "C:\\Users\\<USER>\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\<USER>\\AppData\\Local"
HOME = "C:\\Users\\<USER>"
SystemRoot = "C:\\Windows"
NODE_OPTIONS = "--dns-result-order=ipv4first"
# CONTEXT7_API_KEY = "<CONTEXT7_API_KEY>"
# Bright Data — direct server.js via node.exe
[mcp_servers.brightdata]
command = "C:\\Program Files\\nodejs\\node.exe"
args = ["C:\\Users\\<USER>\\AppData\\Roaming\\npm\\node_modules\\@brightdata\\mcp\\server.js"]
transport = "stdio"
startup_timeout_ms = 60000
[mcp_servers.brightdata.env]
API_TOKEN = "<BRIGHTDATA_API_TOKEN>"
PRO_MODE = "true"
APPDATA = "C:\\Users\\<USER>\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\<USER>\\AppData\\Local"
HOME = "C:\\Users\\<USER>"
SystemRoot = "C:\\Windows"
NODE_OPTIONS = "--dns-result-order=ipv4first"
There's a good way to do this: check the configuration paths for your commands. This way, you can configure multiple MCPs for uv, uvx, and npx. Here are some examples: [mcp_servers.serena] type = "stdio" command = 'C:\Users\lenovo.local\bin\uv.exe' args = ["run", "--directory", "F:\Homework\MyMCP\serena", "serena-mcp-server"] env = { APPDATA = 'C:\Users\lenovo\AppData\Roaming', LOCALAPPDATA = 'C:\Users\lenovo\AppData\Local', HOME = 'C:\Users\lenovo', SystemRoot = 'C:\Windows' } startup_timeout_ms = 20_000
Love you, this is the first way I found that can run serena in my environment. But I did a little bit adjustments to run it in VScode codex extension, here is my config:
[mcp_servers.serena]
type = "stdio"
command = "THE PATH TO YOUR uv.exe"
args = ["run", "--directory", "G:\\serena", "serena", "start-mcp-server", "--context", "codex"]
env = { APPDATA = "C:\\Users\\<YOUR WINDOWS ACCOUT USER ID>\\AppData\\Roaming", LOCALAPPDATA = "C:\\Users\\<YOUR WINDOWS ACCOUT USER ID>\\AppData\\Local", HOME = "C:\\Users\\<YOUR WINDOWS ACCOUT USER ID>", SystemRoot = "C:\\Windows" }
startup_timeout_ms = 20_000``
I was able to get my MCP servers working yesterday as well by adding these environmental variables
APPDATA = 'C:\Users...\AppData\Roaming' LOCALAPPDATA = 'C:\Users...\AppData\Local' DOTNET_ROOT = 'C:\Program Files\dotnet' HOME='C:\Users...' SystemRoot='C:\Windows'
Everything else was identical to my setup for claude code (didn't have to convert npx or uvx to the executable). Thanks all!
This is the format I used to get the MCP servers to work on Windows 11. You have to replace REDACTED with your own character sequence. Notice that I used "cmd" command instead of "npx"
`approval_policy = "never" model = "gpt-5-codex"
[mcp_servers."firecrawl-mcp"] command = "cmd" args = ["/c", "npx", "-y", "firecrawl-mcp"] startup_timeout_ms = 120000
[mcp_servers."firecrawl-mcp".env] APPDATA = "C:\Users\Computer\AppData\Roaming" LOCALAPPDATA = "C:\Users\Computer\AppData\Local" HOME = "C:\Users\Computer" SystemRoot = "C:\Windows" NODE_OPTIONS = "--dns-result-order=ipv4first" FIRECRAWL_API_KEY = "fc-REDACTED"
[mcp_servers."playwright"] command = "cmd" args = ["/c", "npx", "-y", "@playwright/mcp@latest"] startup_timeout_ms = 180000
[mcp_servers."playwright".env] APPDATA = "C:\Users\Computer\AppData\Roaming" LOCALAPPDATA = "C:\Users\Computer\AppData\Local" HOME = "C:\Users\Computer" SystemRoot = "C:\Windows" NODE_OPTIONS = "--dns-result-order=ipv4first"
[mcp_servers."context7"] command = "cmd" args = ["/c", "npx", "-y", "@upstash/context7-mcp", "--api-key", "ctx7sk-REDACTED"] startup_timeout_ms = 120000
[mcp_servers."context7".env] APPDATA = "C:\Users\Computer\AppData\Roaming" LOCALAPPDATA = "C:\Users\Computer\AppData\Local" HOME = "C:\Users\Computer" SystemRoot = "C:\Windows" NODE_OPTIONS = "--dns-result-order=ipv4first"
[mcp_servers."supabase"] command = "cmd" args = ["/c", "npx", "-y", "@supabase/mcp-server-supabase@latest", "--read-only", "--project-ref=REDACTED"] startup_timeout_ms = 120000
[mcp_servers."supabase".env] APPDATA = "C:\Users\Computer\AppData\Roaming" LOCALAPPDATA = "C:\Users\Computer\AppData\Local" HOME = "C:\Users\Computer" SystemRoot = "C:\Windows" NODE_OPTIONS = "--dns-result-order=ipv4first" SUPABASE_ACCESS_TOKEN = "sbp_REDACTED" `
mark,hope fix
mark,hope fix +1
For Windows users, this works for me with Codex 0.38.0:
[mcp_servers.context7]
command = "cmd"
args = [
"/c",
"npx",
"-y",
"@upstash/context7-mcp",
"--api-key",
"YOUR_API_KEY",
]
env = { SystemRoot="C:\\Windows" }
startup_timeout_ms = 20_000
It looks like you can use it as long as there is information in the [.env]. The following settings can run correctly without any issues.
model = "gpt-5-codex"
[mcp_servers.dart]
type = "stdio"
command = 'c:\sdks\flutter\bin\dart.bat'
args = ["mcp-server"]
[mcp_servers.dart.env]
SYSTEMROOT = 'c:\windows'
[mcp_servers.context7]
type = 'stdio'
command = 'c:\nvm4w\nodejs\mcp-remote.cmd'
args = [
'https://mcp.context7.com/mcp',
'--header',
'CONTEXT7-API-KEY',
]
[mcp_servers.context7.env]
SYSTEMROOT = 'c:\windows'
Of course, if you are sse please use this uv tool install mcp-proxy, here is an example:当然,如果您是 sse,请使用此 uv 工具安装 mcp-proxy,以下是一个示例: [mcp_servers."graphiti-memory-stdio-via-proxy"] type = "stdio" 类型 = "stdio" command = 'C:\Users\lenovo.local\bin\uvx.exe'命令 = 'C:\Users\lenovo.local\bin\uvx.exe' args = ["mcp-proxy", "http://127.0.0.1:15627/sse"]参数 = ["mcp-proxy", "http://127.0.0.1:15627/sse"] env = { APPDATA = 'C:\Users\lenovo\AppData\Roaming', LOCALAPPDATA = 'C:\Users\lenovo\AppData\Local', HOME = 'C:\Users\lenovo', SystemRoot = 'C:\Windows' } startup_timeout_ms = 20_000
This works for me. I guess it should be these environmental variables that have played a role
On windows 11, with this setup:
[mcp_servers."context7"]
command = "cmd"
args = [
"/c",
"npx",
"-y",
"@upstash/context7-mcp",
"--api-key",
"ctx7sk-REDACTED",
]
startup_timeout_ms = 120000
[mcp_servers."context7".env]
APPDATA = "C:\Users\user\AppData\Roaming"
LOCALAPPDATA = "C:\Users\user\AppData\Local"
HOME = "C:\Users\user"
SystemRoot = "C:\Windows"
NODE_OPTIONS = "--dns-result-order=ipv4first"
I have this error on typing "codex" command:
Error loading configuration: TOML parse error at line 25, column 16
|
25 | APPDATA = "C:\Users\user\AppData\Roaming"
| ^
too few unicode value digits, expected unicode hexadecimal value
Double-slashing fixed this:
[mcp_servers."context7"]
command = "cmd"
args = [
"/c",
"npx",
"-y",
"@upstash/context7-mcp",
"--api-key",
"ctx7sk-REDACTED",
]
startup_timeout_ms = 120000
[mcp_servers."context7".env]
APPDATA = "C:\\Users\\user\\AppData\\Roaming"
LOCALAPPDATA = "C:\\Users\\user\\AppData\\Local"
HOME = "C:\\Users\\user"
SystemRoot = "C:\\Windows"
NODE_OPTIONS = "--dns-result-order=ipv4first"
Hi all, Can I have help using a stdio mcp running via an .exe file?
[mcp_servers.autodeskAECModel]
type = "stdio"
command = "C:\\Users\\xxx\\Documents\\aps-graphql\\src\\apsMcp.StdioServer\\bin\\Release\\net9.0\\win-x64\\publish\\apsMcp.StdioServer.exe"]
env = { "APS_CLIENT_ID" = "id", "APS_CLIENT_SECRET" = "secret", "APS_CALLBACK_URL" = "callback" }
I keep having this error
MCP client for autodeskAECModel failed to start: handshaking with MCP server failed: connection closed: initialize response
We have fixed many mcp-related bugs for Windows since this bug was first filed. If you're still seeing problems with the latest version of codex, please open a new bug report with details.
Hi all, Can I have help using a stdio mcp running via an .exe file?
[mcp_servers.autodeskAECModel] type = "stdio" command = "C:\\Users\\xxx\\Documents\\aps-graphql\\src\\apsMcp.StdioServer\\bin\\Release\\net9.0\\win-x64\\publish\\apsMcp.StdioServer.exe"] env = { "APS_CLIENT_ID" = "id", "APS_CLIENT_SECRET" = "secret", "APS_CALLBACK_URL" = "callback" }I keep having this error
MCP client for autodeskAECModel failed to start: handshaking with MCP server failed: connection closed: initialize response
I find the problem. In the code, I was having some Write.Console for debugging! Interesting, Claude Code don't care; instead, Codex was literally causing the handshaking to fail.