MCP PHP SDK

InputRequestResolver

FinalYes

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
see
https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/mrtr
author

Christopher Hertel mail@christopher-hertel.de

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

$handlers  : array<string|int, mixed>
$logger  : LoggerInterface

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

Methods

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>|null

resolve()

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
throws
RuntimeException

when an ask cannot be answered at all

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>

resultOf()

private static resultOf(Response<string|int, mixed> $response) : array<string, mixed>
Parameters
$response : Response<string|int, mixed>
Return values
array<string, mixed>
On this page

Search results