Table of Contents

Class McpClient

Namespace
ModelContextProtocol.Client
Assembly
ModelContextProtocol.Core.dll

Represents an instance of a Model Context Protocol (MCP) client session that connects to and communicates with an MCP server.

public abstract class McpClient : McpSession, IAsyncDisposable
Inheritance
McpClient
Implements
Inherited Members

Properties

ServerCapabilities

Gets the capabilities supported by the connected server.

public abstract ServerCapabilities ServerCapabilities { get; }

Property Value

ServerCapabilities

Exceptions

InvalidOperationException

The client is not connected.

ServerInfo

Gets the implementation information of the connected server.

public abstract Implementation ServerInfo { get; }

Property Value

Implementation

Remarks

This property provides identification details about the connected server, including its name and version. It is populated during the initialization handshake and is available after a successful connection.

This information can be useful for logging, debugging, compatibility checks, and displaying server information to users.

Exceptions

InvalidOperationException

The client is not connected.

ServerInstructions

Gets any instructions describing how to use the connected server and its features.

public abstract string? ServerInstructions { get; }

Property Value

string

Remarks

This property contains instructions provided by the server during initialization that explain how to effectively use its capabilities. These instructions can include details about available tools, expected input formats, limitations, or any other helpful information.

This can be used by clients to improve an LLM's understanding of available tools, prompts, and resources. It can be thought of like a "hint" to the model and can be added to a system prompt.

Methods

CallToolAsync(CallToolRequestParams, CancellationToken)

Invokes a tool on the server.

