Class InputResponse
- Namespace
- ModelContextProtocol.Protocol
- Assembly
- ModelContextProtocol.Core.dll
Represents a client's response to a server-initiated InputRequest as part of an MRTR (Multi Round-Trip Request) flow.
[JsonConverter(typeof(InputResponse.Converter))]
public sealed class InputResponse
- Inheritance
-
InputResponse
- Inherited Members
Remarks
An InputResponse wraps the result of a server-to-client request such as CreateMessageResult, ElicitResult, or ListRootsResult. The type of the inner response corresponds to the Method of the associated input request.
The input response does not carry its own type discriminator in JSON. The type is determined by the corresponding Method key in the InputRequests map.
Properties
CreateMessageResultJsonTypeInfo
Gets the JsonTypeInfo<T> for CreateMessageResult, suitable for use with Deserialize<T>(JsonTypeInfo<T>) when the corresponding Method is SamplingCreateMessage.
[Obsolete("The Sampling feature is deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information.", DiagnosticId = "MCP9005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis")]
public static JsonTypeInfo<CreateMessageResult> CreateMessageResultJsonTypeInfo { get; }
Property Value
ElicitResultJsonTypeInfo
Gets the JsonTypeInfo<T> for ElicitResult, suitable for use with Deserialize<T>(JsonTypeInfo<T>) when the corresponding Method is ElicitationCreate.
public static JsonTypeInfo<ElicitResult> ElicitResultJsonTypeInfo { get; }
Property Value
ListRootsResultJsonTypeInfo
Gets the JsonTypeInfo<T> for ListRootsResult, suitable for use with Deserialize<T>(JsonTypeInfo<T>) when the corresponding Method is RootsList.
[Obsolete("The Roots feature is deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information.", DiagnosticId = "MCP9005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis")]
public static JsonTypeInfo<ListRootsResult> ListRootsResultJsonTypeInfo { get; }
Property Value
RawValue
Gets or sets the raw JSON element representing the response.
[JsonIgnore]
public JsonElement RawValue { get; set; }
Property Value
Remarks
Use Deserialize<T>(JsonTypeInfo<T>) with the JsonTypeInfo<T> matching the
associated Method - for elicitation, sampling, or roots see
ElicitResultJsonTypeInfo, CreateMessageResultJsonTypeInfo, and
ListRootsResultJsonTypeInfo.
Methods
Deserialize<T>(JsonTypeInfo<T>)
Deserializes the raw value to the specified result type.
public T? Deserialize<T>(JsonTypeInfo<T> typeInfo)
Parameters
typeInfoJsonTypeInfo<T>The JSON type information for
T.
Returns
- T
The deserialized result, or null if deserialization fails.
Type Parameters
TThe type to deserialize to (e.g., CreateMessageResult, ElicitResult).
FromElicitResult(ElicitResult)
Creates an InputResponse from an ElicitResult.
public static InputResponse FromElicitResult(ElicitResult result)
Parameters
resultElicitResultThe elicitation result.
Returns
- InputResponse
A new InputResponse instance.
FromRootsResult(ListRootsResult)
Creates an InputResponse from a ListRootsResult.
[Obsolete("The Roots feature is deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information.", DiagnosticId = "MCP9005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis")]
public static InputResponse FromRootsResult(ListRootsResult result)
Parameters
resultListRootsResultThe roots list result.
Returns
- InputResponse
A new InputResponse instance.
FromSamplingResult(CreateMessageResult)
Creates an InputResponse from a CreateMessageResult.
[Obsolete("The Sampling feature is deprecated as of specification version 2026-07-28 and may be removed in a future version. See SEP-2577 for more information.", DiagnosticId = "MCP9005", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis")]
public static InputResponse FromSamplingResult(CreateMessageResult result)
Parameters
resultCreateMessageResultThe sampling result.
Returns
- InputResponse
A new InputResponse instance.