PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / trunk
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). vtrunk
3.0.3 3.0.2 3.0.1 trunk 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.3.0 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.91 2.7.92 2.7.93 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0
commercebird / vendor / wordpress / php-mcp-schema / src / Server / Prompts / DTO / PromptArgument.php
commercebird / vendor / wordpress / php-mcp-schema / src / Server / Prompts / DTO Last commit date
GetPromptRequest.php 3 months ago GetPromptRequestParams.php 3 months ago GetPromptResult.php 3 months ago ListPromptsRequest.php 3 months ago ListPromptsResult.php 3 months ago Prompt.php 3 months ago PromptArgument.php 3 months ago PromptListChangedNotification.php 3 months ago PromptMessage.php 3 months ago
PromptArgument.php
118 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Server\Prompts\DTO;
6
7 use WP\McpSchema\Common\Protocol\DTO\BaseMetadata;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Describes an argument that a prompt can accept.
12 *
13 * @since 2024-11-05
14 * @last-updated 2025-06-18 (added properties: title)
15 *
16 * @mcp-domain Server
17 * @mcp-subdomain Prompts
18 * @mcp-version 2025-11-25
19 */
20 class PromptArgument extends BaseMetadata
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * A human-readable description of the argument.
26 *
27 * @since 2024-11-05
28 *
29 * @var string|null
30 */
31 protected ?string $description;
32
33 /**
34 * Whether this argument must be provided.
35 *
36 * @since 2024-11-05
37 *
38 * @var bool|null
39 */
40 protected ?bool $required;
41
42 /**
43 * @param string $name @since 2024-11-05
44 * @param string|null $title @since 2025-06-18
45 * @param string|null $description @since 2024-11-05
46 * @param bool|null $required @since 2024-11-05
47 */
48 public function __construct(
49 string $name,
50 ?string $title = null,
51 ?string $description = null,
52 ?bool $required = null
53 ) {
54 parent::__construct($name, $title);
55 $this->description = $description;
56 $this->required = $required;
57 }
58
59 /**
60 * Creates an instance from an array.
61 *
62 * @param array{
63 * name: string,
64 * title?: string|null,
65 * description?: string|null,
66 * required?: bool|null
67 * } $data
68 * @phpstan-param array<string, mixed> $data
69 * @return self
70 */
71 public static function fromArray(array $data): self
72 {
73 self::assertRequired($data, ['name']);
74
75 return new self(
76 self::asString($data['name']),
77 self::asStringOrNull($data['title'] ?? null),
78 self::asStringOrNull($data['description'] ?? null),
79 self::asBoolOrNull($data['required'] ?? null)
80 );
81 }
82
83 /**
84 * Converts the instance to an array.
85 *
86 * @return array<string, mixed>
87 */
88 public function toArray(): array
89 {
90 $result = parent::toArray();
91
92 if ($this->description !== null) {
93 $result['description'] = $this->description;
94 }
95 if ($this->required !== null) {
96 $result['required'] = $this->required;
97 }
98
99 return $result;
100 }
101
102 /**
103 * @return string|null
104 */
105 public function getDescription(): ?string
106 {
107 return $this->description;
108 }
109
110 /**
111 * @return bool|null
112 */
113 public function getRequired(): ?bool
114 {
115 return $this->required;
116 }
117 }
118