-
Notifications
You must be signed in to change notification settings - Fork 469
Description
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:
- Receive (e.g. from inspector) or define a valid JSON-RPC 2.0 notification string without the
paramskey:{"method":"notifications/initialized","jsonrpc":"2.0"} - 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);
- 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).