codex icon indicating copy to clipboard operation
codex copied to clipboard

Codex CLI on Windows 11: MCP server (Context7) fails with “request timed out”

Open wbdb opened this issue 1 year ago • 42 comments

What version of Codex is running?

0.23.0-0.31.0

Which model were you using?

GPT-5

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What steps can reproduce the bug?

OS: Windows 11 Pro (PowerShell 7 / Windows Terminal) Codex CLI: 0.23.0 Node.js: 22.17.0, npm: 11.5.1 Context7 MCP: @upstash/context7-mcp (local) Location of config: C:\Users\Name\.codex\config.toml

I tried these variations in my config.toml:

[mcp_servers.context7]
args = ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
command = "npx"

=> 🖐 MCP client for context7 failed to start: program not found

[mcp_servers.context7]
command = "cmd"
args    = ["/c","npx","-y","@upstash/context7-mcp"]

=> 🖐 MCP client for context7 failed to start: request timed out

[mcp_servers.context7]
command = "C:\\Program Files\\nodejs\\npx.cmd"
args    = ["-y","@upstash/context7-mcp@latest","--transport","stdio"]

=> 🖐 MCP client for context7 failed to start: request timed out

[mcp_servers.context7]
command = "C:\\Program Files\\nodejs\\node.exe"
args = [
  "C:\\Users\\Name\\AppData\\Roaming\\npm\\node_modules\\@upstash\\context7-mcp\\dist\\index.js",
  "--transport","stdio"
]

[mcp_servers.context7.env]
LOCALAPPDATA = 'C:\\Users\\Name\\AppData\\Local'
APPDATA = 'C:\\Users\\Name\\AppData\\Roaming'
PROGRAMFILES = 'C:\\Program Files'
"PROGRAMFILES(X86)" = 'C:\\Program Files (x86)'
SYSTEMROOT = 'C:\\Windows'
WINDIR = 'C:\\Windows'
HOMEDRIVE = 'C:'
HOMEPATH = '\\Users\\Name'
HOME = 'C:\\Users\\Name'

=> 🖐 MCP client for context7 failed to start: request timed out

What is the expected behavior?

Using MCP Context7

What do you see instead?

MCP Errors

Additional information

Microsoft has invested so much in OpenAI, I don't understand why Windows is being treated so shabbily given its market share.

wbdb avatar Aug 21 '25 11:08 wbdb

same issues

gurumnyang avatar Aug 21 '25 12:08 gurumnyang

Temporary workaround:

Install Context7 globally and link to it directly:

npm i -g @upstash/context7-mcp

Config:

[mcp_servers.context7]
command = "C:\\Program Files\\nodejs\\node.exe"
args    = ["C:\\Users\\Name\\AppData\\Roaming\\npm\\node_modules\\@upstash\\context7-mcp\\dist\\index.js","--transport","stdio"]

wbdb avatar Aug 21 '25 12:08 wbdb

it works! you are my hero

gurumnyang avatar Aug 21 '25 13:08 gurumnyang

@gurumnyang

