Return 202 Accepted for SSE responses per MCP spec

`StreamableHTTPTransport#send_response_to_stream` returned 200 with
`{ accepted: true }` body, but the MCP spec requires 202 with empty body
when a response is sent via SSE stream. This has been a requirement since
Streamable HTTP was introduced in protocol version 2025-03-26.

- https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#sending-messages-to-the-server
- https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#sending-messages-to-the-server
This commit is contained in:
Koichi ITO 2026-02-28 01:14:22 +09:00
commit a02a4572c4

View file

@ -288,7 +288,7 @@ module MCP
def send_response_to_stream(stream, response, session_id)
message = JSON.parse(response)
send_to_stream(stream, message)
[200, { "Content-Type" => "application/json" }, [{ accepted: true }.to_json]]
handle_accepted
rescue IOError, Errno::EPIPE => e
MCP.configuration.exception_reporter.call(
e,