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\Prompt;
15:
16: use Nexus\Mcp\Schema\BaseMetadata;
17:
18: /**
19: * Describes an argument that a prompt can accept.
20: *
21: * @extends BaseMetadata<array{
22: * name: non-empty-string,
23: * title?: non-empty-string,
24: * description?: non-empty-string,
25: * required?: bool,
26: * }>
27: */
28: final readonly class PromptArgument extends BaseMetadata
29: {
30: /**
31: * @param null|non-empty-string $description A human-readable description of the argument.
32: * @param null|bool $required Whether this argument must be provided.
33: */
34: public function __construct(
35: string $name,
36: ?string $title = null,
37: public ?string $description = null,
38: public ?bool $required = null,
39: ) {
40: parent::__construct($name, $title);
41: }
42:
43: #[\Override]
44: public function toArray(): array
45: {
46: return array_filter([
47: 'name' => $this->name,
48: 'title' => $this->title,
49: 'description' => $this->description,
50: 'required' => $this->required,
51: ], static fn(mixed $value): bool => null !== $value);
52: }
53: }
54: