pub struct JsonRpcNotification {
pub jsonrpc: String,
pub method: String,
pub params: Value,
}Expand description
JSON-RPC 2.0 notification envelope — server → client, no id field.
Used for MCP notifications/progress per the 2024-11-05 spec:
https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/utilities/progress/.
A notification MUST NOT carry an id; that’s the serialization rule the
peer uses to route it as a fire-and-forget message.
Fields§
§jsonrpc: String§method: String§params: ValueImplementations§
Source§impl JsonRpcNotification
impl JsonRpcNotification
Sourcepub fn progress(progress_token: Value, message: Value) -> Self
pub fn progress(progress_token: Value, message: Value) -> Self
Construct a notifications/progress payload with the spec-mandated
progressToken echoed back from the originating request’s
params._meta.progressToken.
message is the opaque JSON payload emitted by the subprocess on one
line of stdout. The MCP spec’s optional progress/total numeric
fields are left absent for now — we forward the parsed JSON verbatim
so higher-level clients can introspect whatever shape the CLI emits.
Sourcepub fn to_json_line(&self) -> Result<String, Error>
pub fn to_json_line(&self) -> Result<String, Error>
Serialize this notification as a single JSON line (no trailing
newline). Suitable for writing to stdio with writeln!.
§Errors
Returns a serde_json::Error if the payload cannot be serialized,
which in practice only happens for non-finite floats that a well-formed
subprocess would not produce.
Trait Implementations§
Source§impl Clone for JsonRpcNotification
impl Clone for JsonRpcNotification
Source§fn clone(&self) -> JsonRpcNotification
fn clone(&self) -> JsonRpcNotification
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more