| Methods |
public
|
__construct(
Implementation $clientInfo,
ClientCapabilities $clientCapabilities,
MessageDispatcherInterface $dispatcher,
PendingOutboundRequests $outboundRequests,
Closure(): (int|non-empty-string) $requestIdFactory,
Closure(): (int|non-empty-string) $progressTokenFactory,
ProtocolVersion $protocolVersion = new ProtocolVersion(version: ProtocolVersion::LATEST_VERSION),
ProgressListenerRegistry $progressListeners = new ProgressListenerRegistry(),
SubscriptionRegistry $subscriptions = new SubscriptionRegistry(),
LoggerInterface $logger = new NullLogger(),
null|float $requestTimeout = self::DEFAULT_REQUEST_TIMEOUT,
null|float $maxRequestTimeout = self::DEFAULT_MAX_REQUEST_TIMEOUT,
bool $retryLostRequests = false,
)
Parameters
| $requestTimeout |
Seconds a request may go unanswered, or null to wait indefinitely
|
| $maxRequestTimeout |
Seconds a request may run however much progress arrives, or null to leave it unbounded
|
|
#
|
public
|
connect(TransportInterface $transport): void
Non-blocking connect to the transport.
Non-blocking connect to the transport.
Throws
|
#
|
public
|
disconnect(): void
Closes the transport and detaches it so a fresh connect() can run.
A no-op when the client is not connected.
Closes the transport and detaches it so a fresh connect() can run.
A no-op when the client is not connected.
|
#
|
public
|
getServerInfo(): ?Implementation
The server's Implementation block from the last server/discover
response _meta, or null if discovery has not run or the server did
not identify itself.
The server's Implementation block from the last server/discover
response _meta, or null if discovery has not run or the server did
not identify itself.
|
#
|
public
|
getServerCapabilities(): ?ServerCapabilities
The server's capabilities from the last server/discover response, or
null if discovery has not run.
The server's capabilities from the last server/discover response, or
null if discovery has not run.
|
#
|
public
|
discover(): DiscoverResult
Sends server/discover and records the advertised server info and capabilities.
Sends server/discover and records the advertised server info and capabilities.
Throws
|
#
|
public
|
listen(
SubscriptionFilter $notifications,
Closure(JsonRpcNotification<non-empty-string>): void $onNotification,
): SubscriptionStream
Opens a subscriptions/listen stream and routes every notification the server tags with its id to
$onNotification. Returns as soon as the request is away: the stream runs until either side ends it.
Opens a subscriptions/listen stream and routes every notification the server tags with its id to
$onNotification. Returns as soon as the request is away: the stream runs until either side ends it.
Throws
|
#
|
public
|
listTools(?Cursor $cursor = null): ListToolsResult
|
#
|
public
|
listResources(?Cursor $cursor = null): ListResourcesResult
|
#
|
public
|
listResourceTemplates(?Cursor $cursor = null): ListResourceTemplatesResult
|
#
|
public
|
listPrompts(?Cursor $cursor = null): ListPromptsResult
|
#
|
public
|
readResource(string $uri): InputRequiredResult|ReadResourceResult
|
#
|
public
|
getPrompt(string $name, null|array<string, string> $arguments = null): GetPromptResult|InputRequiredResult
|
#
|
public
|
complete(
PromptReference|ResourceTemplateReference $ref,
array{name: string, value: string} $argument,
null|array{arguments?: array<string, string>} $context = null,
): CompleteResult
|
#
|
public
|
callTool(
string $name,
null|array<string, mixed> $arguments = null,
null|(Closure(float $progress, ?float $total, ?string $message): void) $onProgress = null,
null|array<string, InputResponse> $inputResponses = null,
null|string $requestState = null,
): CallToolResult|InputRequiredResult
Invokes a tool. When $onProgress is given, a fresh progressToken is
minted into the request's _meta and the callback receives every
matching notifications/progress for the duration of the call. A server that needs more input answers with an InputRequiredResult rather
than a result. Satisfy each of its inputRequests and call again with the
answers plus the requestState it carried, which is opaque and must be
echoed back unchanged.
Invokes a tool. When $onProgress is given, a fresh progressToken is
minted into the request's _meta and the callback receives every
matching notifications/progress for the duration of the call. A server that needs more input answers with an InputRequiredResult rather
than a result. Satisfy each of its inputRequests and call again with the
answers plus the requestState it carried, which is opaque and must be
echoed back unchanged.
Parameters
| $inputResponses |
Answers to a prior InputRequiredResult, keyed as its inputRequests were
|
| $requestState |
Echoed verbatim from the InputRequiredResult being answered
|
Throws
|
#
|
public
|
sendRequest<TResponse is JsonRpcResultResponse = JsonRpcResultResponse>(
JsonRpcRequest<non-empty-string> $request,
class-string<TResponse> $response,
?SendContext $context = null,
null|float $timeout = null,
): TResponse
Sends an outbound JSON-RPC request and awaits the correlated response.
Sends an outbound JSON-RPC request and awaits the correlated response.
Parameters
| $timeout |
Seconds this one request may go unanswered, overriding the client's default
|
Throws
|
#
|