Skip to content

SDK Parity: Avoid Parsing Server Response for non-JsonRPCMessage Requests #1290

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 11 commits into
base: main
Choose a base branch
from

Conversation

justin-yi-wang
Copy link

@justin-yi-wang justin-yi-wang commented Aug 21, 2025

Achieve parity with the TypeScript SDK by only parsing server responses to JsonRPCRequests.

Motivation and Context

In the TypeScript SDK, server responses are only parsed if the request is a JsonRPCRequest (ie. has "method" and "id" fields) - link. Otherwise, the response is ignored. Here in the Python SDK, all responses are parsed. Concretely, we've seen in the wild that servers may try to respond to notifications with a 204 No content rather than a 202 Accepted (which is special cased in both SDKs), resulting in a Pydantic validation error. Subsequently, server developers are confused why their servers work with clients presumably using the TypeScript SDK, but not ones using the Python SDK.

How Has This Been Tested?

This PR includes a test.

Breaking Changes

No. Per the MCP protocol, the server should not respond to notifications.

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

@justin-yi-wang justin-yi-wang requested a review from a team as a code owner August 21, 2025 01:38
@justin-yi-wang justin-yi-wang requested a review from ochafik August 21, 2025 01:38
@justin-yi-wang justin-yi-wang marked this pull request as draft August 21, 2025 01:40
@justin-yi-wang justin-yi-wang marked this pull request as ready for review August 21, 2025 01:51
Copy link

@ochafik ochafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @justin-yi-wang!

@justin-yi-wang justin-yi-wang requested a review from ochafik August 21, 2025 17:38
Copy link

@ochafik ochafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again, two last nits!

@justin-yi-wang justin-yi-wang requested a review from ochafik August 22, 2025 16:10
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