Repository navigation
feat(unstable-v2): disallow null request IDs - #2499
Merged
Merged
Conversation
Following MCP, v2 request IDs must be a string or an integer, never null. v2 gets its own RequestId, Request and Response types; v1 keeps the shared JSON-RPC types unchanged. Error responses keep JSON-RPC's `id: null` for when the request ID could not be determined, such as a parse error or an invalid request.
RequestId, Request and Response now live in v1/rpc.rs, mirroring v2. crate::rpc re-exports them so existing paths keep working, and keeps only the version-independent Notification, JsonRpcMessage and JsonRpcBatch types. Response gains a default Error = v1::Error parameter so v1::Response<T> and rpc::Response<T, E> both still resolve.
benbrandt
enabled auto-merge (squash)
October 26, 2026 21:47
Merged
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Base JSON-RPC allows
nullrequest IDs but discourages them, becausenullis also the ID of an error response to a request whose ID couldn't be read. MCP disallows them (RequestId = string | number). This does the same for v2.RequestId(string | integer),RequestandResponsetypes inv2/rpc.rs. v1 keeps the shared JSON-RPC types unchanged.RequestId,RequestandResponsemove fromcrate::rpcintov1/rpc.rsto match.crate::rpcre-exports them, so existing paths keep working until the next breaking release of the crate; it otherwise keeps only the version-independentNotification,JsonRpcMessageandJsonRpcBatch.$/cancel_requestand request-scoped elicitations.id: nullfor when the request ID could not be determined (parse errors, invalid requests). The key stays required, so the existing batch and parse-error rules intransports.mdxstill hold. MCP makes the ID optional instead; keepingnullstays compatible with generic JSON-RPC libraries.The overview (main and draft) and the migration guide state the rule.