Initial commit

This commit is contained in:
PederHP 2024-12-30 20:30:31 +01:00
commit fdbd94b3f9

View file

@ -0,0 +1,84 @@
namespace McpDotNet.Protocol.Types;
using System.Text.Json.Serialization;
/// <summary>
/// Represents a known resource that the server is capable of reading.
/// </summary>
public record Resource
{
/// <summary>
/// The URI of this resource.
/// </summary>
[JsonPropertyName("uri")]
public required string Uri { get; init; }
/// <summary>
/// A human-readable name for this resource.
/// </summary>
[JsonPropertyName("name")]
public required string Name { get; init; }
/// <summary>
/// A description of what this resource represents.
/// </summary>
[JsonPropertyName("description")]
public string? Description { get; init; }
/// <summary>
/// The MIME type of this resource, if known.
/// </summary>
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }
/// <summary>
/// Optional annotations for the resource.
/// </summary>
[JsonPropertyName("annotations")]
public Annotations? Annotations { get; init; }
}
/// <summary>
/// Interface for resource contents.
/// </summary>
public interface IResourceContents
{
string Uri { get; }
string? MimeType { get; }
}
/// <summary>
/// Represents text-based resource contents.
/// </summary>
public record TextResourceContents : IResourceContents
{
[JsonPropertyName("uri")]
public required string Uri { get; init; }
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }
/// <summary>
/// The text content of the resource.
/// </summary>
[JsonPropertyName("text")]
public required string Text { get; init; }
}
/// <summary>
/// Represents binary resource contents.
/// </summary>
public record BlobResourceContents : IResourceContents
{
[JsonPropertyName("uri")]
public required string Uri { get; init; }
[JsonPropertyName("mimeType")]
public string? MimeType { get; init; }
/// <summary>
/// The base64-encoded binary content of the resource.
/// </summary>
[JsonPropertyName("blob")]
public required string Blob { get; init; }
}