Class ResourceTemplate
- Namespace
- ModelContextProtocol.Protocol
- Assembly
- ModelContextProtocol.Core.dll
Represents a known resource template that the server is capable of reading.
public class ResourceTemplate
- Inheritance
-
ResourceTemplate
- Inherited Members
Remarks
Resource templates provide metadata about resources available on the server, including how to construct URIs for those resources.
Properties
Annotations
Gets or sets optional annotations for the resource template.
[JsonPropertyName("annotations")]
public Annotations? Annotations { get; init; }
Property Value
Remarks
These annotations can be used to specify the intended audience (User, Assistant, or both) and the priority level of the resource template. Clients can use this information to filter or prioritize resource templates for different roles.
Description
Gets or sets a description of what this resource template represents.
[JsonPropertyName("description")]
public string? Description { get; init; }
Property Value
Remarks
This description helps clients understand the purpose and content of resources that can be generated from this template. It can be used by client applications to provide context about available resource types or to display in user interfaces.
For AI models, this description can serve as a hint about when and how to use the resource template, enhancing the model's ability to generate appropriate URIs.
IsTemplated
Gets whether UriTemplate contains any template expressions.
[JsonIgnore]
public bool IsTemplated { get; }
Property Value
MimeType
Gets or sets the MIME type of this resource template, if known.
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }
Property Value
Remarks
Specifies the expected format of resources that can be generated from this template. This helps clients understand what type of content to expect when accessing resources created using this template.
Common MIME types include "text/plain" for plain text, "application/pdf" for PDF documents, "image/png" for PNG images, or "application/json" for JSON data.
Name
Gets or sets a human-readable name for this resource template.
[JsonPropertyName("name")]
public required string Name { get; init; }
Property Value
UriTemplate
Gets or sets the URI template (according to RFC 6570) that can be used to construct resource URIs.
[JsonPropertyName("uriTemplate")]
public required string UriTemplate { get; init; }
Property Value
Methods
AsResource()
Converts the ResourceTemplate into a Resource.
public Resource? AsResource()
Returns
- Resource
A Resource if IsTemplated is false; otherwise, null.