Enforce String or Integer non-null ID for MCP JSON-RPC Messages with a new McpSchema subclass #401
+181
−57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I considered
JSONRPCMessageID
, but didn't want theJSONRPC
prefix as it might imply nullability or possibly a float, as is standard for a JSON-RPCid
.I also considered
id
but figured it was too ambiguous.I can see an argument for
McpMessageId
, but I figured it being in theMcpSchema
namespace was good enough for someone to identify theMessageId
type as specific to MCP.Motivation and Context
The specification conditions for JSON-RPC Message
id
values include the requirements of the value being a (non-null) String or Integer.How Has This Been Tested?
Multiple existing tests use this field, have been updated accordingly, and confirmed to work correctly after the changes.
Breaking Changes
N/A
Types of changes
Checklist
Additional context
Edit: After sleeping on it, I realized this IS a breaking change, because people are possibly building requests in tool handlers without the requirements this would enforce.