But unfortunately, I keep getting errors like this :(

tool running... context7.resolve-library-id({"libraryName":"CodeIgniter Shield"})
tool success, duration: 84ms

context7.resolve-library-id({"libraryName":"CodeIgniter Shield"})
Error searching libraries: TypeError: fetch failed

You too?

wbdb avatar Aug 21 '25 13:08 wbdb

Added to the /mcp list, but when I tested it, I got the same error...

gurumnyang avatar Aug 21 '25 18:08 gurumnyang

I now use it via Windows WSL. It works flawlessly there.


WSL

Open WSL: wsl Enable WSL 2: wsl.exe --set-default-version 2 Install Ubuntu 24.04 LTS: wsl --install -d Ubuntu-24.04 Set Ubuntu as default (for wsl start): wsl --set-default Ubuntu-24.04 List installed WSL distros: wsl -l -v Switch to a specific WSL distro: wsl -d Ubuntu-24.04 Execute a specific command directly: wsl -d Ubuntu-24.04 ls -la Exit WSL session: exit Shut down all WSL sessions: wsl --shutdown Terminate a specific WSL session: wsl --terminate Ubuntu-24.04


Codex & Node.js

Check correct Linux version: uname -a Install updates: sudo apt update && sudo apt upgrade -y Install essential packages: sudo apt install -y curl git build-essential unzip

Download and install fnm: curl -o- https://fnm.vercel.app/install | bash

Download and install Node.js: fnm install 22

Reload shell: source ~/.bashrc

Verify Node.js version: node -v (should print “v22.18.0”)

Verify npm version: npm -v (should print “10.9.3”)

Update npm: npm install -g npm@latest Show npm version: npm --version (e.g. 11.5.2)

Install Codex CLI: npm install -g @openai/codex Check Codex version: codex --version


MCP Context 7 Setup

Create config directory and file, then edit: mkdir -p ~/.codex && touch ~/.codex/config.toml && nano ~/.codex/config.toml

Add the following:

[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]

wbdb avatar Aug 22 '25 20:08 wbdb

After spending (wasting) several hours troubleshooting this issue, I found a workaround:

  1. install this http-stdio adapter: npm install -g mcp-remote
  2. specify explicit environment variables in your: C:/Users/username/.codex/config.toml :

` [mcp_servers.learn_mcp]

command = 'node'

args = [ 'C:/Users/username/AppData/Roaming/npm/node_modules/mcp-remote/dist/proxy.js', 'https://learn.microsoft.com/api/mcp' ]

env = { APPDATA = 'C:\Users\username\AppData\Roaming', LOCALAPPDATA = 'C:\Users\username\AppData\Local', SystemRoot = 'C:\WINDOWS', COMSPEC = 'C:\WINDOWS\system32\cmd.exe' } `

evgenyop avatar Aug 25 '25 04:08 evgenyop

Hello, are there another install options?

edulml98 avatar Aug 30 '25 03:08 edulml98

Same issue here. The following is a quick way to fix it:

[mcp_servers.context7]
command = "C:\\.....\\nodejs\\node.exe"
args = ["C:\\Users\\.....\\AppData\\Local\\npm-cache\\_npx\\.....\\node_modules\\@upstash\\context7-mcp\\dist\\index.js"]

I was able to get this working with the server-memory MCP as well.

Update 1/9: I’m now using MCP-Router as the central gateway for all other MCP servers. Then I only need to push this into config.toml:

[mcp_servers.mcp-router]
command = "C:\\...\\bin\\bun.exe" # Or node.exe
args = [".....\\mcpr-cli\\dist\\mcpr.js", "connect"]
env = { SystemRoot = 'C:\WINDOWS', COMSPEC = 'C:\WINDOWS\system32\cmd.exe' , MCPR_TOKEN = "<key>" } # Thanks @evgenyop 

sting8k avatar Aug 30 '25 14:08 sting8k

I started to use Docker MCP Toolkit (you can find there Context7 MCP, Firecrawl, Playwrith and more). And it works for Codex CLI (and Codex VSCode extension).

Details

Image

My config:

[mcp_servers.toolkit]
command = "docker"
args = [
    "mcp",
    "gateway",
    "run"
]
env = { "LOCALAPPDATA" = "C:\\Users\\<USER>\\AppData\\Local", "ProgramFiles" = "C:\\Program Files" }

Xopoko avatar Aug 31 '25 02:08 Xopoko

Is there anyone who can resolve the error “Error searching libraries: TypeError: fetch failed” using Windows 11 cmd?

eburakars avatar Aug 31 '25 09:08 eburakars

I started to use Docker MCP Toolkit (you can find there Context7 MCP, Firecrawl, Playwrith and more). And it works for Codex CLI (and Codex VSCode extension).

Details My config:

[mcp_servers.toolkit]
command = "docker"
args = [
    "mcp",
    "gateway",
    "run"
]
env = { "LOCALAPPDATA" = "C:\\Users\\<USER>\\AppData\\Local", "ProgramFiles" = "C:\\Program Files" }

It didn't work for me. Only the per-server entries below worked. Posting in case it helps others. After a lot of failures trying to spawn MCP servers with npx on Windows, I used ChatGPT to iterate on options and landed on a simple, reliable fix:


Environment

  • Windows 11
  • PowerShell 7.x
  • Docker Desktop
  • Codex CLI (latest at time of writing)

Symptoms

  • npx @playwright/mcp@latest would repeatedly “request timed out” when launched by Codex, even though it worked in MCP Inspector.

What worked (Docker over STDIO)

Pre-pull (optional but speeds up first run): docker pull mcp/playwright docker pull mcp/fetch

Codex config: %USERPROFILE%.codex\config.toml [mcp_servers.fetch] command = "docker" args = ["run","--rm","-i","--init","--security-opt","no-new-privileges","mcp/fetch"] [mcp_servers.fetch.env] PYTHONIOENCODING = "utf-8" PYTHONUNBUFFERED = "1" # avoids rare Python stdio stalls on Windows

[mcp_servers.playwright] command = "docker" args = ["run","--rm","-i","--init","--security-opt","no-new-privileges","mcp/playwright"]

Notes Keep -i (STDIO attached). Don’t use -d.

Sanity checks These should return help immediately: docker run --rm -i mcp/playwright --help docker run --rm -i mcp/fetch --help

hbiaou avatar Sep 01 '25 22:09 hbiaou

To be fair, it should be noted that they do state that it is preferable to use it with WSL. However, now that the VS Code extension has been released, it is time for this to be implemented for Windows as well.

As mentioned, it runs very effectively with WSL, especially since it is already inclined to try Linux commands.

wbdb avatar Sep 02 '25 09:09 wbdb

I think this PR could fix the timeout.

almirb avatar Sep 02 '25 20:09 almirb

This may be helpful for anyone searching for help adding Dart and Firebase MCPs.

I was getting a related error: On Windows 11, Codex fails to start MCP servers with errors like:

🖐 MCP client for dart failed to start: program not found 🖐 MCP client for firebase failed to start: program not found

This happens because Codex spawns processes directly (no cmd.exe), so dart and npx on PATH aren’t found.
For Firebase, running through npx also adds extra startup delay and prompts, causing Codex to time out.

Fix

Wrap with cmd.exe /c. No need for long paths. Also, pass a --dir to Firebase so it doesn’t prompt at startup. (prompts cause timeout)

# ~/.codex/config.toml

# Dart MCP (wrap with cmd.exe)
[mcp_servers.dart]
command = "cmd.exe"
args    = ["/c", "dart", "mcp-server"]

# Firebase MCP (call firebase.cmd directly with project dir)
[mcp_servers.firebase]
command = "firebase.cmd"
args    = ["experimental:mcp", "--dir", "C:\\Users\\USERNAME\\dev\\yourproject"]

eturk1 avatar Sep 02 '25 23:09 eturk1

As a workaround you can run mcp through docker; Downside is to containerize every mcp you use

For example in settings.toml

[mcp_servers.mssql]
command = "docker"
args = [
  "run","-i","--rm",
  "-e","Server=host.docker.internal,1433;User Id=sa;Password=Your_password123;TrustServerCertificate=True;Encrypt=False",
  "medeiroshudson/mssql-mcp:latest"
]

medeiroshudson avatar Sep 05 '25 19:09 medeiroshudson

@medeiroshudson

# Context7 MCP via Docker (stdio)
[mcp_servers.context7]
command = "docker"
args = [
  "run","-i","--rm","--pull","always",
  "-e","CONTEXT7_API_KEY",
  "-e","NO_COLOR","-e","FORCE_COLOR","-e","NODE_NO_WARNINGS","-e","NPM_CONFIG_UPDATE_NOTIFIER",
  "node:22-slim",
  "npx","-y","@upstash/context7-mcp","--transport","stdio"
]

=> MCP client for context7 failed to start: request timed out :(

wbdb avatar Sep 05 '25 20:09 wbdb

I just tested it again after the latest update (https://github.com/openai/codex/commit/cad37009e155b57697dced9795a2b04d7ec8fe3e). Unfortunately, the same error still occurs (timeout). Codex VS Code: Version 0.4.5 (from 2025-09-09). I no longer have Codex CLI on Windows, as I only use it under WSL now.

[mcp_servers.context7]
command = "cmd"
args    = ["/c","npx","-y","@upstash/context7-mcp"]
startup_timeout_ms = 20000

wbdb avatar Sep 09 '25 10:09 wbdb

@wbdb i can confirm the latest codex cli (0.31) doesn't fix the issue on native Windows. But it doesn't seem like the latest version patch suppose to fix what's being discussed here, it's a separate bug.

nikitakot avatar Sep 09 '25 10:09 nikitakot

https://github.com/openai/codex/releases/tag/rust-v0.31.0 now supports startup_timeout_ms, so please use that!

bolinfest avatar Sep 09 '25 17:09 bolinfest