1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2025 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\Schema\Request;
15:
16: use Nexus\Mcp\Schema\Arrayable;
17: use Nexus\Mcp\Schema\Elicitation\RequestedSchema;
18: use Nexus\Mcp\Schema\Message\JsonRpcRequest;
19: use Nexus\Mcp\Schema\Message\RequestId;
20:
21: /**
22: * A request from the server to elicit additional information from the user via the client.
23: *
24: * @extends JsonRpcRequest<array{
25: * jsonrpc: '2.0',
26: * id: int|non-empty-string,
27: * method: 'elicitation/create',
28: * params: array{
29: * _meta?: array<string, mixed>,
30: * message: non-empty-string,
31: * requestedSchema: template-type<RequestedSchema, Arrayable, 'T'>,
32: * },
33: * }>
34: */
35: final readonly class ElicitRequest extends JsonRpcRequest implements ServerRequest
36: {
37: /**
38: * @param non-empty-string $message The message to present to the user.
39: * @param RequestedSchema $requestedSchema A restricted subset of JSON Schema.
40: * Only top-level properties are allowed, without nesting.
41: * @param null|array<string, mixed> $meta Reserved by MCP to allow clients and servers to attach
42: * additional metadata to their interactions.
43: */
44: public function __construct(RequestId $id, string $message, RequestedSchema $requestedSchema, ?array $meta = null)
45: {
46: parent::__construct(self::JSON_RPC_VERSION, $id, 'elicitation/create', [
47: '_meta' => $meta,
48: 'message' => $message,
49: 'requestedSchema' => $requestedSchema->toArray(),
50: ]);
51: }
52: }
53: