Table of Contents

Class Content

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.Core.dll

Represents content within the Model Context Protocol (MCP) that can contain text, binary data, or references to resources.

public class Content
Inheritance
Content
Inherited Members
Extension Methods

Remarks

The Content class is a fundamental type in the MCP that can represent different forms of content based on the Type property. The main content types are:

  • "text" - Textual content, stored in the Text property
  • "image" - Image data, stored as base64 in the Data property with appropriate MIME type
  • "audio" - Audio data, stored as base64 in the Data property with appropriate MIME type
  • "resource" - Reference to a resource, accessed through the Resource property

This class is used extensively 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.

Data

Gets or sets the base64-encoded image or audio data.

[JsonPropertyName("data")]
public string? Data { get; set; }

Property Value

string

MimeType

Gets or sets the MIME type (or "media type") of the content, specifying the format of the data.

[JsonPropertyName("mimeType")]
public string? MimeType { get; set; }

Property Value

string

Remarks

This property is used when Type is "image", "audio", or "resource", to indicate the specific format of the binary data. Common values include "image/png", "image/jpeg", "audio/wav", and "audio/mp3".

This property is required when the Data property contains binary content, as it helps clients properly interpret and render the content.

Resource

Gets or sets the resource content of the message when Type is "resource".

[JsonPropertyName("resource")]
public ResourceContents? Resource { get; set; }

Property Value

ResourceContents

Remarks

This property is used to embed or reference resource data within a message. It's only applicable when the Type property is set to "resource".

Resources can be either text-based (TextResourceContents) or binary (BlobResourceContents), allowing for flexible data representation. Each resource has a URI that can be used for identification and retrieval.

Text

Gets or sets the text content of the message.

[JsonPropertyName("text")]
public string? Text { get; set; }

Property Value

string

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", and "resource".