Class JsonRpcMessage
- Namespace
- ModelContextProtocol.Protocol.Messages
- Assembly
- ModelContextProtocol.dll
Represents any JSON-RPC message used in the Model Context Protocol (MCP).
[JsonConverter(typeof(JsonRpcMessageConverter))]
public abstract class JsonRpcMessage
- Inheritance
-
JsonRpcMessage
- Derived
- Inherited Members
Remarks
This interface serves as the foundation for all message types in the JSON-RPC 2.0 protocol used by MCP, including requests, responses, notifications, and errors. JSON-RPC is a stateless, lightweight remote procedure call (RPC) protocol that uses JSON as its data format.
Properties
JsonRpc
Gets the JSON-RPC protocol version used.
[JsonPropertyName("jsonrpc")]
public string JsonRpc { get; init; }
Property Value
RelatedTransport
Gets or sets the transport the JsonRpcMessage was received on or should be sent over.
[JsonIgnore]
public ITransport? RelatedTransport { get; set; }
Property Value
Remarks
This is used to support the Streamable HTTP transport where the specification states that the server SHOULD include JSON-RPC responses in the HTTP response body for the POST request containing the corresponding JSON-RPC request. It may be null for other transports.