MCP PHP SDK

PromptReference extends ElementReference

Tags
phpstan-import-type

Handler from ElementReference

author

Kyrian Obikwelu koshnawaza@gmail.com

Table of Contents

Properties

$completionProviders  : array<string|int, mixed>
$handler  : Closure|array<string|int, mixed>|string
$isManual  : bool
$prompt  : Prompt

Methods

__construct()  : mixed
formatResult()  : array<string|int, PromptMessage>
Formats the raw result of a prompt generator into an array of MCP PromptMessages.

Properties

$completionProviders read-only

public array<string|int, mixed> $completionProviders = []

$handler read-only

public Closure|array<string|int, mixed>|string $handler

Methods

__construct()

public __construct(Prompt $prompt, Handler $handler[, bool $isManual = false ][, array<string, class-string|object> $completionProviders = [] ]) : mixed
Parameters
$prompt : Prompt
$handler : Handler
$isManual : bool = false
$completionProviders : array<string, class-string|object> = []

formatResult()

Formats the raw result of a prompt generator into an array of MCP PromptMessages.

public formatResult(mixed $promptGenerationResult) : array<string|int, PromptMessage>
Parameters
$promptGenerationResult : mixed

expected: array of message structures

Tags
throws
RuntimeException

if the result cannot be formatted

throws
JsonException

if JSON encoding fails

Return values
array<string|int, PromptMessage>

array of PromptMessage objects


        
On this page

Search results