public ValueTask<CallToolResult> CallToolAsync(CallToolRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams CallToolRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<CallToolResult>

The result of the request.

Exceptions

ArgumentNullException

requestParams is null.

CallToolAsync(string, IReadOnlyDictionary<string, object?>?, IProgress<ProgressNotificationValue>?, RequestOptions?, CancellationToken)

Invokes a tool on the server.

public ValueTask<CallToolResult> CallToolAsync(string toolName, IReadOnlyDictionary<string, object?>? arguments = null, IProgress<ProgressNotificationValue>? progress = null, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

toolName string

The name of the tool to call on the server.

arguments IReadOnlyDictionary<string, object>

An optional dictionary of arguments to pass to the tool.

progress IProgress<ProgressNotificationValue>

An optional progress reporter for server notifications.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<CallToolResult>

The CallToolResult from the tool execution.

Exceptions

ArgumentNullException

toolName is null.

CompleteAsync(CompleteRequestParams, CancellationToken)

Requests completion suggestions for a prompt argument or resource reference.

public ValueTask<CompleteResult> CompleteAsync(CompleteRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams CompleteRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<CompleteResult>

The result of the request.

Exceptions

ArgumentNullException

requestParams is null.

CompleteAsync(Reference, string, string, RequestOptions?, CancellationToken)

Requests completion suggestions for a prompt argument or resource reference.

public ValueTask<CompleteResult> CompleteAsync(Reference reference, string argumentName, string argumentValue, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

reference Reference

The reference object specifying the type and optional URI or name.

argumentName string

The name of the argument for which completions are requested.

argumentValue string

The current value of the argument, used to filter relevant completions.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<CompleteResult>

A CompleteResult containing completion suggestions.

Exceptions

ArgumentNullException

reference or argumentName is null.

ArgumentException

argumentName is empty or composed entirely of whitespace.

CreateAsync(IClientTransport, McpClientOptions?, ILoggerFactory?, CancellationToken)

Creates an McpClient, connecting it to the specified server.

public static Task<McpClient> CreateAsync(IClientTransport clientTransport, McpClientOptions? clientOptions = null, ILoggerFactory? loggerFactory = null, CancellationToken cancellationToken = default)

Parameters

clientTransport IClientTransport

The transport instance used to communicate with the server.

clientOptions McpClientOptions

A client configuration object that specifies client capabilities and protocol version. If null, details based on the current process are used.

loggerFactory ILoggerFactory

A logger factory for creating loggers for clients.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task<McpClient>

An McpClient that's connected to the specified server.

Exceptions

ArgumentNullException

clientTransport is null.

GetPromptAsync(GetPromptRequestParams, CancellationToken)

Retrieves a list of available prompts from the server.

public ValueTask<GetPromptResult> GetPromptAsync(GetPromptRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams GetPromptRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<GetPromptResult>

The result of the request as provided by the server.

Exceptions

ArgumentNullException

requestParams is null.

GetPromptAsync(string, IReadOnlyDictionary<string, object?>?, RequestOptions?, CancellationToken)

Retrieves a specific prompt from the MCP server.

public ValueTask<GetPromptResult> GetPromptAsync(string name, IReadOnlyDictionary<string, object?>? arguments = null, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

name string

The name of the prompt to retrieve.

arguments IReadOnlyDictionary<string, object>

Optional arguments for the prompt. The dictionary keys are parameter names, and the values are the argument values.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<GetPromptResult>

A task containing the prompt's result with content and messages.

Exceptions

ArgumentNullException

name is null.

ArgumentException

name is empty or composed entirely of whitespace.

ListPromptsAsync(ListPromptsRequestParams, CancellationToken)

Retrieves a list of available prompts from the server.

public ValueTask<ListPromptsResult> ListPromptsAsync(ListPromptsRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams ListPromptsRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ListPromptsResult>

The result of the request as provided by the server.

Remarks

The ListPromptsAsync(RequestOptions?, CancellationToken) overload retrieves all prompts by automatically handling pagination. This overload works with the lower-level ListPromptsRequestParams and ListPromptsResult, returning the raw result from the server. Any pagination needs to be managed by the caller.

Exceptions

ArgumentNullException

requestParams is null.

ListPromptsAsync(RequestOptions?, CancellationToken)

Retrieves a list of available prompts from the server.

public ValueTask<IList<McpClientPrompt>> ListPromptsAsync(RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<IList<McpClientPrompt>>

A list of all available prompts as McpClientPrompt instances.

ListResourceTemplatesAsync(ListResourceTemplatesRequestParams, CancellationToken)

Retrieves a list of available resource templates from the server.

public ValueTask<ListResourceTemplatesResult> ListResourceTemplatesAsync(ListResourceTemplatesRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams ListResourceTemplatesRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ListResourceTemplatesResult>

The result of the request as provided by the server.

Remarks

The ListResourceTemplatesAsync(RequestOptions?, CancellationToken) overload retrieves all resource templates by automatically handling pagination. This overload works with the lower-level ListResourceTemplatesRequestParams and ListResourceTemplatesResult, returning the raw result from the server. Any pagination needs to be managed by the caller.

Exceptions

ArgumentNullException

requestParams is null.

ListResourceTemplatesAsync(RequestOptions?, CancellationToken)

Retrieves a list of available resource templates from the server.

public ValueTask<IList<McpClientResourceTemplate>> ListResourceTemplatesAsync(RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<IList<McpClientResourceTemplate>>

A list of all available resource templates as ResourceTemplate instances.

ListResourcesAsync(ListResourcesRequestParams, CancellationToken)

Retrieves a list of available resources from the server.

public ValueTask<ListResourcesResult> ListResourcesAsync(ListResourcesRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams ListResourcesRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ListResourcesResult>

The result of the request as provided by the server.

Remarks

The ListResourcesAsync(RequestOptions?, CancellationToken) overload retrieves all resources by automatically handling pagination. This overload works with the lower-level ListResourcesRequestParams and ListResourcesResult, returning the raw result from the server. Any pagination needs to be managed by the caller.

Exceptions

ArgumentNullException

requestParams is null.

ListResourcesAsync(RequestOptions?, CancellationToken)

Retrieves a list of available resources from the server.

public ValueTask<IList<McpClientResource>> ListResourcesAsync(RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<IList<McpClientResource>>

A list of all available resources as Resource instances.

ListToolsAsync(ListToolsRequestParams, CancellationToken)

Retrieves a list of available tools from the server.

public ValueTask<ListToolsResult> ListToolsAsync(ListToolsRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams ListToolsRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ListToolsResult>

The result of the request as provided by the server.

Remarks

The ListToolsAsync(RequestOptions?, CancellationToken) overload retrieves all tools by automatically handling pagination. This overload works with the lower-level ListToolsRequestParams and ListToolsResult, returning the raw result from the server. Any pagination needs to be managed by the caller.

Exceptions

ArgumentNullException

requestParams is null.

ListToolsAsync(RequestOptions?, CancellationToken)

Retrieves a list of available tools from the server.

public ValueTask<IList<McpClientTool>> ListToolsAsync(RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<IList<McpClientTool>>

A list of all available tools as McpClientTool instances.

PingAsync(PingRequestParams, CancellationToken)

Sends a ping request to verify server connectivity.

public ValueTask<PingResult> PingAsync(PingRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams PingRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<PingResult>

A task containing the ping result.

Exceptions

ArgumentNullException

requestParams is null.

McpException

The server cannot be reached or returned an error response.

PingAsync(RequestOptions?, CancellationToken)

Sends a ping request to verify server connectivity.

public ValueTask<PingResult> PingAsync(RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<PingResult>

A task containing the ping result.

Exceptions

McpException

The server cannot be reached or returned an error response.

ReadResourceAsync(ReadResourceRequestParams, CancellationToken)

Reads a resource from the server.

public ValueTask<ReadResourceResult> ReadResourceAsync(ReadResourceRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams ReadResourceRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ReadResourceResult>

The result of the request.

Exceptions

ArgumentNullException

requestParams is null.

ReadResourceAsync(string, RequestOptions?, CancellationToken)

Reads a resource from the server.

public ValueTask<ReadResourceResult> ReadResourceAsync(string uri, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri string

The URI of the resource.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ReadResourceResult>

Exceptions

ArgumentNullException

uri is null.

ArgumentException

uri is empty or composed entirely of whitespace.

ReadResourceAsync(string, IReadOnlyDictionary<string, object?>, RequestOptions?, CancellationToken)

Reads a resource from the server.

public ValueTask<ReadResourceResult> ReadResourceAsync(string uriTemplate, IReadOnlyDictionary<string, object?> arguments, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uriTemplate string

The URI template of the resource.

arguments IReadOnlyDictionary<string, object>

Arguments to use to format uriTemplate.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ReadResourceResult>

Exceptions

ArgumentNullException

uriTemplate or arguments is null.

ArgumentException

uriTemplate is empty or composed entirely of whitespace.

ReadResourceAsync(Uri, RequestOptions?, CancellationToken)

Reads a resource from the server.

public ValueTask<ReadResourceResult> ReadResourceAsync(Uri uri, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri Uri

The URI of the resource.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<ReadResourceResult>

Exceptions

ArgumentNullException

uri is null.

ResumeSessionAsync(IClientTransport, ResumeClientSessionOptions, McpClientOptions?, ILoggerFactory?, CancellationToken)

Recreates an McpClient using an existing transport session without sending a new initialize request.

public static Task<McpClient> ResumeSessionAsync(IClientTransport clientTransport, ResumeClientSessionOptions resumeOptions, McpClientOptions? clientOptions = null, ILoggerFactory? loggerFactory = null, CancellationToken cancellationToken = default)

Parameters

clientTransport IClientTransport

The transport instance already configured to connect to the target server.

resumeOptions ResumeClientSessionOptions

The metadata captured from the original session that should be applied when resuming.

clientOptions McpClientOptions

Optional client settings that should mirror those used to create the original session.

loggerFactory ILoggerFactory

An optional logger factory for diagnostics.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task<McpClient>

An McpClient bound to the resumed session.

Exceptions

ArgumentNullException

clientTransport, resumeOptions, ServerCapabilities, or ServerInfo is null.

SetLoggingLevelAsync(LogLevel, RequestOptions?, CancellationToken)

Sets the logging level for the server to control which log messages are sent to the client.

public Task SetLoggingLevelAsync(LogLevel level, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

level LogLevel

The minimum severity level of log messages to receive from the server.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

A task representing the asynchronous operation.

SetLoggingLevelAsync(LoggingLevel, RequestOptions?, CancellationToken)

Sets the logging level for the server to control which log messages are sent to the client.

public Task SetLoggingLevelAsync(LoggingLevel level, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

level LoggingLevel

The minimum severity level of log messages to receive from the server.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

A task representing the asynchronous operation.

SetLoggingLevelAsync(SetLevelRequestParams, CancellationToken)

Sets the logging level for the server to control which log messages are sent to the client.

public Task SetLoggingLevelAsync(SetLevelRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams SetLevelRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

The result of the request.

Exceptions

ArgumentNullException

requestParams is null.

SubscribeToResourceAsync(SubscribeRequestParams, CancellationToken)

Subscribes to a resource on the server to receive notifications when it changes.

public Task SubscribeToResourceAsync(SubscribeRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams SubscribeRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

The result of the request.

Remarks

This method subscribes to resource update notifications but does not register a handler. To receive notifications, you must separately call RegisterNotificationHandler(string, Func<JsonRpcNotification, CancellationToken, ValueTask>) with ResourceUpdatedNotification and filter for the specific resource URI. To unsubscribe, call UnsubscribeFromResourceAsync(UnsubscribeRequestParams, CancellationToken) and dispose the handler registration.

For a simpler API that handles both subscription and notification registration in a single call, use SubscribeToResourceAsync(Uri, Func<ResourceUpdatedNotificationParams, CancellationToken, ValueTask>, RequestOptions?, CancellationToken).

Exceptions

ArgumentNullException

requestParams is null.

SubscribeToResourceAsync(string, RequestOptions?, CancellationToken)

Subscribes to a resource on the server to receive notifications when it changes.

public Task SubscribeToResourceAsync(string uri, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri string

The URI of the resource to which to subscribe.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

uri is null.

ArgumentException

uri is empty or composed entirely of whitespace.

SubscribeToResourceAsync(string, Func<ResourceUpdatedNotificationParams, CancellationToken, ValueTask>, RequestOptions?, CancellationToken)

Subscribes to a resource on the server and registers a handler for notifications when it changes.

public Task<IAsyncDisposable> SubscribeToResourceAsync(string uri, Func<ResourceUpdatedNotificationParams, CancellationToken, ValueTask> handler, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri string

The URI of the resource to which to subscribe.

handler Func<ResourceUpdatedNotificationParams, CancellationToken, ValueTask>

The handler to invoke when the resource is updated. It receives ResourceUpdatedNotificationParams for the subscribed resource.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task<IAsyncDisposable>

A task that completes with an IAsyncDisposable that, when disposed, unsubscribes from the resource and removes the notification handler.

Remarks

This method provides a convenient way to subscribe to resource updates and handle notifications in a single call. The returned IAsyncDisposable manages both the subscription and the notification handler registration. When disposed, it automatically unsubscribes from the resource and removes the handler.

The handler will only be invoked for notifications related to the specified resource URI. Notifications for other resources are filtered out automatically.

Exceptions

ArgumentNullException

uri or handler is null.

ArgumentException

uri is empty or composed entirely of whitespace.

SubscribeToResourceAsync(Uri, RequestOptions?, CancellationToken)

Unsubscribes from a resource on the server to stop receiving notifications about its changes.

public Task SubscribeToResourceAsync(Uri uri, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri Uri

The URI of the resource to which to subscribe.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

uri is null.

SubscribeToResourceAsync(Uri, Func<ResourceUpdatedNotificationParams, CancellationToken, ValueTask>, RequestOptions?, CancellationToken)

Subscribes to a resource on the server and registers a handler for notifications when it changes.

public Task<IAsyncDisposable> SubscribeToResourceAsync(Uri uri, Func<ResourceUpdatedNotificationParams, CancellationToken, ValueTask> handler, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri Uri

The URI of the resource to which to subscribe.

handler Func<ResourceUpdatedNotificationParams, CancellationToken, ValueTask>

The handler to invoke when the resource is updated. It receives ResourceUpdatedNotificationParams for the subscribed resource.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task<IAsyncDisposable>

A task that completes with an IAsyncDisposable that, when disposed, unsubscribes from the resource and removes the notification handler.

Remarks

This method provides a convenient way to subscribe to resource updates and handle notifications in a single call. The returned IAsyncDisposable manages both the subscription and the notification handler registration. When disposed, it automatically unsubscribes from the resource and removes the handler.

The handler will only be invoked for notifications related to the specified resource URI. Notifications for other resources are filtered out automatically.

Exceptions

ArgumentNullException

uri or handler is null.

UnsubscribeFromResourceAsync(UnsubscribeRequestParams, CancellationToken)

Unsubscribes from a resource on the server to stop receiving notifications about its changes.

public Task UnsubscribeFromResourceAsync(UnsubscribeRequestParams requestParams, CancellationToken cancellationToken = default)

Parameters

requestParams UnsubscribeRequestParams

The request parameters to send in the request.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

The result of the request.

Exceptions

ArgumentNullException

requestParams is null.

UnsubscribeFromResourceAsync(string, RequestOptions?, CancellationToken)

Unsubscribes from a resource on the server to stop receiving notifications about its changes.

public Task UnsubscribeFromResourceAsync(string uri, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri string

The URI of the resource to unsubscribe from.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

uri is null.

ArgumentException

uri is empty or composed entirely of whitespace.

UnsubscribeFromResourceAsync(Uri, RequestOptions?, CancellationToken)

Unsubscribes from a resource on the server to stop receiving notifications about its changes.

public Task UnsubscribeFromResourceAsync(Uri uri, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

uri Uri

The URI of the resource to unsubscribe from.

options RequestOptions

Optional request options including metadata, serialization settings, and progress tracking.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

uri is null.