Class ContentBlock
- Namespace
- ModelContextProtocol.Protocol
- Assembly
- ModelContextProtocol.Core.dll
Represents content within the Model Context Protocol (MCP).
[JsonConverter(typeof(ContentBlock.Converter))]
public abstract class ContentBlock
- Inheritance
-
ContentBlock
- Derived
- Inherited Members
- Extension Methods
Remarks
The ContentBlock class is a fundamental type in the MCP that can represent different forms of content based on the Type property. Derived types like TextContentBlock, ImageContentBlock, and EmbeddedResourceBlock provide the type-specific content.
This class is used throughout the MCP for representing content in messages, tool responses, and other communication between clients and servers.
See the schema for more details.
Properties
Annotations
Gets or sets optional annotations for the content.
[JsonPropertyName("annotations")]
public Annotations? Annotations { get; set; }
Property Value
Remarks
These annotations can be used to specify the intended audience (User, Assistant, or both) and the priority level of the content. Clients can use this information to filter or prioritize content for different roles.
Meta
Gets or sets metadata reserved by MCP for protocol-level metadata.
[JsonPropertyName("_meta")]
public JsonObject? Meta { get; set; }
Property Value
Remarks
Implementations must not make assumptions about its contents.
Type
When overridden in a derived class, gets the type of content.
[JsonPropertyName("type")]
public abstract string Type { get; }
Property Value
Remarks
This determines the structure of the content object. Valid values include "image", "audio", "text", "resource", "resource_link", "tool_use", and "tool_result".