Skip to content

Return HTTP status code 202 for notification initialized method #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

siddhantbajaj
Copy link

@siddhantbajaj siddhantbajaj commented Aug 8, 2025

Brief summary: Return 202 Accepted (no body) for POSTed JSON-RPC notifications over Streamable HTTP, specifically notifications/initialized, to align with the MCP spec. Added a focused handler and unit test.

Motivation and Context

  • The MCP Streamable HTTP spec requires servers to return 202 Accepted with no body for JSON-RPC notifications/responses. Previously, notifications/initialized returned 200.
  • This change brings behavior into compliance and prevents client-side mismatches.
  • Spec reference: Model Context Protocol Transports – Backwards Compatibility.
Screenshot 2025-08-08 at 3 21 13 AM

How Has This Been Tested?

  • Added a unit test in test/mcp/server/transports/streamable_http_transport_test.rb:
  • Verifies POST to notifications/initialized returns HTTP 202 with empty headers and empty body.
  • Existing transport tests cover non-notification flows.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@koic
Copy link
Member

koic commented Aug 11, 2025

@siddhantbajaj Thanks! Can you squash commits into one?

@siddhantbajaj siddhantbajaj force-pushed the handle-notification-initialized-method branch from 2381508 to 4a65f62 Compare August 11, 2025 14:40
@siddhantbajaj siddhantbajaj requested a review from koic August 11, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants