-
Notifications
You must be signed in to change notification settings - Fork 2.6k
types: Setting default value for jsonrpc #1310
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
base: main
Are you sure you want to change the base?
types: Setting default value for jsonrpc #1310
Conversation
0302041
to
d626174
Compare
d626174
to
18051bc
Compare
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.
this seems like a move in the right direction but my feeling is - why isn't this just defined at the type that is at the top of the message hierarchy? It's mandatory in every protocol message that goes over the wire. Intuitively, I would expect that to be JSONRPCMessage, I think maybe it's not, but this is the "correct" ontology in my opinion. Whatever type is at the root of all message types (if there is one, which there should be) should have this field set always.
Hi @hesreallyhim But, as the original schema is defined in TypeScript, and types.py depends on it... I am not sure if we can change the base structure in Python SDK. Additionally, we might have to use multiple inheritance as JSONRPCRequest already inherits from Request and JSONRPCNotification from Notification. I hope one of the maintainers can guide us. \cc @ochafik |
yeah... well i think they've kind of fixed this in the draft spec, but the sdk may still choose to do things a little differently. |
We need to migrate to this: https://github.com/Kludex/mcp/blob/main/src/mcp-types/mcp_types/__init__.py |
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 @sreenaths !
@Kludex not sure it would support passing the literal values as defaults? |
sorry, perhaps I should have been more direct - i would need to study the codebase more closely to understand how the sdk consumes the spec schema.ts - in the case of the typescript SDK i think they had decided to declare the internal types as not including
was actually just an oversight in the MCP schema.ts (or so I argued) - the schema hierarchy was not type-theoretically correct. I merged a change into the draft so that all requests inherit from JSONRPCRequest, and notifications extend JSONRPCNotification - see modelcontextprotocol/modelcontextprotocol#1026 for more info if interested. I hope this is relevant, sorry if it's not, just flagging that there is an upcoming change surrounding this part of the schema. |
18051bc
to
becfff2
Compare
Thank you for the review, @ochafik. @hesreallyhim It looks like your changes are one level down the class hierarchy, so I believe our changes are independent. Thanks, @Kludex. Will mcp_types be included in the Python SDK? As @ochafik mentioned, does mcp_types set literal values as defaults? From what I can see, it only defines the types here: mcp_types |
becfff2
to
7e2292a
Compare
Thank you, @felixweinberger |
The JSON-RPC version is fixed at 2.0 for MCP messages. However, as the value is not set by default, we have to pass the correct value every time a model is instantiated.
Motivation and Context
This change simplifies model instantiation by automatically setting the JSON-RPC version. Additionally, if the version ever needs to change in the future, it only has to be updated in a single place.
For example
How Has This Been Tested?
Tests were improved and are working as expected.
Breaking Changes
No
Types of changes
Checklist
Additional context
None