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:
parent
5b04089e06
commit
a02a4572c4
1 changed files with 42 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue