MCP PHP SDK

StatelessResponder

FinalYes

Turns a modern-era answer into the HTTP response carrying it.

Shared by the transports that can serve that era, so a subscriptions/listen stream and a plain result look the same on the wire whether the endpoint serves the modern lifecycle alone or alongside the handshake one.

Tags
author

Christopher Hertel mail@christopher-hertel.de

Table of Contents

Properties

$logger  : LoggerInterface
$responseFactory  : ResponseFactoryInterface
$streamFactory  : StreamFactoryInterface

Methods

__construct()  : mixed
error()  : ResponseInterface
json()  : ResponseInterface
respond()  : ResponseInterface
sse()  : ResponseInterface

Properties

Methods

__construct()

public __construct(ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory[, LoggerInterface $logger = new NullLogger() ]) : mixed
Parameters
$responseFactory : ResponseFactoryInterface
$streamFactory : StreamFactoryInterface
$logger : LoggerInterface = new NullLogger()

error()

public error(Error $error, int $httpStatus) : ResponseInterface
Parameters
$error : Error
$httpStatus : int
Return values
ResponseInterface

json()

public json(string $payload, int $status) : ResponseInterface
Parameters
$payload : string
$status : int
Return values
ResponseInterface

sse()

private sse(callable(): Generator<string|int, mixed> $frames) : ResponseInterface
Parameters
$frames : callable(): Generator<string|int, mixed>
Return values
ResponseInterface
On this page

Search results