You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codex CLI hangs when configured to use codex mcp-server as an MCP server #6664
When configuring Codex CLI to connect to Codex’s own MCP server (via the codex mcp-server subcommand), the Codex CLI hangs indefinitely when listing MCP servers (e.g., using the /mcp command). The MCP server never initializes successfully and no tools are exposed.
2. Start the Codex CLI with: `codex`
3. In the CLI, run: `/mcp`
What is the expected behavior?
Expected Behavior
• Codex CLI should successfully start codex mcp-server as an MCP server.
• /mcp should list the MCP server and its tools.
Actual Behavior
• /mcp hangs indefinitely
• Trying to kill the Codex CLI with cmd + C doesn't work
• No MCP tools ever appear.
• The child codex mcp-server process appears to start but the CLI never completes the MCP handshake.
Additional information
No response
Reacted by Wesley Wang, TypeFunctor, matssk, Anthony Rogliano, Daniel Andersson, Kennedy and Jason Bosco
@Zyy0530 If you want a workaround, I found a reliable approach:
use a small Node.js HTTP MCP wrapper instead of connecting the Codex CLI directly to codex mcp-server.
The idea is to run a tiny HTTP server that:
1. launches codex mcp-server internally (via stdio)
2. auto-approves Codex confirmation prompts
3. re-exports the Codex MCP tools over HTTP using @modelcontextprotocol/sdk
Then in your config.toml, enable the HTTP MCP client and point Codex to the wrapper:
@thomaswitt, you mentioned that it used to work great. Does that mean you suspect a regression? If so, can you provide any further details, including repro steps and the version where you saw the behavior change? We haven't spent much time on this issue because we don't have a good repro.
codex - codex (MCP)(prompt: "Review the following architecture plan for …
but then runs basically for 30-40+ minutes. It insists that the MCP call aborted:
Thomas is checking if I'm still here again. The Codex MCP call got aborted. Let me try again -
maybe with a shorter prompt or just acknowledge and retry.
⏺ Nope, wide awake! The Codex MCP server keeps aborting — let me retry with a more focused prompt:
I also see in the ps task list that the command itself is running: codex -m gpt-5.2-codex -s read-only -a never -c model_reasoning_effort=high mcp-server
This doesnt happen EVERY time, but in 70% of the time.
I didn't have these problems until around end of this year. Unfortunately I can't pinpoint them to a specific release.
OK, thanks for the details. That's still not a lot to go on. Since this issue has been reported only by a few users in the past several months, it hasn't been a big priority for us to investigate (relative to many other higher-impact issues), so community help is welcome here. If anyone is able to pinpoint concrete repro steps — or better yet, root cause the problem, that would be most helpful.
@etraut-openai It would be helpful if I could SOMEWHERE get some debugging output from Codex. I don't know if it's even starting to work, if it hangs because of questions (tried to avoid that with -a never) ... at least a mcp list command for the current thread ids and get an in-between result would be very helpful, as it apparently doesn't stream his results (that's at least what I assume).
Claudes session logs are also not much more insightful:
After a while, this file disappears, but claude still says codex - codex (MCP)(prompt: "You are reviewing...
So maybe the commuication that the job is done doesnt go well?
I can reproduce a narrower root cause for this on codex-cli 0.114.0.
This is not a full MCP handshake failure. initialize and tools/list succeed. The hang is specifically that codex mcp-server never replies to:
resources/list
resources/templates/list
That explains why /mcp wedges: the snapshot path waits for tools, resources, and resource templates together, so tools may already be available but the overall /mcp request stays blocked until the resource timeout expires.
Minimal JSON-RPC repro
This reproduces against a command that launches codex ... mcp-server over stdio.
Note: We've announced that the mcp-server is deprecated and will be removed in a future release. We recommend using the app server interface instead. We won't be prioritizing any bug fixes in the mcp-server, so I'm going to close this issue.
@etraut-openai Feedback - the MCP server is a vital part of our orchestration with claude. Removing it will cause a lot of code to be rewritten. Please reconsider.
Activity
github-actions commentedon Nov 14, 2025
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Xfailed to start: handshaking with MCP server failed: connection closed: initialize response #6020Powered by Codex Action
Zyy0530 commentedon Nov 14, 2025
same issue
NikTheGeek1 commentedon Nov 14, 2025
@Zyy0530 If you want a workaround, I found a reliable approach:
use a small Node.js HTTP MCP wrapper instead of connecting the Codex CLI directly to codex mcp-server.
The idea is to run a tiny HTTP server that:
1. launches codex mcp-server internally (via stdio)
2. auto-approves Codex confirmation prompts
3. re-exports the Codex MCP tools over HTTP using @modelcontextprotocol/sdk
Then in your config.toml, enable the HTTP MCP client and point Codex to the wrapper:
This gives you full access to all Codex tools, just routed through a stable HTTP layer instead of the stdio path that currently hangs.
Not ideal long-term, but it’s a clean and reliable workaround until the direct stdio communication is fixed.
raghudinesht commentedon Dec 5, 2025
same issue
thomaswitt commentedon Jan 30, 2026
Same here. Used to work great, until it didnt.
etraut-openai commentedon Jan 30, 2026
@thomaswitt, you mentioned that it used to work great. Does that mean you suspect a regression? If so, can you provide any further details, including repro steps and the version where you saw the behavior change? We haven't spent much time on this issue because we don't have a good repro.
thomaswitt commentedon Jan 30, 2026
@etraut-openai I added codex as an MCP server in claude:
I see that Claude calls the MCP server:
codex - codex (MCP)(prompt: "Review the following architecture plan for …but then runs basically for 30-40+ minutes. It insists that the MCP call aborted:
I also see in the ps task list that the command itself is running:
codex -m gpt-5.2-codex -s read-only -a never -c model_reasoning_effort=high mcp-serverThis doesnt happen EVERY time, but in 70% of the time.
I didn't have these problems until around end of this year. Unfortunately I can't pinpoint them to a specific release.
etraut-openai commentedon Jan 30, 2026
OK, thanks for the details. That's still not a lot to go on. Since this issue has been reported only by a few users in the past several months, it hasn't been a big priority for us to investigate (relative to many other higher-impact issues), so community help is welcome here. If anyone is able to pinpoint concrete repro steps — or better yet, root cause the problem, that would be most helpful.
thomaswitt commentedon Jan 30, 2026
@etraut-openai It would be helpful if I could SOMEWHERE get some debugging output from Codex. I don't know if it's even starting to work, if it hangs because of questions (tried to avoid that with -a never) ... at least a mcp list command for the current thread ids and get an in-between result would be very helpful, as it apparently doesn't stream his results (that's at least what I assume).
Claudes session logs are also not much more insightful:
thomaswitt commentedon Jan 30, 2026
@etraut-openai I also found this debug output in /private/tmp/...claude../tasks/, in case that helps....
{ "parentUuid": "779944d3-055d-4e70-95c2-bc1cc5569cb6", "isSidechain": true, "userType": "external", "cwd": "/Users/thomas/Dev/myproject", "sessionId": "76a784c5-ffe7-4bcc-9e34-722017cab969", "version": "2.1.25", "gitBranch": "264-ingestion", "agentId": "afa4c31", "slug": "stateful-weaving-pancake", "message": { "model": "claude-opus-4-5-20251101", "id": "msg_01Fn1cbUSCFRhgER3VLbQjL6", "type": "message", "role": "assistant", "content": [ { "type": "tool_use", "id": "toolu_01KFTifai2R3nqagY2Qui163", "name": "mcp__codex__codex", "input": { "prompt": "You are reviewing a [...shortened...]", "cwd": "/Users/thomas/Dev/myproject" }, "caller": { "type": "direct" } } ], "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 3, "cache_creation_input_tokens": 814, "cache_read_input_tokens": 53067, "cache_creation": { "ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 814 }, "output_tokens": 2, "service_tier": "standard" } }, "requestId": "req_011CXe8KRzESAv3ZF5amaWKf", "type": "assistant", "uuid": "8306e5d7-6c65-4b0d-80d9-4bc56cadb885", "timestamp": "2026-01-30T19:38:39.940Z" } { "parentUuid": "8306e5d7-6c65-4b0d-80d9-4bc56cadb885", "isSidechain": true, "userType": "external", "cwd": "/Users/thomas/Dev/myproject", "sessionId": "76a784c5-ffe7-4bcc-9e34-722017cab969", "version": "2.1.25", "gitBranch": "264-ingestion", "agentId": "afa4c31", "slug": "stateful-weaving-pancake", "type": "progress", "data": { "type": "mcp_progress", "status": "started", "serverName": "codex", "toolName": "codex" }, "toolUseID": "toolu_01KFTifai2R3nqagY2Qui163", "parentToolUseID": "toolu_01KFTifai2R3nqagY2Qui163", "uuid": "b58b00b4-596f-4809-9f3a-82dd88d916b8", "timestamp": "2026-01-30T19:38:40.051Z" }After a while, this file disappears, but claude still says
codex - codex (MCP)(prompt: "You are reviewing...So maybe the commuication that the job is done doesnt go well?
Penlect commentedon Mar 15, 2026
I can reproduce a narrower root cause for this on
codex-cli 0.114.0.This is not a full MCP handshake failure.
initializeandtools/listsucceed. The hang is specifically thatcodex mcp-servernever replies to:resources/listresources/templates/listThat explains why
/mcpwedges: the snapshot path waits for tools, resources, and resource templates together, so tools may already be available but the overall/mcprequest stays blocked until the resource timeout expires.Minimal JSON-RPC repro
This reproduces against a command that launches
codex ... mcp-serverover stdio.Control:
initializeandtools/listworkObserved:
initializeresponds immediatelytools/listresponds immediatelyFailure:
resources/listnever respondsObserved:
initializerespondsresources/listbeforetimeoutkills the pipelineFailure:
resources/templates/listnever respondsSame setup, replacing the last request with:
{"jsonrpc":"2.0","id":3,"method":"resources/templates/list","params":{}}Observed:
initializerespondsresources/templates/listSource-level explanation
Current source appears to explain this:
ClientRequest::ListResourcesRequestandClientRequest::ListResourceTemplatesRequestare acceptedhandle_list_resources()andhandle_list_resource_templates()only log and returnRequestIdsend_response(...)orsend_error(...)So the server is silently accepting the request and then never replying.
Requested fixes
Server-side
For
resources/listandresources/templates/list, please either:METHOD_NOT_FOUNDThe current behavior of accepting the request and never replying is a protocol bug.
Client-side
/mcpshould not block tool listing on optional resource enumeration.Even if one server:
/mcpshould still render tools and remain responsive.This also looks related to the broader “Codex over-indexes on resources/list” issue family for tool-only MCP servers.
personal(codex-review): harden codex invocation in review skills
etraut-openai commentedon Aug 26, 2026
Note: We've announced that the mcp-server is deprecated and will be removed in a future release. We recommend using the app server interface instead. We won't be prioritizing any bug fixes in the mcp-server, so I'm going to close this issue.
thomaswitt commentedon Aug 26, 2026
@etraut-openai Feedback - the MCP server is a vital part of our orchestration with claude. Removing it will cause a lot of code to be rewritten. Please reconsider.
thomaswitt commentedon Aug 29, 2026
FYI, I wrote an mcp agent which makes codex behave like an mcp server using its app server: https://github.com/thomaswitt/mcp-agents