Table of Contents

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; init; }

Property Value

Annotations

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.

Type

Gets or sets the type of content.

[JsonPropertyName("type")]
public string Type { get; set; }

Property Value

string

Remarks

This determines the structure of the content object. Valid values include "image", "audio", "text", "resource", and "resource_link".