TextContent extends Content
Represents text content in MCP.
Tags
Table of Contents
Properties
- $annotations : Annotations|null
- $text : mixed
- $type : string
Methods
- __construct() : mixed
- Create a new TextContent instance from any value.
- code() : self
- Create a new TextContent with markdown formatted code.
- fromArray() : self
- jsonSerialize() : Annotations}
- Convert the content to an array.
Properties
$annotations read-only
public
Annotations|null
$annotations
= null
$text
public
mixed
$text
$type read-only
public
string
$type
Methods
__construct()
Create a new TextContent instance from any value.
public
__construct(mixed $text[, Annotations|null $annotations = null ]) : mixed
Parameters
- $text : mixed
-
The value to convert to text
- $annotations : Annotations|null = null
-
Optional annotations describing the content
code()
Create a new TextContent with markdown formatted code.
public
static code(string $code[, string $language = '' ][, Annotations|null $annotations = null ]) : self
Parameters
- $code : string
-
The code to format
- $language : string = ''
-
The language for syntax highlighting
- $annotations : Annotations|null = null
Return values
selffromArray()
public
static fromArray(TextContentData $data) : self
Parameters
- $data : TextContentData
Return values
selfjsonSerialize()
Convert the content to an array.
public
jsonSerialize() : Annotations}