Class McpClientResourceTemplate
- Namespace
- ModelContextProtocol.Client
- Assembly
- ModelContextProtocol.Core.dll
Represents a named resource template that can be retrieved from an MCP server.
public sealed class McpClientResourceTemplate
- Inheritance
-
McpClientResourceTemplate
- Inherited Members
Remarks
This class provides a client-side wrapper around a resource template defined on an MCP server. It allows retrieving the resource template's content by sending a request to the server with the resource's URI. Instances of this class are typically obtained by calling ListResourceTemplatesAsync(IMcpClient, CancellationToken) or EnumerateResourceTemplatesAsync(IMcpClient, CancellationToken).
Properties
Description
Gets a description of the resource template.
public string? Description { get; }
Property Value
MimeType
Gets a media (MIME) type of the resource template.
public string? MimeType { get; }
Property Value
Name
Gets the name of the resource template.
public string Name { get; }
Property Value
ProtocolResourceTemplate
Gets the underlying protocol ResourceTemplate type for this instance.
public ResourceTemplate ProtocolResourceTemplate { get; }
Property Value
Remarks
This property provides direct access to the underlying protocol representation of the resource template, which can be useful for advanced scenarios or when implementing custom MCP client extensions.
For most common use cases, you can use the more convenient UriTemplate and Description properties instead of accessing the ProtocolResourceTemplate directly.
UriTemplate
Gets the URI template of the resource template.
public string UriTemplate { get; }
Property Value
Methods
ReadAsync(IReadOnlyDictionary<string, object?>, CancellationToken)
Gets this resource template's content by formatting a URI from the template and supplied arguments and sending a request to the server.
public ValueTask<ReadResourceResult> ReadAsync(IReadOnlyDictionary<string, object?> arguments, CancellationToken cancellationToken = default)
Parameters
arguments
IReadOnlyDictionary<string, object>A dictionary of arguments to pass to the tool. Each key represents a parameter name, and its associated value represents the argument value.
cancellationToken
CancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<ReadResourceResult>
A ValueTask<TResult> containing the resource template's result with content and messages.