Table of Contents

Class RequestOptions

Namespace
ModelContextProtocol
Assembly
ModelContextProtocol.Core.dll

Provides a bag of optional parameters for use with MCP requests.

public sealed class RequestOptions
Inheritance
RequestOptions
Inherited Members

Constructors

RequestOptions()

Initializes a new instance of the RequestOptions class.

public RequestOptions()

Properties

JsonSerializerOptions

Gets or sets a JsonSerializer to use for any serialization of arguments or results in the request.

public JsonSerializerOptions? JsonSerializerOptions { get; set; }

Property Value

JsonSerializerOptions

Remarks

If null, DefaultOptions is used.

Meta

Gets or sets optional metadata to include as the "_meta" property in a request.

public JsonObject? Meta { get; set; }

Property Value

JsonObject

Remarks

Although progress tokens are propagated in MCP "_meta" objects, the ProgressToken property and the Meta property do not interact (setting Meta does not affect ProgressToken, and the object returned from Meta is not impacting by the value of ProgressToken). To get the actual JsonObject that contains state from both Meta and ProgressToken, use the GetMetaForRequest() method.

ProgressToken

Gets or sets an optional progress token to use for tracking long-running operations.

public ProgressToken? ProgressToken { get; set; }

Property Value

ProgressToken?

Remarks

Although progress tokens are propagated in MCP "_meta" objects, the ProgressToken property and the Meta property do not interact (setting ProgressToken does not affect Meta, and getting ProgressToken does not read from Meta. To get the actual JsonObject that contains state from both Meta and ProgressToken, use the GetMetaForRequest() method.

Methods

GetMetaForRequest()

Gets a JsonObject to use in requests for the "_meta" property.

public JsonObject? GetMetaForRequest()

Returns

JsonObject

A JsonObject suitable for use in requests for the "_meta" property.

Remarks

Progress tokens are part of MCP's _meta property. As such, if ProgressToken is non-null but Meta is null, GetMetaForRequest() will manufacture and return a new JsonObject instance containing the token. If both ProgressToken and Meta are non-null, a new clone of Meta will be created and its "progressToken" property overwritten with ProgressToken. Otherwise, GetMetaForRequest() will just return Meta.