diff --git a/src/ModelContextProtocol/Protocol/Types/Annotated.cs b/src/ModelContextProtocol/Protocol/Types/Annotated.cs new file mode 100644 index 0000000..2b3458f --- /dev/null +++ b/src/ModelContextProtocol/Protocol/Types/Annotated.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; + +namespace ModelContextProtocol.Protocol.Types; + +/// +/// Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed. +/// See the schema for details +/// +public abstract record Annotated +{ + /// + /// Optional annotations for the resource. + /// + [JsonPropertyName("annotations")] + public Annotations? Annotations { get; init; } +} diff --git a/src/ModelContextProtocol/Protocol/Types/Resources.cs b/src/ModelContextProtocol/Protocol/Types/Resource.cs similarity index 83% rename from src/ModelContextProtocol/Protocol/Types/Resources.cs rename to src/ModelContextProtocol/Protocol/Types/Resource.cs index 7bd3a93..fbe44bc 100644 --- a/src/ModelContextProtocol/Protocol/Types/Resources.cs +++ b/src/ModelContextProtocol/Protocol/Types/Resource.cs @@ -6,7 +6,7 @@ namespace ModelContextProtocol.Protocol.Types; /// Represents a known resource that the server is capable of reading. /// See the schema for details /// -public record Resource +public record Resource : Annotated { /// /// The URI of this resource. @@ -31,10 +31,4 @@ public record Resource /// [JsonPropertyName("mimeType")] public string? MimeType { get; init; } - - /// - /// Optional annotations for the resource. - /// - [JsonPropertyName("annotations")] - public Annotations? Annotations { get; init; } } diff --git a/src/ModelContextProtocol/Protocol/Types/ResourceTemplate.cs b/src/ModelContextProtocol/Protocol/Types/ResourceTemplate.cs index b32822a..4bf6e60 100644 --- a/src/ModelContextProtocol/Protocol/Types/ResourceTemplate.cs +++ b/src/ModelContextProtocol/Protocol/Types/ResourceTemplate.cs @@ -8,7 +8,7 @@ namespace ModelContextProtocol.Protocol.Types; /// Represents a known resource template that the server is capable of reading. /// See the schema for details /// -public record ResourceTemplate +public record ResourceTemplate : Annotated { /// /// The URI template (according to RFC 6570) that can be used to construct resource URIs. @@ -33,10 +33,4 @@ public record ResourceTemplate /// [JsonPropertyName("mimeType")] public string? MimeType { get; init; } - - /// - /// Optional annotations for the resource template. - /// - [JsonPropertyName("annotations")] - public Annotations? Annotations { get; init; } } \ No newline at end of file