| Methods |
public
|
__construct(
non-empty-string $endpoint,
null|DelegateHttpClient $client = null,
LoggerInterface $logger = new NullLogger(),
float $readTimeout = 30.0,
int $maxResponseBytes = self::DEFAULT_MAX_RESPONSE_BYTES,
)
Parameters
| $endpoint |
Absolute URL of the server's MCP endpoint
|
| $client |
Defaults to the amphp default client
|
| $readTimeout |
Seconds a response may stall before the exchange is abandoned.
It must exceed the server's SSE keep-alive interval, or a quiet
long-lived stream is torn down between keep-alives.
|
| $maxResponseBytes |
Bytes a buffered body, or one SSE frame, may occupy
|
|
#
|
public
|
start(): void
Begins consuming inbound envelopes from the peer. Returns immediately.
Begins consuming inbound envelopes from the peer. Returns immediately.
Implements
|
#
|
public
|
send(JsonRpcMessage $message, ?SendContext $context = null): void
Enqueues an outbound JSON-RPC message to the peer. On write failure, close listeners fire before the exception is rethrown.
Enqueues an outbound JSON-RPC message to the peer. On write failure, close listeners fire before the exception is rethrown.
Implements
|
#
|
public
|
close(): void
Closes the connection. The onClose() listener fires once after the
underlying streams are closed. Subsequent calls are no-ops. Implementations MUST guarantee that onClose() listeners fire after a
fatal error too, not only after explicit close(). Server::run()
blocks on the close signal, so a transport that raises errors without
eventually closing would hang the server loop.
Closes the connection. The onClose() listener fires once after the
underlying streams are closed. Subsequent calls are no-ops. Implementations MUST guarantee that onClose() listeners fire after a
fatal error too, not only after explicit close(). Server::run()
blocks on the close signal, so a transport that raises errors without
eventually closing would hang the server loop.
Implements
|
#
|
public
|
onMessage(Closure $listener): SubscriptionInterface
Register an inbound-envelope listener.
Register an inbound-envelope listener.
Implements
|
#
|
public
|
onError(Closure $listener): SubscriptionInterface
Register an error listener.
Register an error listener.
Implements
|
#
|
public
|
onDrain(Closure $listener): SubscriptionInterface
Register a drain listener that fires before close().
Register a drain listener that fires before close().
Implements
|
#
|
public
|
onClose(Closure $listener): SubscriptionInterface
Register a close listener.
Register a close listener.
Implements
|
#
|