MCP PHP SDK

CreateSamplingMessageResult implements ResultInterface

The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.

since protocol revision 2026-07-28 (SEP-2577), earliest removal 2027-07-28. Integrate with an LLM provider's API directly instead.

Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

Table of Contents

Interfaces

ResultInterface
Base class for all specific MCP result objects (the value of the 'result' field).

Properties

$content  : TextContent|ImageContent|AudioContent|ToolUseContent|array<int, TextContent|ImageContent|AudioContent|ToolUseContent>
$meta  : array<string|int, mixed>|null
$model  : string
$role  : Role
$stopReason  : string|null

Methods

__construct()  : mixed
fromArray()  : self
getContentBlocks()  : array<int, TextContent|ImageContent|AudioContent|ToolUseContent>
jsonSerialize()  : ToolUseContent>, model: string, stopReason?: string, _meta?: array}
hydrateContent()  : TextContent|ImageContent|AudioContent|ToolUseContent

Properties

Methods

__construct()

public __construct(Role $role, TextContent|ImageContent|AudioContent|ToolUseContent|array<string|int, TextContent|ImageContent|AudioContent|ToolUseContent$content, string $model[, string|null $stopReason = null ][, array<string, mixed>|null $meta = null ]) : mixed
Parameters
$role : Role

the role of the message

$content : TextContent|ImageContent|AudioContent|ToolUseContent|array<string|int, TextContent|ImageContent|AudioContent|ToolUseContent>

The content of the message. Keys are discarded, the property always holds a list.

$model : string

the name of the model that generated the message

$stopReason : string|null = null

The reason why sampling stopped, if known. The spec defines "endTurn", "stopSequence", "maxTokens" and "toolUse", but leaves the set open for provider-specific values, so this stays an unconstrained string.

$meta : array<string, mixed>|null = null

optional message metadata

fromArray()

public static fromArray(array<string, mixed> $data) : self
Parameters
$data : array<string, mixed>
Return values
self

jsonSerialize()

public jsonSerialize() : ToolUseContent>, model: string, stopReason?: string, _meta?: array}
Return values
ToolUseContent>, model: string, stopReason?: string, _meta?: array}
On this page

Search results