MCP client for `X` failed to start: handshaking with MCP server failed: connection closed: initialize response

Open 💬 43 comments Opened Oct 31, 2025 by kirso
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.53.0

What subscription do you have?

Pro

Which model were you using?

GPT-5

What platform is your computer?

Darwin 24.6.0 arm64 arm

What issue are you seeing?

All servers fail at once

MCP client for X failed to start: handshaking with MCP server failed: connection closed: initialize response

What steps can reproduce the bug?

Uploaded thread: 019a38db-7497-7b12-bbaa-75edef1f4150

What is the expected behavior?

MCP servers load

Additional information

model = "gpt-5" <br>model_reasoning_effort = "high"

\[features\] <br>rmcp_client=true <br>web_search_request=true

\[mcp_servers.svelte\] <br>command = "npx" <br>args = \["-y", "@sveltejs/mcp"\]

\[mcp_servers.sentry\] <br>command = "npx" <br>args = \["-y", "mcp-remote@latest", "[https://mcp.sentry.dev/mcp](<https://mcp.sentry.dev/mcp>)"\]

\[mcp_servers.posthog\] <br>command = "npx" <br>args = \[ "-y", "mcp-remote@latest", "[https://mcp.posthog.com/sse](<https://mcp.posthog.com/sse>)", "--header", "Authorization: Bearer {KEY}"\]

\[mcp_servers.context7\] <br>command = "npx" <br>args = \["-y", "@upstash/context7-mcp", "--api-key", "{KEY}"\]

\[mcp_servers.linear\] <br>command = "npx" <br>args = \["-y", "mcp-remote", "[https://mcp.linear.app/sse](<https://mcp.linear.app/sse>)"\]

\[mcp_servers.stripe\] <br>command = "npx" <br>args = \[ "mcp-remote", "[https://mcp.stripe.com/](<https://mcp.stripe.com/>)" \]

#\[mcp_servers.dataforseo\] <br>#command = "npx" <br>#args = \[ "-y", "dataforseo-mcp-server"\]

#\[mcp_servers.dataforseo.env\] <br>#DATAFORSEO_USERNAME = "{email}" <br>#DATAFORSEO_PASSWORD = "{KEY}"

\[mcp_servers.supabase\] <br>command = "npx" <br>args = \["-y", "@supabase/mcp-server-supabase@latest"\]

\[mcp_servers.supabase.env\] <br>SUPABASE_ACCESS_TOKEN = "{KEY}"

\[mcp_servers.vercel\] <br>command = "npx" <br>args = \[ "mcp-remote", "[https://mcp.vercel.com](<https://mcp.vercel.com>)" \]

\[mcp_servers.trigger\] <br>command = "npx" <br>args = \[ "trigger.dev@latest", "mcp", "--dev-only" \]

View original on GitHub ↗

43 Comments

github-actions[bot] contributor · 8 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #5805
  • #5855
  • #5619

Powered by Codex Action

gpeal contributor · 8 months ago

Can you specify which of your MCP servers stopped working so I can try to repro?

benglewis · 8 months ago

I got this error with Linear:

