Skip to content

Notification initialized parse error #703

@awgn

Description

@awgn

Describe the bug
rmcp::model::JsonRpcMessage fails to deserialize valid JSON-RPC 2.0 notifications that omit the params field. According to the JSON-RPC 2.0 specification, params is optional, but serde throws a "data did not match any variant of untagged enum JsonRpcMessage" error when parsing messages like the standard MCP notifications/initialized notification.

To Reproduce
Steps to reproduce the behavior:

  1. Receive (e.g. from inspector) or define a valid JSON-RPC 2.0 notification string without the params key: {"method":"notifications/initialized","jsonrpc":"2.0"}
  2. Attempt to deserialize it using serde_json:
    // Attempting to parse the payload
    let payload = b"{\"method\":\"notifications/initialized\",\"jsonrpc\":\"2.0\"}";
    let result: Result<rmcp::model::JsonRpcMessage, _> = serde_json::from_slice(payload);
  3. The result is an Err

Additional context
This bug breaks the standard Model Context Protocol (MCP) connection handshake. When the client sends the notifications/initialized message (which takes no parameters) to signal it's ready, the gateway fails to parse it.

Please verify if this is an actual bug in the crate, if I am misusing the library, or if the issue is actually on the inspector's side (in which case, please ignore this report).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions