Handle 202 Accepted response in HTTP client
Per the Streamable HTTP spec, a server returns 202 Accepted with no body as the ACK for a JSON-RPC notification or response. The client previously errored on 202 because it fell through Content-Type dispatch. Short-circuit to return nil before Content-Type handling so fire-and-forget messages (e.g. notifications/initialized) no longer raise. https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#sending-messages-to-the-server Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
5c0fee309f
commit
cfc42dbfe7
1 changed files with 20 additions and 1 deletions
|
|
@ -100,6 +100,10 @@ module MCP
|
|||
end
|
||||
|
||||
def parse_response_body(response, method, params)
|
||||
# 202 Accepted is the server's ACK for a JSON-RPC notification or response; no body is expected.
|
||||
# https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#sending-messages-to-the-server
|
||||
return if response.status == 202
|
||||
|
||||
content_type = response.headers["Content-Type"]
|
||||
|
||||
if content_type&.include?("text/event-stream")
|
||||
|
|
|
|||
Loading…
Reference in a new issue