Table of Contents

Class JsonRpcMessage

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.Core.dll

Represents any JSON-RPC message used in the Model Context Protocol (MCP).

[JsonConverter(typeof(JsonRpcMessage.Converter))]
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

Context

Gets or sets the contextual information for this JSON-RPC message.

[JsonIgnore]
public JsonRpcMessageContext? Context { get; set; }

Property Value

JsonRpcMessageContext

Remarks

This property contains transport-specific and runtime context information that accompanies JSON-RPC messages but is not serialized as part of the JSON-RPC payload. This includes transport references, execution context, and authenticated user information.

This property should only be set when implementing a custom ITransport that needs to pass additional per-message context or to pass a User to HandlePostRequestAsync(JsonRpcMessage, Stream, CancellationToken) or OnMessageReceivedAsync(JsonRpcMessage, CancellationToken) .

JsonRpc

Gets or sets the JSON-RPC protocol version used.

[JsonPropertyName("jsonrpc")]
public string JsonRpc { get; set; }

Property Value

string