InputRequestResolver
Answers a server's multi round-trip asks (SEP-2322).
The modern era removed server-initiated requests, so a server that needs
something from the client says so in the result and the client re-sends the
original call carrying the answers. What used to be an inbound request the
client responded to is now an entry in inputRequests it resolves locally —
so the same handlers answer it, and a caller that registered an elicitation
callback keeps working across the revision boundary.
Tags
Table of Contents
Constants
- RESOLVABLE : array<string, Request>> = ['elicitation/create' => \Mcp\Schema\Request\El...
- The only requests a server may park in `inputRequests`. Anything else is a server fault, and answering it would be inventing protocol.
Properties
Methods
- __construct() : mixed
- asked() : array<string, mixed>|null
- Reads the `inputRequests` map off a result, or null when the result is not an ask.
- resolve() : array<string, mixed>
- Resolves every ask into the `inputResponses` map the retry carries.
- answer() : array<string, mixed>
- dispatch() : array<string, mixed>|Error
- resultOf() : array<string, mixed>
Constants
RESOLVABLE
The only requests a server may park in `inputRequests`. Anything else is a server fault, and answering it would be inventing protocol.
private
array<string, Request>>
RESOLVABLE
= ['elicitation/create' => \Mcp\Schema\Request\ElicitRequest::class, 'sampling/createMessage' => \Mcp\Schema\Request\CreateSamplingMessageRequest::class, 'roots/list' => \Mcp\Schema\Request\ListRootsRequest::class]
Properties
$handlers read-only
private
array<string|int, mixed>
$handlers
$logger read-only
private
LoggerInterface
$logger
= new NullLogger()
Methods
__construct()
public
__construct(array<string|int, RequestHandlerInterface<string|int, mixed>> $handlers[, LoggerInterface $logger = new NullLogger() ]) : mixed
Parameters
- $handlers : array<string|int, RequestHandlerInterface<string|int, mixed>>
- $logger : LoggerInterface = new NullLogger()
asked()
Reads the `inputRequests` map off a result, or null when the result is not an ask.
public
static asked(array<string, mixed> $result) : array<string, mixed>|null
A result with no resultType MUST be read as complete, so an absent
member is not an ask — only the explicit input_required is.
Parameters
- $result : array<string, mixed>
Return values
array<string, mixed>|nullresolve()
Resolves every ask into the `inputResponses` map the retry carries.
public
resolve(array<string, mixed> $inputRequests) : array<string, mixed>
Keys are the server's, and each answer goes back under the key it was asked under — the client never reorders or renames them, since that map is how the server correlates answers to questions.
Parameters
- $inputRequests : array<string, mixed>
Tags
Return values
array<string, mixed>answer()
private
answer(string $key, mixed $ask) : array<string, mixed>
Parameters
- $key : string
- $ask : mixed
Return values
array<string, mixed>dispatch()
private
dispatch(Request $request) : array<string, mixed>|Error
Parameters
- $request : Request
Return values
array<string, mixed>|ErrorresultOf()
private
static resultOf(Response<string|int, mixed> $response) : array<string, mixed>
Parameters
- $response : Response<string|int, mixed>