Enable JSON responses on Streamable HTTP for Codex CLI compatibility#57
Merged
Conversation
Codex CLI's Rust MCP client (rmcp) cannot parse SSE-formatted responses from the Streamable HTTP transport, causing initialization failures. Setting enableJsonResponse: true on the transport returns application/json instead -- fully MCP spec-compliant and transparent to all other clients. Also adds Known Concerns section to the client docs and bumps to v1.13.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A community user reported that Pathfinder's MCP server doesn't work with OpenAI Codex CLI — initialization fails with connection drops. Confirmed working with Claude Code.
Root cause: Codex CLI uses the
rmcpRust MCP SDK, which has open bugs (#5619, #11284) around parsing SSE-formatted responses from Streamable HTTP endpoints. Pathfinder was returningContent-Type: text/event-streamfor all responses (including simple request/response likeinitializeandtools/list), which rmcp fails to parse — it closes the connection before reading the response data.Fix: The MCP SDK's
StreamableHTTPServerTransporthas anenableJsonResponseoption (default:false). When enabled, the server responds withContent-Type: application/jsoninstead of SSE-wrapping for single-message exchanges. This is one line:Spec compliance: Fully compliant. The MCP spec (2025-06-18) explicitly states: "If the input is a JSON-RPC request, the server MUST either return
Content-Type: text/event-stream, to initiate an SSE stream, orContent-Type: application/json, to return one JSON object. The client MUST support both these cases." The server gets to choose.Tradeoff: Loses the ability to send server-initiated notifications mid-request via SSE. Pathfinder's tools are all request/response — none stream intermediate results. The GET SSE endpoint still works for server-initiated messages.
No impact on Claude Code or any other spec-compliant client, since they're required to handle both formats.
Changes
src/server.ts: AddenableJsonResponse: truetoStreamableHTTPServerTransportconstructordocs/clients/index.html: Add Known Concerns section documenting SSE parsing bugs in some MCP clients, our mitigation, and themcp-remotestdio bridge workaround for any remaining edge casespackage.json,src/cli.ts,package-lock.json,CHANGELOG.md)Test plan
/mcpPOST returnsContent-Type: application/json(previously returnedtext/event-stream){"result":{"protocolVersion":"2025-06-18",...},"jsonrpc":"2.0","id":1}) — not SSE-wrapped (event: message\ndata: {...}\n\n)codex execagainst local Pathfinder — successfully initialized and discovered MCP tools (search_breeze_docs,submit_breeze_feedback)