Audit protocol types (#892)

This commit is contained in:
Mackinnon Buck 2025-11-04 18:41:10 -05:00 • committed by GitHub
commit 121929da36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,18 +23,18 @@ namespace ModelContextProtocol.Protocol;
public abstract class Reference
{
/// <summary>Prevent external derivations.</summary>
private protected Reference()
private protected Reference()
{
}
/// <summary>
/// Gets or sets the type of content.
/// When overridden in a derived class, gets the type of content.
/// </summary>
/// <remarks>
/// This can be "ref/resource" or "ref/prompt".
/// </remarks>
[JsonPropertyName("type")]
public string Type { get; set; } = string.Empty;
public abstract string Type { get; }
/// <summary>
/// Provides a <see cref="JsonConverter"/> for <see cref="Reference"/>.
@ -153,10 +153,8 @@ public abstract class Reference
/// </summary>
public sealed class PromptReference : Reference, IBaseMetadata
{
/// <summary>
/// Initializes a new instance of the <see cref="PromptReference"/> class.
/// </summary>
public PromptReference() => Type = "ref/prompt";
/// <inheritdoc />
public override string Type => "ref/prompt";
/// <inheritdoc />
[JsonPropertyName("name")]
@ -175,10 +173,8 @@ public sealed class PromptReference : Reference, IBaseMetadata
/// </summary>
public sealed class ResourceTemplateReference : Reference
{
/// <summary>
/// Initializes a new instance of the <see cref="ResourceTemplateReference"/> class.
/// </summary>
public ResourceTemplateReference() => Type = "ref/resource";
/// <inheritdoc />
public override string Type => "ref/resource";
/// <summary>
/// Gets or sets the URI or URI template of the resource.