Method ReadResourceAsync
ReadResourceAsync(string, CancellationToken)
Reads the content of a specific resource from the server.
public Task<IReadOnlyList<McpResourceContent>> ReadResourceAsync(string uri, CancellationToken cancellationToken = default)
Parameters
uristringThe URI of the resource to read.
cancellationTokenCancellationTokenOptional cancellation token to cancel the operation.
Returns
- Task<IReadOnlyList<McpResourceContent>>
A read-only list of McpResourceContent entries representing the resource content.
Exceptions
- ArgumentException
Thrown when
uriis null or whitespace.- ObjectDisposedException
Thrown when the client has been disposed.
- InvalidOperationException
Thrown when the server payload is malformed or the resource is missing.
- HttpRequestException
Thrown when the HTTP request fails or the server returns an error.