Method ReadResource
ReadResource(string, CancellationToken)
Reads the content of a specific resource from the server (synchronous wrapper).
public IReadOnlyCollection<McpResourceContent> ReadResource(string uri, CancellationToken cancellationToken = default)
Parameters
uristringThe URI of the resource to read (e.g., "file:///project/README.md", "schema://database"). Must not be null or whitespace.
cancellationTokenCancellationTokenOptional cancellation token to cancel the operation.
Returns
- IReadOnlyCollection<McpResourceContent>
A read-only collection 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.