ClientGateway
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- elicit() : ElicitResult
- Convenience method for elicitation requests.
- log() : void
- Convenience method to send a logging notification to the client.
- notify() : void
- Send a notification to the client (fire and forget).
- progress() : void
- Convenience method to send a progress notification to the client.
- sample() : CreateSamplingMessageResult
- Convenience method for LLM sampling requests.
- supportsElicitation() : bool
- Check if the connected client supports elicitation.
- request() : Response<string|int, array<string, mixed>>|Error
- Send a request to the client and wait for a response (blocking).
Properties
$session read-only
private
SessionInterface
$session
Methods
__construct()
public
__construct(SessionInterface $session) : mixed
Parameters
- $session : SessionInterface
elicit()
Convenience method for elicitation requests.
public
elicit(string $message, ElicitationSchema $requestedSchema[, int $timeout = 120 ]) : ElicitResult
Requests additional information from the user via the client. The user can accept (providing the requested data), decline, or cancel the request.
Parameters
- $message : string
-
A human-readable message describing what information is needed
- $requestedSchema : ElicitationSchema
-
The schema defining the fields to elicit from the user
- $timeout : int = 120
-
The timeout in seconds
Tags
Return values
ElicitResult —The elicitation response containing the user's action and any provided content
log()
Convenience method to send a logging notification to the client.
public
log(LoggingLevel $level, mixed $data[, string|null $logger = null ]) : void
Parameters
- $level : LoggingLevel
- $data : mixed
- $logger : string|null = null
notify()
Send a notification to the client (fire and forget).
public
notify(Notification $notification) : void
This suspends the Fiber to let the transport flush the notification via SSE, then immediately resumes execution.
Parameters
- $notification : Notification
progress()
Convenience method to send a progress notification to the client.
public
progress(float $progress[, float|null $total = null ][, string|null $message = null ]) : void
Parameters
- $progress : float
- $total : float|null = null
- $message : string|null = null
sample()
Convenience method for LLM sampling requests.
public
sample(array<string|int, SamplingMessage>|TextContent|AudioContent|ImageContent|string $message[, int $maxTokens = 1000 ][, int $timeout = 120 ][, SampleOptions $options = [] ]) : CreateSamplingMessageResult
Parameters
- $message : array<string|int, SamplingMessage>|TextContent|AudioContent|ImageContent|string
-
The message for the LLM
- $maxTokens : int = 1000
-
Maximum tokens to generate
- $timeout : int = 120
-
The timeout in seconds
- $options : SampleOptions = []
-
Additional sampling options (temperature, etc.)
Tags
Return values
CreateSamplingMessageResult —The sampling response
supportsElicitation()
Check if the connected client supports elicitation.
public
supportsElicitation() : bool
Elicitation allows servers to request additional information from users during tool execution. This method checks the client's advertised capabilities to determine if elicitation/create requests are supported.
Return values
bool —True if the client supports elicitation, false otherwise
request()
Send a request to the client and wait for a response (blocking).
private
request(Request $request[, int $timeout = 120 ]) : Response<string|int, array<string, mixed>>|Error
This suspends the Fiber and waits for the client to respond. The transport handles polling the session for the response and resuming the Fiber when ready.
Parameters
- $request : Request
-
The request to send
- $timeout : int = 120
-
Maximum time to wait for response (seconds)
Tags
Return values
Response<string|int, array<string, mixed>>|Error —The client's response message