MCP PHP SDK

TextContent extends Content

Represents text content in MCP.

Tags
phpstan-import-type

AnnotationsData from Annotations

author

Kyrian Obikwelu koshnawaza@gmail.com

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

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
self

fromArray()

public static fromArray(TextContentData $data) : self
Parameters
$data : TextContentData
Return values
self

jsonSerialize()

Convert the content to an array.

public jsonSerialize() : Annotations}
Return values
Annotations}

        
On this page

Search results