1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Core\Schema\RequestParams;
15:
16: use Nexus\Assert\Assert;
17: use Nexus\Mcp\Core\Schema\MetaObject\RequestMetaObject;
18: use Nexus\Mcp\Core\Schema\RequestParams;
19: use Nexus\Mcp\Core\Schema\Result\InputResponse;
20:
21: /**
22: * Request params that may carry the client's responses to a prior
23: * `InputRequiredResult` plus the opaque request-state continuation token.
24: *
25: * @template-covariant T of array<string, mixed>
26: *
27: * @extends RequestParams<T>
28: *
29: * @see https://modelcontextprotocol.io/specification/2026-07-28/schema#inputresponserequestparams
30: */
31: abstract readonly class InputResponseRequestParams extends RequestParams implements InputResponseCarrierInterface
32: {
33: /**
34: * @var null|array<int|non-empty-string, InputResponse>
35: */
36: public ?array $inputResponses;
37:
38: /**
39: * @param null|array<int|non-empty-string, InputResponse> $inputResponses
40: */
41: public function __construct(
42: ?array $inputResponses,
43: public ?string $requestState,
44: RequestMetaObject $meta,
45: ) {
46: $inputResponses = [] === $inputResponses ? null : $inputResponses;
47:
48: if (null !== $inputResponses) {
49: Assert::that($inputResponses)
50: ->keys()
51: ->isIntOrNonEmptyString('each "params.inputResponses" key must be an int or non-empty string.')
52: ;
53: Assert::that($inputResponses)
54: ->values()
55: ->isInstanceOf(InputResponse::class, 'each "params.inputResponses" entry must be an InputResponse, {type} given.')
56: ;
57: }
58:
59: $this->inputResponses = $inputResponses;
60:
61: parent::__construct(meta: $meta);
62: }
63:
64: #[\Override]
65: public function getInputResponses(): ?array
66: {
67: return $this->inputResponses;
68: }
69:
70: #[\Override]
71: public function getRequestState(): ?string
72: {
73: return $this->requestState;
74: }
75: }
76: