Skip to content

Outdated rmcp 0.15.0 dependency may contribute to HTTP MCP session failures #15815

Closed as not planned

Description

@joshrotenberg

What version of Codex CLI is running?

0.116.0

What subscription do you have?

Plus

Which model were you using?

gpt-5.4

What platform is your computer?

Darwin 25.4.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

iTerm2

What issue are you seeing?

Codex CLI fails to call tools on Streamable HTTP MCP servers with:

Session not initialized. Only 'initialize' and 'ping' are allowed before initialization. Got: tools/call

The initialize and tools/list phases succeed, but subsequent tools/call requests arrive at the
server without a valid mcp-session-id header, hitting an uninitialized session.

This was reported against a tower-mcp HTTP server (joshrotenberg/cratesio-mcp#61, filed 2026-03-04).
Both Codex CLI and Cursor failed identically.

Codex's codex-rmcp-client depends on rmcp = "0.15.0" (codex-rs/Cargo.toml:273). rmcp appears to
have shipped several session-related fixes between 0.15 and 1.2:

  • 1fe5d1e (2026-03-03) - fix(streamable-http): map stale session 401 to status-aware error
  • 27b0096 (2026-03-11) - feat: transparent session re-init on HTTP 404
  • 3ea8c3c - feat: add configuration for transparent session re-init

What steps can reproduce the bug?

  1. Run a Streamable HTTP MCP server that enforces session IDs (e.g. any tower-mcp HTTP server without
    optional_sessions()).
  2. Configure Codex CLI to use it:
    [mcp_servers.myserver]
    url = "http://localhost:3000/"
  3. Ask Codex to call a tool from that server.
  4. initialize and tools/list succeed during setup, but tools/call fails with the session error above.

We verified this with rmcp 1.2 (current HEAD) against the same tower-mcp server with strict session
enforcement. All operations succeed -- the session ID is correctly forwarded on every request. An rmcp
0.15-era client may not correctly forward mcp-session-id on requests after initialization, based on the
error pattern and the fixes present in 1.x.

What is the expected behavior?

tools/call requests should include the mcp-session-id header obtained during initialization,
maintaining session continuity with the server as required by the MCP 2025-11-25 spec.

Additional information

Server-side workaround: tower-mcp 0.9.2+ provides HttpTransport::optional_sessions() which creates a
transient pre-initialized session for requests arriving without mcp-session-id. In our local testing,
enabling this made Codex-compatible HTTP tool calls succeed. tower-mcp's own HTTP client correctly
stores and forwards mcp-session-id, so the observed failure does not appear to be server-side.

Possibly related open issues (similar pattern -- HTTP MCP init succeeds but subsequent operations
fail):

Upgrade scope: The codex-rmcp-client integration surface is broad (custom StreamableHttpClient impl,
ClientHandler, OAuth state management), so upgrading to rmcp 1.x appears to be a real migration rather
than a version bump.

Activity

  1. added
    bug
    on Mar 26, 2026
  2. added
    CLI
    mcp
    tool-calls
    on Mar 26, 2026
  3. removed
    CLI
    tool-calls
    on Mar 26, 2026
  4. joshrotenberg commented on Mar 26, 2026

    @joshrotenberg
    Author

    Update: After further investigation, we were unable to reproduce this with Codex CLI 0.116.0
    against a tower-mcp server using strict session enforcement (require_sessions()). The session ID is
    forwarded correctly on all requests.

    The original report
    (joshrotenberg/cratesio-mcp#61) was against
    a server deployed on Fly.dev, which load-balances across instances. The error message (Session not initialized. Only 'initialize' and 'ping' are allowed before initialization. Got: tools/call) is
    consistent with a server-side session affinity problem rather than a client-side header issue: the
    client initializes on instance A, then Fly routes tools/call to instance B where that session doesn't
    exist. The request has a valid mcp-session-id header (passes the transport check) but hits an
    uninitialized router on the wrong instance.

    This would explain why HttpTransport::optional_sessions() resolved it -- each request gets a fresh
    pre-initialized session regardless of which instance handles it -- and why we can't reproduce locally
    against a single-instance server.

    That said, upgrading rmcp from 0.15 to 1.x is still worth doing independently. The session-related
    fixes in 1.x (transparent re-init on 404, stale session 401 mapping) would make Codex more resilient to
    exactly this kind of multi-instance session loss, rather than failing outright.

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

    bugmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions