Skip to content

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

Open

Description

@kirso

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"
model_reasoning_effort = "high"

[features]
rmcp_client=true
web_search_request=true

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

[mcp_servers.sentry]
command = "npx"
args = ["-y", "mcp-remote@latest", "https://mcp.sentry.dev/mcp"]

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

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

[mcp_servers.linear]
command = "npx"
args = ["-y", "mcp-remote", "https://mcp.linear.app/sse"]

[mcp_servers.stripe]
command = "npx"
args = [ "mcp-remote", "https://mcp.stripe.com/" ]

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

#[mcp_servers.dataforseo.env]
#DATAFORSEO_USERNAME = "{email}"
#DATAFORSEO_PASSWORD = "{KEY}"

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

[mcp_servers.supabase.env]
SUPABASE_ACCESS_TOKEN = "{KEY}"

[mcp_servers.vercel]
command = "npx"
args = [ "mcp-remote", "https://mcp.vercel.com" ]

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

Activity

  1. added
    mcpIssues related to the use of model context protocol (MCP) servers
    on Oct 31, 2025
  2. github-actions commented on Oct 31, 2025

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. gpeal commented on Nov 3, 2025

    @gpeal
    Contributor

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

  4. benglewis commented on Nov 4, 2025

    @benglewis

    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 (https://mcp.linear.app/sse), when send initialize request

  5. benglewis commented on Nov 4, 2025

    @benglewis

    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::StreamableHttpClientWorkerreqwest::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

  6. jozef-barton commented on Nov 4, 2025

    @jozef-barton

    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

  7. gpeal commented on Nov 4, 2025

    @gpeal
    Contributor

    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::StreamableHttpClientWorkerrmcp::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.

  8. gpeal commented on Nov 4, 2025

    @gpeal
    Contributor

    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?

    Image
  9. gpeal commented on Nov 4, 2025

    @gpeal
    Contributor

    @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?

  10. jozef-barton commented on Nov 4, 2025

    @jozef-barton

    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>"
    
  11. Krinhj commented on Nov 4, 2025

    @Krinhj

    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

  12. YikaJ commented on Nov 5, 2025

    @YikaJ

    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

  13. kirso commented on Nov 5, 2025

    @kirso
    Author

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

    Svelte

    Image

    Setup:

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

    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.

  14. gpeal commented on Nov 5, 2025

    @gpeal
    Contributor

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

    Svelte

    Image Setup:

    [mcp_servers.svelte]
    command = "npx"
    args = ["-y", "@sveltejs/mcp"]
    Image
    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.

    Image
  15. 15 remaining items

  16. purelind commented on Jan 4, 2026

    @purelind

    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.

  17. yangcheng commented on Jan 19, 2026

    @yangcheng

    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
    
  18. SpaceOgre commented on Jan 20, 2026

    @SpaceOgre

    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"]
    
  19. handlemotion commented on Feb 2, 2026

    @handlemotion

    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

  20. MauScheff commented on Feb 2, 2026

    @MauScheff

    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

  21. bjoernzosel commented on Feb 8, 2026

    @bjoernzosel

    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"]

  22. PelleRavn commented on Feb 17, 2026

    @PelleRavn

    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:

    Image
  23. itsmeares commented on Feb 25, 2026

    @itsmeares

    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"

  24. CSchulz commented on Feb 26, 2026

    @CSchulz

    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//.npm/_npx/9833c18b2d85bc59/node_modules/playwright-core
    npm error dest /Users//.npm/_npx/9833c18b2d85bc59/node_modules/.playwright-core-6ShRAoyb
    npm error errno -66
    npm error ENOTEMPTY: directory not empty, rename '/Users//.npm/_npx/9833c18b2d85bc59/node_modules/playwright-core' -> '/Users//.npm/_npx/9833c18b2d85bc59/node_modules/.playwright-core-6ShRAoyb'
    npm error A complete log of this run can be found in: /Users//.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)
    
  25. chanmathew commented on Mar 11, 2026

    @chanmathew

    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.

  26. sean-mcl commented on May 12, 2026

    @sean-mcl

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

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

  27. SylvainWinning commented on May 24, 2026

    @SylvainWinning

    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

  28. david-makhija81 commented on Jun 11, 2026

    @david-makhija81

    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

  29. agenteo commented on Jun 12, 2026

    @agenteo

    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
    
  30. zyowo commented on Jul 20, 2026

    @zyowo

    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" }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmcpIssues related to the use of model context protocol (MCP) servers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions