Repository navigation
Accept a 2xx acknowledgment of a notification without a body - #599
Closed
dtjldamien wants to merge 1 commit into
Closed
dtjldamien wants to merge 1 commit into
dtjldamien wants to merge 1 commit into
Conversation
The HTTP client raised `unsupported_media_type` when a server acknowledged a notification with 200 and no Content-Type instead of 202, so `connect` failed after a successful `initialize`. A notification awaits no response, and the TypeScript and Python SDKs accept any 2xx for it. Requests and non-2xx responses are unchanged. Fixes modelcontextprotocol#598 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
|
Closing in favor of #600, which uses the same guard and also handles another case this PR does not cover: a 2xx #NNN also adds regression tests covering Thank you for the report, the comparison with the reference SDKs in #598, and the live-server verification that confirmed the fix for the reported issue. |
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.
Motivation and Context
Fixes #598.
MCP::Client::HTTP#connectfailed against servers that acknowledgenotifications/initializedwith200 OKand an empty body instead of202 Accepted.send_requestpasses every response toresolve_response_body, which returns early only for202and otherwise raisesunsupported_media_typewhen the response has neither a JSON nor an SSE content type. Freshservice's hosted MCP server answers this way, soconnectraised right after a successfulinitialize.The spec requires
202here, but a notification awaits no response, and the TypeScript and Python SDKs accept any 2xx for it: neither checks the content type unless the POST carried a request.resolve_response_bodynow returnsnilinstead of raising in that branch when the message is a notification and the response is 2xx. JSON and SSE bodies are handled as before, sotest_send_request_does_not_check_the_body_answering_a_notificationis unaffected. Requests answered with an empty 200 still raiseunsupported_media_type, and 4xx/5xx responses to a notification still raise through the existing Faraday error handling.How Has This Been Tested?
Four new tests in
test/mcp/client/http_test.rb:test_send_request_returns_nil_for_notification_acknowledged_with_empty_200test_connect_accepts_initialized_notification_acknowledged_with_empty_200test_send_request_raises_error_for_request_answered_with_empty_200test_send_request_raises_error_for_notification_answered_with_empty_4xx_or_5xxAgainst the previous library, the first two raise
unsupported_media_type.rake testpasses, and the reproduction script from #598 now connects. Against a live Freshservice MCP server,mainfails withUnsupported Content-Type: nil, and this branch connects and lists all 40 tools, the same as the TypeScript and Python SDKs (see the table in #598).rake conformance:testpasses: 73/73 server checks, and 476 client checks pass with only the failures listed inexpected_failures.yml(auth/dpop,auth/dpop-nonce,auth/wif-jwt-bearer).Breaking Changes
None.
Types of changes
Checklist