-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
SDK Parity: Avoid Parsing Server Response for non-JsonRPCMessage Requests #1290
Conversation
There was a problem hiding this 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!
There was a problem hiding this 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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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
Checklist
Additional context