What version of Codex CLI is running?
codex-cli 0.104.0
What subscription do you have?
ChatGPT Pro
Which model were you using?
gpt-5.3-codex
What platform is your computer?
macOS 26.3 (Build 25D125), Darwin 25.3.0, arm64
What terminal emulator and version are you using (if applicable)?
Ghostty 1.2.3
What issue are you seeing?
When using streamable HTTP MCP connectors, Codex CLI can degrade after a stale MCP session response.
In this failure mode, the server returns 401 Unauthorized with a body like Unauthorized: Session not found for a stale or invalid mcp-session-id. After that failure, follow-up MCP calls in the same Codex session can keep failing instead of transparently recovering.
Observed impact:
- Initial MCP calls can succeed (for example
list_tools).
- A later call fails on stale session.
- Subsequent calls in the same session fail until restart/reconnect.
What steps can reproduce the bug?
- Start a stateful streamable HTTP MCP server.
- Connect to it from Codex CLI as an MCP connector.
- Make at least one successful MCP call (for example a tools list call).
- Invalidate/expire the MCP session (or force stale session behavior on server side).
- Make another MCP call.
- Observe stale-session failure and lack of automatic recovery for subsequent calls in the same session.
Concrete local repro setup used:
- Test server path in this repo:
codex-rs/rmcp-client/src/bin/test_streamable_http_server.rs
- Force stale session on Nth POST with:
MCP_FORCE_STALE_SESSION_AT_POST_NUMBER=3
What is the expected behavior?
Codex CLI should recover automatically from stale streamable HTTP MCP sessions:
- Detect stale-session failure.
- Reconnect/reinitialize the MCP transport.
- Retry the failed request once.
- Keep the connector usable for subsequent calls.
If retry still fails, Codex should return a clear, status-aware error message (including HTTP status/body context) rather than leaving the connector in a degraded state.
Additional information
- Related upstream SDK issue:
- Related Codex fix branch:
- Related rust-sdk fix branch:
What version of Codex CLI is running?
codex-cli 0.104.0
What subscription do you have?
ChatGPT Pro
Which model were you using?
gpt-5.3-codex
What platform is your computer?
macOS 26.3 (Build 25D125), Darwin 25.3.0, arm64
What terminal emulator and version are you using (if applicable)?
Ghostty 1.2.3
What issue are you seeing?
When using streamable HTTP MCP connectors, Codex CLI can degrade after a stale MCP session response.
In this failure mode, the server returns
401 Unauthorizedwith a body likeUnauthorized: Session not foundfor a stale or invalidmcp-session-id. After that failure, follow-up MCP calls in the same Codex session can keep failing instead of transparently recovering.Observed impact:
list_tools).What steps can reproduce the bug?
Concrete local repro setup used:
codex-rs/rmcp-client/src/bin/test_streamable_http_server.rsMCP_FORCE_STALE_SESSION_AT_POST_NUMBER=3What is the expected behavior?
Codex CLI should recover automatically from stale streamable HTTP MCP sessions:
If retry still fails, Codex should return a clear, status-aware error message (including HTTP status/body context) rather than leaving the connector in a degraded state.
Additional information