Class BlobResourceContents
- Namespace
- ModelContextProtocol.Protocol
- Assembly
- ModelContextProtocol.Core.dll
Represents the binary contents of a resource in the Model Context Protocol.
public sealed class BlobResourceContents : ResourceContents
- Inheritance
-
BlobResourceContents
- Inherited Members
- Extension Methods
Remarks
BlobResourceContents is used when binary data needs to be exchanged through the Model Context Protocol. The binary data is represented as base64-encoded UTF-8 bytes in the Blob property.
This class inherits from ResourceContents, which also has a sibling implementation TextResourceContents for text-based resources. When working with resources, the appropriate type is chosen based on the nature of the content.
See the schema for more details.
Constructors
BlobResourceContents()
Initializes a new instance of the BlobResourceContents class.
public BlobResourceContents()
Properties
Blob
Gets or sets the base64-encoded UTF-8 bytes representing the binary data of the item.
[JsonPropertyName("blob")]
public required ReadOnlyMemory<byte> Blob { get; set; }
Property Value
Remarks
Setting this value will invalidate any cached value of DecodedData.
DecodedData
Gets the decoded data represented by Blob.
[JsonIgnore]
public ReadOnlyMemory<byte> DecodedData { get; }
Property Value
Remarks
When getting, this member will decode the value in Blob and cache the result. Subsequent accesses return the cached value unless Blob is modified.
Methods
FromBytes(ReadOnlyMemory<byte>, string, string?)
Creates a BlobResourceContents from raw data.
public static BlobResourceContents FromBytes(ReadOnlyMemory<byte> bytes, string uri, string? mimeType = null)
Parameters
bytesReadOnlyMemory<byte>The raw unencoded data.
uristringThe URI of the blob resource.
mimeTypestringThe optional MIME type of the data.
Returns
- BlobResourceContents
A new BlobResourceContents instance.