codex icon indicating copy to clipboard operation
codex copied to clipboard

Codex extension in vscode: MCP server (Context7) fails with “request timed out”

Open CongDon1207 opened this issue 1 year ago • 17 comments

What version of Codex is running?

0.4.3

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?

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 = "C:\Program Files\nodejs\npx.cmd" args = ["-y","@upstash/context7-mcp@latest","--transport","stdio"] => 🖐 MCP client for context7 failed to start: request timed out

So i change: 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","st

=> i work but unfortunately, I keep getting errors like this :( "result": { "Ok": { "content": [ { "text": "Error searching libraries: TypeError: fetch failed", "type": "text" } ] }

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

CongDon1207 avatar Sep 08 '25 01:09 CongDon1207

Almost all mcps servers encounter this problem in windows, I believe it's related to a winsocket error.

ahSOLO avatar Sep 08 '25 04:09 ahSOLO

@ahSOLO This isn't the main issue. The core problem is that codex's MCP timeout defaults to 10 seconds. Even when we manually execute "npx -y @upstash/context7-mcp" in the terminal, it exceeds 10 seconds.

sfz009900 avatar Sep 08 '25 07:09 sfz009900

same here:

>_ You are using OpenAI Codex in ~/code/lobe-chat

 To get started, describe a task or try one of these commands:

 /status - show current session configuration and token usage
 /approvals - choose what Codex can do without approval
 /model - choose what model and reasoning effort to use

🖐  MCP client for `SearXNG` failed to start: request timed out

🖐  MCP client for `vscode-mcp` failed to start: request timed out

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

🖐  MCP client for `chrome-mcp` failed to start: request timed out

tjx666 avatar Sep 08 '25 09:09 tjx666

@ahSOLO This isn't the main issue. The core problem is that codex's MCP timeout defaults to 10 seconds. Even when we manually execute "npx -y @upstash/context7-mcp" in the terminal, it exceeds 10 seconds.

Yeah I understand the timeout is too low, but even if you find a way around that (local installation, proxy server), you'll still get that error on a native Windows environment due to the winsocket error. For me I had to use WSL to escape it.

ahSOLO avatar Sep 08 '25 12:09 ahSOLO

Same problem here.

It was working ok in my 2 computers, but after a few days stopped working in both.

RodrigoMunozP avatar Sep 10 '25 07:09 RodrigoMunozP

没用的,我设置超时为600秒,照样超时

luodaoyi avatar Sep 11 '25 11:09 luodaoyi

@luodaoyi Check out my solution! 😉 https://github.com/openai/codex/issues/3385

sfz009900 avatar Sep 11 '25 12:09 sfz009900

@luodaoyi Check out my solution! 😉 #3385

It work‘s ! Thanks ,

luodaoyi avatar Sep 13 '25 04:09 luodaoyi

@luodaoyi Check out my solution! 😉 #3385

I tried your solution and it worked, thanks.

CongDon1207 avatar Sep 13 '25 06:09 CongDon1207

@luodaoyi Check out my solution! 😉 #3385

Thanks @sfz009900, TLDR; just add startup_timeout_ms = XXXXX for each mcp

# example
[mcp_servers.playwright]
command = "npx"
startup_timeout_ms = 20_000
args = ["@playwright/mcp@latest"]

because some MCP installations take longer than the codex default timeout.

suraneti avatar Sep 15 '25 03:09 suraneti

@luodaoyi Check out my solution! 😉 #3385

Thanks @sfz009900, TLDR; just add startup_timeout_ms = XXXXX for each mcp

# example
[mcp_servers.playwright]
command = "npx"
startup_timeout_ms = 20_000
args = ["@playwright/mcp@latest"]

because some MCP installations take longer than the codex default timeout.

不是timeout的问题是环境变量的问题!环境变量设置后期才可以正常启动mcp,否则timeout不管改多少都会超时

luodaoyi avatar Sep 15 '25 07:09 luodaoyi

I'm using mac and same things happen to me as well....

ryoppippi avatar Sep 16 '25 14:09 ryoppippi

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-key",
]
env = { SystemRoot="C:\\Windows" }
startup_timeout_ms = 20_000

wbdb avatar Sep 17 '25 22:09 wbdb

@wbdb env = { SystemRoot="C:\Windows" } ,This method is effective, very good

Opawn avatar Sep 18 '25 03:09 Opawn

After testing, I found the following three feasible solutions:

  1. Start context7-mcp directly (context7 must be installed in advance):
[mcp_servers.context7]
command = "C:\\Users\\{Your Windows Username}\\AppData\\Roaming\\npm\\context7-mcp.cmd"
args = []
  1. Use the absolute path for npx (using npx instead of path will result in an error stating that the program not found):
[mcp_servers.context7]
command = "C:\\Users\\{Your Windows Username}\\AppData\\Roaming\\npm\\npx.cmd"
args = [
    "-y",
    "@upstash/context7-mcp"
]
env = { SystemRoot="C:\\Windows", APPDATA="C:\\Users\\{Your Windows Username}\\AppData\\Roaming" }
  1. Use cmd:
[mcp_servers.context7]
command = "cmd"
args = [
    "/c",
    "npx",
    "-y",
    "@upstash/context7-mcp"
]
env = { SystemRoot="C:\\Windows", APPDATA="C:\\Users\\{Your Windows Username}\\AppData\\Roaming" }

Among them, the env configuration is required for the 2nd and 3rd plans. If you still receive a "request timed out" message, add the following line: startup_timeout_ms = 20_000 to resolve the issue.

kv-chiu avatar Oct 15 '25 13:10 kv-chiu

The direct cause of this issue is the environment variable whitelist.

codex-rs/mcp-client/src/mcp_client.rs:435

https://github.com/openai/codex/issues/4180

kv-chiu avatar Oct 15 '25 13:10 kv-chiu

I think this issue is now addressed by the changes to the environment variable whitelist. If you see any further problems related to this, please let us know.

etraut-openai avatar Nov 18 '25 02:11 etraut-openai