You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A request whose id is not an i64 or a string is parsed as a notification #1345
Describe the bug JsonRpcMessage is #[serde(untagged)]. When id is present but does not deserialize as NumberOrString (i64 or string), the Request variant fails and the message falls through to Notification, which ignores the extra id field. The server then never answers, so the client waits until its own timeout instead of getting -32600 Invalid Request.
To Reproduce (main at 808124b)
let raw = r#"{"jsonrpc":"2.0","id":1.0,"method":"tools/list"}"#;let msg: rmcp::model::ClientJsonRpcMessage = serde_json::from_str(raw).unwrap();assert!(matches!(msg, rmcp::model::ClientJsonRpcMessage::Request(_)));// fails: Notification
Same result for 9223372036854775808 (i64::MAX + 1), 1e2, 1.5, true and null. 9223372036854775807 parses as a request.
Expected behavior
A message that carries id and method is a request. If the id is not one the SDK supports, reject it with -32600 rather than treating it as a notification. 1.0 and 1e2 are integral JSON numbers and could reasonably be accepted as 1 and 100.
Additional context
Found by running the same request ids through several SDKs. The Go SDK has a related report in modelcontextprotocol/go-sdk#1376. I checked message parsing only, not a live server.
I'd like to send a fix: decide request vs notification by the presence of id, and report an invalid id as an error.
AI disclosure: found and drafted with Claude Code; I reviewed it and ran the cases above.
Activity