Skip to content

MCP server HTTP transport issues with Codex #134

Description

@pclifford

I had some trouble using the MCP server's HTTP transport with Codex so I switched to the stdio transport and forgot about it, but I recently went back to see what was happening.

Firstly, one minor issue:

std::string method_not_allowed =
"HTTP/1.1 405 Method Not Allowed\r\n"
"Content-Type: application/json\r\n"
"Content-Length: 56\r\n" +
get_cors_origin_header() +
"Connection: close\r\n"
"\r\n"
"{\"error\":\"SSE streaming not supported by this server\"}";

This sends Content-Length: 56 but only 54 bytes of body content, so if you curl the endpoint you get a warning:

$ curl 127.0.0.1:7777/mcp
curl: (18) transfer closed with 2 bytes remaining to read
{"error":"SSE streaming not supported by this server"}

The other issue is the one that was confusing Codex. This part responds to notifications/initialized:

else if (method == "notifications/initialized")
{
// Notifications don't need JSON-RPC response, but HTTP needs HTTP response
if (dynamic_cast<HttpTransport*>(m_transport))
{
m_transport->send("{}");
}
}

https://www.jsonrpc.org/specification#notification (section 4.1) says

A Notification is a Request object without an "id" member. [...] The Server MUST NOT reply to a Notification, including those that are within a batch request.

And https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#sending-messages-to-the-server says

If the server accepts the input, the server MUST return HTTP status code 202 Accepted with no body.

It seems that Codex doesn't like getting a 200 response with body content, and marks the MCP server as unavailable. Changing to a 202 response with no body fixes this.

Activity

  1. locked and limited conversation to collaborators on Jul 20, 2026
  2. unlocked this conversation on Jul 20, 2026
  3. drhelius commented on Jul 20, 2026

    @drhelius
    Owner

    Thanks for reporting!

  4. drhelius commented on Jul 20, 2026

    @drhelius
    Owner

    Fixed

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions