using System.Text.Json.Serialization; namespace ModelContextProtocol.Protocol; /// /// Represents a known resource template that the server is capable of reading. /// /// /// Resource templates provide metadata about resources available on the server, /// including how to construct URIs for those resources. /// public class ResourceTemplate { /// /// 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; } /// /// Gets or sets a human-readable name for this resource template. /// [JsonPropertyName("name")] public required string Name { get; init; } /// /// Gets or sets a description of what this resource template represents. /// /// /// /// 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. /// /// [JsonPropertyName("description")] public string? Description { get; init; } /// /// Gets or sets the MIME type of this resource template, if known. /// /// /// /// 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. /// /// [JsonPropertyName("mimeType")] public string? MimeType { get; init; } /// /// Gets or sets optional annotations for the resource template. /// /// /// These annotations can be used to specify the intended audience (, , or both) /// and the priority level of the resource template. Clients can use this information to filter /// or prioritize resource templates for different roles. /// [JsonPropertyName("annotations")] public Annotations? Annotations { get; init; } /// Gets whether contains any template expressions. [JsonIgnore] public bool IsTemplated => UriTemplate.Contains('{'); /// Converts the into a . /// A if is ; otherwise, . public Resource? AsResource() { if (IsTemplated) { return null; } return new() { Uri = UriTemplate, Name = Name, Description = Description, MimeType = MimeType, Annotations = Annotations, }; } }