Table of Contents

Class InputRequest

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.Core.dll

Represents a server-initiated request that the client must fulfill as part of an MRTR (Multi Round-Trip Request) flow.

[JsonConverter(typeof(InputRequest.Converter))]
public sealed class InputRequest
Inheritance
InputRequest
Inherited Members

Remarks

An InputRequest wraps a server-to-client request such as SamplingCreateMessage, ElicitationCreate, or RootsList. It is included in an InputRequiredResult when the server needs additional input before it can complete a client-initiated request.

The Method property identifies the type of request, and the corresponding parameters can be accessed via the typed accessor properties.

Properties

ElicitationParams

Gets the parameters as ElicitRequestParams when Method is ElicitationCreate.

[JsonIgnore]
public ElicitRequestParams? ElicitationParams { get; }

Property Value

ElicitRequestParams

The deserialized elicitation parameters, or null if the method does not match or params are absent.

Method

Gets or sets the method name identifying the type of this input request.

[JsonPropertyName("method")]
public required string Method { get; set; }

Property Value

string

Remarks

Standard values include:

Params

Gets or sets the raw JSON parameters for this input request.

[JsonPropertyName("params")]
public JsonElement? Params { get; set; }

Property Value

JsonElement?

Remarks

Use the typed accessor properties (SamplingParams, ElicitationParams, RootsParams) for convenient strongly-typed access.

RootsParams

Gets the parameters as ListRootsRequestParams when Method is RootsList.

[JsonIgnore]
[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 ListRootsRequestParams? RootsParams { get; }

Property Value

ListRootsRequestParams

The deserialized roots list parameters, or null if the method does not match or params are absent.

SamplingParams

[JsonIgnore]
[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 CreateMessageRequestParams? SamplingParams { get; }

Property Value

CreateMessageRequestParams

The deserialized sampling parameters, or null if the method does not match or params are absent.

Methods

ForElicitation(ElicitRequestParams)

Creates an InputRequest for an elicitation request.

public static InputRequest ForElicitation(ElicitRequestParams requestParams)

Parameters

requestParams ElicitRequestParams

The elicitation request parameters.

Returns

InputRequest

A new InputRequest instance.

ForRootsList(ListRootsRequestParams)

Creates an InputRequest for a roots list request.

[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 InputRequest ForRootsList(ListRootsRequestParams requestParams)

Parameters

requestParams ListRootsRequestParams

The roots list request parameters.

Returns

InputRequest

A new InputRequest instance.

ForSampling(CreateMessageRequestParams)

Creates an InputRequest for a sampling request.

[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 InputRequest ForSampling(CreateMessageRequestParams requestParams)

Parameters

requestParams CreateMessageRequestParams

The sampling request parameters.

Returns

InputRequest

A new InputRequest instance.