Skip to content

A request whose id is not an i64 or a string is parsed as a notification #1345

Open

Description

@talhayme

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

  1. added
    bugSomething is not working
    P1High: significant functionality gap or spec violation
    T-modelModel/data structure changes
    T-coreCore library changes
    ready for workIssue is well-defined and ready to be picked up
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High: significant functionality gap or spec violationT-coreCore library changesT-modelModel/data structure changesbugSomething is not workingready for workIssue is well-defined and ready to be picked up

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions