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 / Tools / DTO / ToolInputSchema.php
commercebird / vendor / wordpress / php-mcp-schema / src / Server / Tools / DTO Last commit date
CallToolRequest.php 2 months ago CallToolRequestParams.php 2 months ago CallToolResult.php 2 months ago ListToolsRequest.php 2 months ago ListToolsResult.php 2 months ago Tool.php 2 months ago ToolAnnotations.php 2 months ago ToolExecution.php 2 months ago ToolInputSchema.php 1 month ago ToolListChangedNotification.php 2 months ago ToolOutputSchema.php 1 month ago
ToolInputSchema.php
135 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Server\Tools\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * A JSON Schema object defining the expected parameters for the tool.
12 *
13 * @mcp-domain Server
14 * @mcp-subdomain Tools
15 * @mcp-version 2025-11-25
16 */
17 class ToolInputSchema extends AbstractDataTransferObject
18 {
19 use ValidatesRequiredFields;
20
21 public const TYPE = 'object';
22
23 /**
24 * @var string|null
25 */
26 protected ?string $schema;
27
28 /**
29 * @var 'object'
30 */
31 protected string $type;
32
33 /**
34 * @var array<string, object>|null
35 */
36 protected ?array $properties;
37
38 /**
39 * @var array<string>|null
40 */
41 protected ?array $required;
42
43 /**
44 * @param string|null $schema
45 * @param array<string, object>|null $properties
46 * @param array<string>|null $required
47 */
48 public function __construct(
49 ?string $schema = null,
50 ?array $properties = null,
51 ?array $required = null
52 ) {
53 $this->type = self::TYPE;
54 $this->schema = $schema;
55 $this->properties = $properties;
56 $this->required = $required;
57 }
58
59 /**
60 * Creates an instance from an array.
61 *
62 * @param array{
63 * '$schema'?: string|null,
64 * type: 'object',
65 * properties?: array<string, object>|null,
66 * required?: array<string>|null
67 * } $data
68 * @phpstan-param array<string, mixed> $data
69 * @return self
70 */
71 public static function fromArray(array $data): self
72 {
73 return new self(
74 self::asStringOrNull($data['$schema'] ?? null),
75 self::asObjectMapOrNull($data['properties'] ?? null),
76 self::asStringArrayOrNull($data['required'] ?? null)
77 );
78 }
79
80 /**
81 * Converts the instance to an array.
82 *
83 * @return array<string, mixed>
84 */
85 public function toArray(): array
86 {
87 $result = [];
88
89 if ($this->schema !== null) {
90 $result['$schema'] = $this->schema;
91 }
92 $result['type'] = $this->type;
93 $result['properties'] = !empty($this->properties)
94 ? $this->properties
95 : new \stdClass();
96 if ($this->required !== null) {
97 $result['required'] = $this->required;
98 }
99
100 return $result;
101 }
102
103 /**
104 * @return string|null
105 */
106 public function getSchema(): ?string
107 {
108 return $this->schema;
109 }
110
111 /**
112 * @return 'object'
113 */
114 public function getType(): string
115 {
116 return $this->type;
117 }
118
119 /**
120 * @return array<string, object>|null
121 */
122 public function getProperties(): ?array
123 {
124 return $this->properties;
125 }
126
127 /**
128 * @return array<string>|null
129 */
130 public function getRequired(): ?array
131 {
132 return $this->required;
133 }
134 }
135