Skip to content

Refactor Resource/ResourceTemplate to subclass Annotated #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/ModelContextProtocol/Protocol/Types/Annotated.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;

namespace ModelContextProtocol.Protocol.Types;

/// <summary>
/// Base for objects that include optional annotations for the client. The client can use annotations to inform how objects are used or displayed.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
/// </summary>
public abstract record Annotated
{
/// <summary>
/// Optional annotations for the resource.
/// </summary>
[JsonPropertyName("annotations")]
public Annotations? Annotations { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ModelContextProtocol.Protocol.Types;
/// Represents a known resource that the server is capable of reading.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
/// </summary>
public record Resource
public record Resource : Annotated
{
/// <summary>
/// The URI of this resource.
Expand All @@ -31,10 +31,4 @@ public record Resource
/// </summary>
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }

/// <summary>
/// Optional annotations for the resource.
/// </summary>
[JsonPropertyName("annotations")]
public Annotations? Annotations { get; init; }
}
8 changes: 1 addition & 7 deletions src/ModelContextProtocol/Protocol/Types/ResourceTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ModelContextProtocol.Protocol.Types;
/// Represents a known resource template that the server is capable of reading.
/// <see href="https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.json">See the schema for details</see>
/// </summary>
public record ResourceTemplate
public record ResourceTemplate : Annotated
{
/// <summary>
/// The URI template (according to RFC 6570) that can be used to construct resource URIs.
Expand All @@ -33,10 +33,4 @@ public record ResourceTemplate
/// </summary>
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }

/// <summary>
/// Optional annotations for the resource template.
/// </summary>
[JsonPropertyName("annotations")]
public Annotations? Annotations { get; init; }
}