fix: accept HTTP 204 No Content in SendNotification#717
Conversation
WalkthroughSendNotification in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
HTTP 204 is a valid success status code per RFC 7231, commonly returned by servers for notification endpoints where no response body is expected. The client previously only accepted 200 and 202, causing initialization to fail when connecting to servers that return 204 for the initialized notification. Refactored the status code handling to a switch statement for clarity. Fixes mark3labs#700 Co-authored-by: Cursor <cursoragent@cursor.com>
21eb01a to
d77ab00
Compare
Description
Fixes #700
SendNotificationinstreamable_http.gocurrently treats HTTP 204 (No Content) as an error, returning"notification failed with status 204". However, HTTP 204 is a valid success status code per RFC 7231 that indicates the server successfully processed the request but has no content to return. This is semantically appropriate for notification endpoints, as notifications are one-way messages that don't expect a response body.Many HTTP servers return 204 for successful notification/webhook deliveries. The official TypeScript MCP SDK (
@modelcontextprotocol/sdk) already handles this correctly by usingresponse.ok(which accepts any 2xx status).Changes
http.StatusNoContent(204) to the accepted status codes inSendNotificationTestStreamableHTTP_SendNotification_Accepts204NoContenttestTest plan
TestStreamableHTTP_SendNotification_Accepts204NoContentverifies 204 is acceptedSendNotificationtests continue to pass (202, 401 handling)go test ./...)Made with Cursor
Summary by CodeRabbit
Bug Fixes
Tests