4using System.Threading.Tasks;
27 Dictionary<string, object>?
MetaData)
35 public override Type[]
Encodes =>
new Type[]
51 public override Task<Dictionary<string, object>>
Encode(
object Content)
53 Dictionary<string, object> Result =
new Dictionary<string, object>();
56 if (Encoded.
ContentType.StartsWith(
"text/plain", StringComparison.InvariantCultureIgnoreCase))
58 Result[
"type"] =
"text";
61 else if (Encoded.
ContentType.StartsWith(
"image/", StringComparison.InvariantCultureIgnoreCase))
63 Result[
"type"] =
"image";
65 Result[
"data"] = Convert.ToBase64String(Encoded.
Encoded);
67 else if (Encoded.
ContentType.StartsWith(
"audio/", StringComparison.InvariantCultureIgnoreCase))
69 Result[
"type"] =
"audio";
71 Result[
"data"] = Convert.ToBase64String(Encoded.
Encoded);
75 Result[
"type"] =
"resource";
76 Result[
"resource"] =
new Dictionary<string, object>()
78 {
"uri", Encoded.
Uri?.OriginalString ?? string.Empty },
79 {
"mimeType", Encoded.ContentType },
80 {
"blob", Convert.ToBase64String(Encoded.
Encoded) }
86 return Task.FromResult(Result);
Uri Uri
Optional original URI of content.
string ContentType
Internet Content-Type of encoded object.
byte[] Encoded
Encoded object.
DateTime? LastModified
The moment the resource was last modified, as an ISO 8601 formatted string.
double? Priority
Describes how important this data is for operating the server.
McpRole?[] Audience
Describes who the intended audience of this object or data is.
Abstract base class for an MCP Content Block.
override void Annotate(Dictionary< string, object > Object)
Annotates an object.
Dictionary< string, object >? MetaData
CustomContent(McpRole[]? Audience, double? Priority, DateTime? LastModified, Dictionary< string, object >? MetaData)
Custom Content Block
override Type[] Encodes
What types the content block encodes.
override bool IsStructuredContent
If the content block is encoded as structured content.
override Task< Dictionary< string, object > > Encode(object Content)
Encodes a content block, given the content to encode and available annotations and meta-data.
CustomContent()
Custom Content Block
Static class managing binary representations of strings.
static string GetString(byte[] Data, int Offset, int Count, Encoding DefaultEncoding)
Gets a string from its binary representation, taking any Byte Order Mark (BOM) into account.
McpRole
Identifies a Role in a Model Context Protocol (MCP) context.