■ MCP client for linear failed to start: handshaking with MCP server failed: Send message error Transport [rmcp::transport::worker::WorkerTransport<rmcp::transport::streamable_http_client::StreamableHttpClientWorker<rmcp::transport::auth::AuthClient<reqwest::async_impl::client::Client>> \>] error: Client error: HTTP status client error (404 Not Found) for url (https://mcp.linear.app/sse), when send initialize request
benglewis · 8 months ago

I am also getting this error with Posthog:

■ MCP client for posthog failed to start: handshaking with MCP server failed: Send message error Transport [rmcp::transport::worker::WorkerTransport<rmcp::transport::streamable_http_client::StreamableHttpClientWorker<reqwest::async_impl::client::Client>>] error: Client error: HTTP status client error (404 Not Found) for url (https://mcp.posthog.com/sse), when send initialize request
jozef-barton · 8 months ago

I'm currently getting this for the Chakra UI MCP server as well:

MCP client for chakra-ui failed to start: handshaking with MCP server failed:
connection closed: initialize response

https://chakra-ui.com/docs/get-started/ai/mcp-server

gpeal contributor · 8 months ago
I got this error with Linear: > ■ MCP client for linear failed to start: handshaking with MCP server failed: Send message error Transport > [rmcp::transport::worker::WorkerTransport<rmcp::transport::streamable_http_client::StreamableHttpClientWorker<rmcp::transport::auth::AuthClientreqwest::async_impl::client::Client> > >] error: Client error: HTTP status client error (404 Not Found) for url (mcp.linear.app/sse), when send initialize request

Codex only supports streamable http servers. SSE is deprecated and we may or may not backport support.

Linear's updated server is at https://mcp.linear.app/mcp and posthog looks like MCP.

gpeal contributor · 8 months ago
I'm currently getting this for the Chakra UI MCP server as well: MCP client for chakra-ui failed to start: handshaking with MCP server failed: connection closed: initialize response chakra-ui.com/docs/get-started/ai/mcp-server

@jozef-barton I just tried that MCP server and it worked fine

[mcp_servers.chakra]
command = "npx"
args = ["-y", "@chakra-ui/react-mcp"]

What is in your config.toml?

<img width="1944" height="368" alt="Image" src="https://github.com/user-attachments/assets/b60017eb-fb17-41ad-b3eb-f1817aac71c2" />

gpeal contributor · 8 months ago

@kirso I think all of your MCP issues are either unsupported SSE servers or incorrect configuration. I just tried all of them and I think they're all working. Can you reply with a specific broken server and your config if you think there is still an issue?

jozef-barton · 8 months ago

Thank you for checking this for me. Here's my config.toml.

model = "gpt-5-codex"
model_reasoning_effort = "medium"
experimental_use_rmcp_client = true

[projects."/Users/<user>/dev/<repo>"]
trust_level = "trusted"

[projects."/Users/<user>/dev/<repo>"]
trust_level = "trusted"

[projects."/Users/<user>/dev/<repo>"]
trust_level = "trusted"

[mcp_servers.chakra-ui]
command = "npx"
args = ["-y", "@chakra-ui/react-mcp"]
transport = "stdio"
startup_timeout_sec = 30

[mcp_servers.supabase]
url = "https://mcp.supabase.com/mcp?project_ref=<project_ref>&read_only=true&features=docs"

[mcp_servers.chakra-ui.env]
CHAKRA_PRO_API_KEY = "<api_key>"
Krinhj · 8 months ago

I am getting this when trying to add the Shadcn MCP:

[mcp_servers.shadcn]
command = "cmd"
args = ["/c", "npx", "-y", "@shadcn@latest", "mcp"]
startup_timeout_sec = 20.0

[mcp_servers.shadcn.env]
SystemRoot = "C:\\Windows"

■ MCP client for shadcn failed to start: handshaking with MCP server failed: connection closed: initialize response

YikaJ · 8 months ago

same error.

I tested my own local Nodejs file, still get the error:
■ MCP client for ppt-agent failed to start: handshaking with MCP server
failed: connection closed: initialize response

kirso · 8 months ago

@gpeal apologies for the late response, here is a list of servers that is still failing for me.

Svelte

<img width="852" height="324" alt="Image" src="https://github.com/user-attachments/assets/cc29102a-b1a0-452e-95ea-68dac3564e0d" />

Setup:

[mcp_servers.svelte]
command = "npx"
args = ["-y", "@sveltejs/mcp"]

<img width="2280" height="784" alt="Image" src="https://github.com/user-attachments/assets/c1b3757d-2ca1-4ea1-99b9-aa3cacc03970" />

Official docs: https://svelte.dev/docs/mcp/remote-setup#Codex-CLI

Once I changed to:

[mcp_servers.svelte]
url = "https://mcp.svelte.dev/mcp"

For a remote implementation, it picked it up, so it seems indeed the error is SSE and in case you are not supporting it then its expected behavior

To add, did something change? They all used to work fine and broke a few weeks back.

gpeal contributor · 8 months ago
@gpeal apologies for the late response, here is a list of servers that is still failing for me. Svelte <img alt="Image" width="852" height="324" src="https://private-user-images.githubusercontent.com/2138870/510056972-cc29102a-b1a0-452e-95ea-68dac3564e0d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjIzNTkzMTcsIm5iZiI6MTc2MjM1OTAxNywicGF0aCI6Ii8yMTM4ODcwLzUxMDA1Njk3Mi1jYzI5MTAyYS1iMWEwLTQ1MmUtOTVlYS02OGRhYzM1NjRlMGQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MTEwNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTExMDVUMTYxMDE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjI0M2MzOWUzMzk5YWFhNGIxZGNkMDdiNDZjYjg4NmIyY2NjYjRhYmNmYWY0M2MzNjc1MGE3NmZhMjc3ZGFkMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.rfjT4PAvzA1ko7qIUk9TA9RACo4XWJjVv1I7OsZHIzc"> Setup: [mcp_servers.svelte] command = "npx" args = ["-y", "@sveltejs/mcp"] <img alt="Image" width="2000" height="784" src="https://private-user-images.githubusercontent.com/2138870/510057365-c1b3757d-2ca1-4ea1-99b9-aa3cacc03970.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjIzNTkzMTcsIm5iZiI6MTc2MjM1OTAxNywicGF0aCI6Ii8yMTM4ODcwLzUxMDA1NzM2NS1jMWIzNzU3ZC0yY2ExLTRlYTEtOTliOS1hYTNjYWNjMDM5NzAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MTEwNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTExMDVUMTYxMDE3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTU0NzUxN2UyNDJlOTk1ZTk3ZmRmZTU5MzVhN2NjODVlYjQ0YWJjYjEyM2Q5OTlhM2QwOWY3YWM3OWQzYzkyNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.kzsdDHrgLvrtGtxOSAr1XwHDCIRMdm_BBlaYwaHWL5Q"> Official docs: svelte.dev/docs/mcp/remote-setup#Codex-CLI Once I changed to: [mcp_servers.svelte] url = "https://mcp.svelte.dev/mcp" For a remote implementation, it picked it up, so it seems indeed the error is SSE and in case you are not supporting it then its expected behavior To add, did something change? They all used to work fine and broke a few weeks back.

Intersting, both the local and remote svelte MCP worked just fine when I tried it. What happens if you run that npx command in the same termianl outside of the terminal? Do you see it start successfully? If so, the command should appear as if it's running but not doing anything but no errors and it should not exit on its own.

<img width="1897" height="686" alt="Image" src="https://github.com/user-attachments/assets/f2e0e189-7742-4832-aa07-02c34e627231" />

gpeal contributor · 8 months ago
ppt-agent

@YikaJ can you run tail -f ~/.codex/log/codex-tui.log if you're on macOS or check the logs from the equivalent CODEX_HOME path on Windows? When I run it, I see these logs because I haven't fully configured ppt-agent so maybe you have a similar issue:

2025-11-05T16:16:41.417426Z  INFO MCP server stderr (uv): 2025-11-05 08:16:41,417 - ERROR - mcp_server.py:71 - Unable to connect to the model, please set the PPTAGENT_MODEL, PPTAGENT_API_BASE, and PPTAGENT_API_KEY environment variables correctly
2025-11-05T16:16:41.417462Z  INFO MCP server stderr (uv): ERROR:pptagent.mcp_server:Unable to connect to the model, please set the PPTAGENT_MODEL, PPTAGENT_API_BASE, and PPTAGENT_API_KEY environment variables correctly
jozef-barton · 8 months ago

For anybody running into the same problem I did, I used some ChatGPT and tinkering and found the problem was that codex was pointed to Node 23 when the MCP server I'm using only supports Node 20/22. Changing that fixed the problem.

sruckh · 8 months ago

I get the same error following the instructions on the Zen MCP server page for codex.
``
[mcp_servers.zen]
command = "bash"
args = ["-c", "for p in $(which uvx 2>/dev/null) $HOME/.local/bin/uvx /opt/homebrew/bin/uvx /usr/local/bin/uvx uvx; do [ -x \\\"$p\\\" ] && exec \\\"$p\\\" --from git+https://github.com/BeehiveInnovations/zen-mcp-server.git zen-mcp-server; done; echo 'uvx not found' >&2; exit 1"]
tool_timeout_sec = 1200

[mcp_servers.zen.env]
PATH = "/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/bin:/opt/docker/zen-mcp-server"
GEMINI_API_KEY = "redacted"
OPENAI_API_KEY = "redacted"
OPENROUTER_API_KEY = "redacted"
CUSTOM_API_URL = "https://api.z.ai/api/paas/v4"
CUSTOM_API_KEY = "redacted"
CUSTOM_MODEL_NAME = "glm-4.6"
DEFAULT_MODEL = "auto"
DEFAULT_THINKING_MODE_THINKDEEP = "high"
CONVERSATION_TIMEOUT_HOURS = "24"
MAX_CONVERSATION_TURNS = "40"
LOG_LEVEL = "DEBUG"
DISABLED_TOOLS = "analyze,refactor,testgen,secaudit,docgen,tracer"
ZEN_MCP_FORCE_ENV_OVERRIDE = "false"
COMPOSE_PROJECT_NAME = "zen-mcp"
TZ = "UTC"
LOG_MAX_SIZE = "10MB

sonomirco · 8 months ago

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

craftgear · 8 months ago

@jozef-barton Could you elaborate a bit?
How did you change codex pointing node from 23 to 22?

makeavish · 8 months ago
For anybody running into the same problem I did, I used some ChatGPT and tinkering and found the problem was that codex was pointed to Node 23 when the MCP server I'm using only supports Node 20/22. Changing that fixed the problem.

Thanks! This fixed it for me! I switched back to Node 22 and it worked.

kirso · 8 months ago

I've partially solved this for the majority of MCP servers by switching them to streaming http and just using codex mcp login command.

However one server is still throwing the same error that I can't bypass and I just can't figure out from the docs how to set it up.

The MCP requires an Auth Bearer token

[mcp_servers.posthog]
command = "npx"
args = ["-y", "mcp-server", "https://mcp.posthog.com/sse", "--header", "Authorization: Bearer <TOKEN>"]

It still fails with handshaking, it doesn't support oath and is pure SSE with the old implementation it never loads, but used to load fine like a month ago.

Am I missing something here?

I think what is frustrating that a lot of these are not backward compatible after changes, so its hard to find specific issues. They work one month, and then stop after internal changes but I might also have a skill issue...

kentkost · 7 months ago

I was trying to add decriptor/AvaloniaUI.MCP.
I got the following errors:

⚠ MCP client for avalonia failed to start: MCP startup failed: handshaking with MCP server failed: connection closed: initialize response 
⚠ MCP startup incomplete (failed: avalonia)

After a lot of Trial and error me and AI figured out the reason for it was that the logger in AvaloniaUI.MCP vomits logs to STDOUT.
So Codex receives garbage before the JSON handshake.

I fixed the code in AvaloniaUI.MCP by editing the following:

builder.Logging.AddConsole();

to

builder.Logging.AddConsole(o =>
{
    o.LogToStandardErrorThreshold = LogLevel.Trace;
});

I imagine it is the same for a lot other MCPs failing.

sonomirco · 7 months ago
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.

shriyash-fundrev · 7 months ago

I also had same issue I just installed latest npm package for playwright globally using npm i -g @playwright/mcp@latest and it worked.

JeongJuhyeon · 7 months ago

@gpeal You need to make Codex handle logs being sent before the handshake. We've used at least 3 other clients (including Claude Code as well as open source ones) and none of them had issues with this. It's not debuggable either as all you're sending is connection closed: initialize response. We've got a bunch of people running into this in this thread alone.

AyinMostima · 7 months ago
@gpeal You need to make Codex handle logs being sent before the handshake. We've used at least 3 other clients (including Claude Code as well as open source ones) and none of them had issues with this. It's not debuggable either as all you're sending is connection closed: initialize response. We've got a bunch of people running into this in this thread alone.

The Codex team is absolutely terrible. I pay $200 a month for the subscription, and I encounter these kinds of minor problems every single day. ​​Every other CLI works fine except for theirs, and the newline input issue hasn't been fixed for almost a year. They should really beg Claude Code to teach them something useful.

failcoach · 6 months ago

@AyinMostima but we did get Sora app 😂

Joke aside ... I have same issues with Supabase MCP ... and the only solution is to re-authenticate every day when I start Codex
I haven't seen this issue with any other model ... just codex.

Mansehej · 6 months ago
For anybody running into the same problem I did, I used some ChatGPT and tinkering and found the problem was that codex was pointed to Node 23 when the MCP server I'm using only supports Node 20/22. Changing that fixed the problem.

Worked for me as well. However I had to clear my .npm folder (rm -rf Users/<username>/.npm) for it to work after changing the node version.

kirso · 6 months ago
> For anybody running into the same problem I did, I used some ChatGPT and tinkering and found the problem was that codex was pointed to Node 23 when the MCP server I'm using only supports Node 20/22. Changing that fixed the problem.

I am on node 22, and this didn't help unfortunately. Its always an issue with specific MCP servers that require some special treatment like env.

[mcp_servers.dfs-mcp]
command = "npx"
args = ["-y", "dataforseo-mcp-server"]
startup_timeout_sec = 20

[mcp_servers.dfs-mcp.env]
DATAFORSEO_USERNAME = X
DATAFORSEO_PASSWORD = X

This for instance triggers the same error :/

purelind · 6 months ago

I also encountered this problem recently when using @playwright/mcp@latest. Then I tried to start it directly using npx in the terminal.

~ ❯ npx -y @playwright/mcp@latest
npm error code ENOTEMPTY
npm error syscall rename
npm error path /Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/playwright-core
npm error dest /Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/.playwright-core-6ShRAoyb
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '/Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/playwright-core' -> '/Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/.playwright-core-6ShRAoyb'
npm error A complete log of this run can be found in: /Users/<username>/.npm/_logs/2026-01-04T06_17_50_725Z-debug-0.log

After deleting the npm/_npx/9833c18b2d85bc59 directory under the home directory, the mcp returned to normal.

yangcheng · 6 months ago

I have same error with supabase mcp, i setup use codex mcp add supabase --url http://localhost:54321/mcp
according to https://supabase.com/docs/guides/getting-started/mcp , I also have added

[features]
rmcp_client = true
SpaceOgre · 6 months ago

I'm having this problem with the https://github.com/microsoft/azure-devops-mcp server

[mcp_servers.azure-devops.env]
ADO_MCP_AUTH_TOKEN = "<PAT>"

[mcp_servers.azure-devops]
command = "npx"
args = ["-y", "@azure-devops/mcp", "--authentication", "envvar", "grutbildning"]
handlemotion · 5 months ago

Getting the same issue with context 7 MCP

MCP client for `context7` failed to start: MCP startup failed: handshaking with MCP server failed: Send message error Transport
  [rmcp::transport::worker::WorkerTransport<rmcp::transport::streamable_http_client::StreamableHttpClientWorker<rmcp::transport::auth::AuthClient<reqwest::async_impl::client::Client>>>] error: Auth error: OAuth token refresh failed: Server returned
  error response: invalid_grant: The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued
  to another client. The refresh token is malformed or not valid., when send initialize request

with the proper context 7 config

[mcp_servers.context7]
url = "https://mcp.context7.com/mcp"
http_headers = { "CONTEXT7_API_KEY" = "" }

it's trying to force OAuth even when using the context 7 API url https://context7.com/api/v2 as well

MauScheff · 5 months ago

What worked for me with Posthog (mcp-remote) was to follow the advice here for Cursor and Claude Desktop.

I used an AUTH_TOKEN and no spaces in the header, like this:

npm install -g mcp-remote@latest
````

[mcp_servers.posthog]
command = "mcp-remote"
args = [
"https://mcp-eu.posthog.com/sse",
"--header",
"Authorization:${CUTS_POSTHOG_MCP_API_KEY}",
]
env = { CUTS_POSTHOG_MCP_API_KEY = "Bearer phx_**************************" }


You may need to create a Personal API Key in Posthog:
[https://us.posthog.com/login?next=/settings/user-api-keys%3Fpreset%3Dmcp_server](https://us.posthog.com/login?next=/settings/user-api-keys%3Fpreset%3Dmcp_server)
bjoernzosel · 5 months ago

Having the problem with https://github.com/laravel/boost

⚠ MCP client for laravel-boost failed to start: MCP startup failed:
handshaking with MCP server failed: connection closed: initialize response

⚠ MCP startup incomplete (failed: laravel-boost)


[mcp_servers.laravel-boost]
command = "php"
args = ["artisan", "boost:mcp"]

PelleRavn · 5 months ago

I having the same problem with XcodeBuildMCP (version 2.0.7):

[mcp_servers.XcodeBuildMCP]
args = [
"-lc",
"PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin; export NVM_DIR=\"$HOME/.nvm\"; [ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"; nvm use --silent >/dev/null 2>&1 || true; npx -y xcodebuildmcp@latest mcp"
]
command = "/bin/zsh"
enabled = true
tool_timeout_sec = 10000

And here's Codex' explanation of the problem:

<img width="762" height="500" alt="Image" src="https://github.com/user-attachments/assets/2dc34ebf-5f43-4202-892c-22dfea8df15e" />

itsmeares · 4 months ago
I have same error with supabase mcp, i setup use codex mcp add supabase --url http://localhost:54321/mcp according to https://supabase.com/docs/guides/getting-started/mcp , I also have added `` [features] rmcp_client = true ``

Can you try with hosted platform installation?

Go to https://supabase.com/docs/guides/getting-started/mcp

For platform, select "Hosted"
For project, select the project you want.

And select "Codex" as the client.

It should give you a command that looks like this:

"codex mcp add supabase --url https://mcp.supabase.com/mcp..."

After doing that, don't forget to run "codex mcp login supabase"

CSchulz · 4 months ago
I also encountered this problem recently when using @playwright/mcp@latest. Then I tried to start it directly using npx in the terminal. ~ ❯ npx -y @playwright/mcp@latest npm error code ENOTEMPTY npm error syscall rename npm error path /Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/playwright-core npm error dest /Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/.playwright-core-6ShRAoyb npm error errno -66 npm error ENOTEMPTY: directory not empty, rename '/Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/playwright-core' -> '/Users/<username>/.npm/_npx/9833c18b2d85bc59/node_modules/.playwright-core-6ShRAoyb' npm error A complete log of this run can be found in: /Users/<username>/.npm/_logs/2026-01-04T06_17_50_725Z-debug-0.log After deleting the npm/_npx/9833c18b2d85bc59 directory under the home directory, the mcp returned to normal.

This was the solution for me as well.

It would be a nice addition if Codex Desktop / CLI is telling you that there is an issue while running the npx command.

The Codex CLI gives you more information but no details about the failure:

⚠ MCP client for `local-mcp` failed to start: MCP startup failed: handshaking with MCP server failed: connection closed: initialize
  response
⚠ MCP startup incomplete (failed: local-mcp)
chanmathew · 4 months ago
I have same error with supabase mcp, i setup use codex mcp add supabase --url http://localhost:54321/mcp according to https://supabase.com/docs/guides/getting-started/mcp , I also have added `` [features] rmcp_client = true ``

Same here. Remote one works, just not the local one.

sean-mcl · 2 months ago

I had to add the env variable for the MCP in the config.toml.

NODIST_PREFIX = "C:\\Program Files (x86)\\Nodist"

SylvainWinning · 1 month ago

I took a closer look at the current codex doctor MCP check and I think there is a small support-friendly step that would help reports like the ones in this thread without trying to fully start every MCP server from doctor.

A narrow MVP would be to keep the existing mcp.config detail strings, but also emit structured issues[] entries in codex doctor --json for the MCP cases that can already be detected locally:

  • stdio command is empty or not resolvable;
  • configured cwd does not exist;
  • forwarded env_vars are absent from the launching environment;
  • env_vars uses source = "remote" for a local stdio server;
  • HTTP bearer/header env vars are absent;
  • streamable HTTP endpoint probe fails.

That would make the uploaded doctor report easier to triage because support tooling could read cause, measured, expected, remedy, and the config field path (mcp_servers.<name>...) instead of parsing free-form detail lines. It also complements #19023: docs can explain env vs env_vars, while doctor can show exactly which forwarded variable or command path is missing on the user’s machine.

I prepared a local patch for this shape, including tests around missing env_vars and remote-sourced env vars. I am not opening an unsolicited PR because the repo’s contribution policy says external code contributions are invitation-only, but if this direction is useful I can share the branch/patch or adapt the scope.

Branch with the local implementation: https://github.com/SylvainWinning/codex/tree/codex/mcp-doctor-diagnostics

david-makhija81 · 1 month ago

I had the same issue. It happens because network access is disabled for Codex, which blocks the automatic setup. You can fix it by manually installing context7. Just open your terminal and run this command:
npx ctx7 setup

agenteo · 1 month ago

Sadly I don't have any data/logs but this used to work around Jan/Feb 2026 when I had sentry MCP setup (it would just open a browser window like claude code) to get the right tokens.

Right now in wsl when I open codex I am getting the:

⚠ MCP client for `sentry` failed to start: MCP startup failed: handshaking with MCP server failed: connection closed: initialize response

⚠ MCP startup incomplete (failed: sentry)

Following Sentry's docs: https://mcp.sentry.dev/?ide=codex-cli

codex mcp add sentry -- npx -y mcp-remote@latest https://mcp.sentry.dev/mcp
zyowo · 19 hours ago

I also encountered this issue when using UnityMCP

⚠ MCP client for unityMCP failed to start: MCP startup failed: handshaking with MCP server failed: connection closed:
initialize response

⚠ MCP startup incomplete (failed: unityMCP)

It works fine with the HTTP server, but fails to connect when using Stdio.

I tried the official configuration and versions of Node.js 18-23, but neither worked. Installing CTX7 also didn't help.

[mcp_servers.unityMCP]
command = "C:\\Users\\myname\\.local\\bin\\uvx.exe"
args = [ "--offline", "--from", "mcpforunityserver==9.6.8", "mcp-for-unity", "--transport", "stdio" ]
startup_timeout_sec = 60
env = { SystemRoot = "C:\\Windows" }