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 / ToolOutputSchema.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
ToolOutputSchema.php
139 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 * An optional JSON Schema object defining the structure of the tool's output returned in
12 * the structuredContent field of a CallToolResult.
13 *
14 * Defaults to JSON Schema 2020-12 when no explicit $schema is provided.
15 * Currently restricted to type: "object" at the root level.
16 *
17 * @mcp-domain Server
18 * @mcp-subdomain Tools
19 * @mcp-version 2025-11-25
20 */
21 class ToolOutputSchema extends AbstractDataTransferObject
22 {
23 use ValidatesRequiredFields;
24
25 public const TYPE = 'object';
26
27 /**
28 * @var string|null
29 */
30 protected ?string $schema;
31
32 /**
33 * @var 'object'
34 */
35 protected string $type;
36
37 /**
38 * @var array<string, object>|null
39 */
40 protected ?array $properties;
41
42 /**
43 * @var array<string>|null
44 */
45 protected ?array $required;
46
47 /**
48 * @param string|null $schema
49 * @param array<string, object>|null $properties
50 * @param array<string>|null $required
51 */
52 public function __construct(
53 ?string $schema = null,
54 ?array $properties = null,
55 ?array $required = null
56 ) {
57 $this->type = self::TYPE;
58 $this->schema = $schema;
59 $this->properties = $properties;
60 $this->required = $required;
61 }
62
63 /**
64 * Creates an instance from an array.
65 *
66 * @param array{
67 * '$schema'?: string|null,
68 * type: 'object',
69 * properties?: array<string, object>|null,
70 * required?: array<string>|null
71 * } $data
72 * @phpstan-param array<string, mixed> $data
73 * @return self
74 */
75 public static function fromArray(array $data): self
76 {
77 return new self(
78 self::asStringOrNull($data['$schema'] ?? null),
79 self::asObjectMapOrNull($data['properties'] ?? null),
80 self::asStringArrayOrNull($data['required'] ?? null)
81 );
82 }
83
84 /**
85 * Converts the instance to an array.
86 *
87 * @return array<string, mixed>
88 */
89 public function toArray(): array
90 {
91 $result = [];
92
93 if ($this->schema !== null) {
94 $result['$schema'] = $this->schema;
95 }
96 $result['type'] = $this->type;
97 $result['properties'] = !empty($this->properties)
98 ? $this->properties
99 : new \stdClass();
100 if ($this->required !== null) {
101 $result['required'] = $this->required;
102 }
103
104 return $result;
105 }
106
107 /**
108 * @return string|null
109 */
110 public function getSchema(): ?string
111 {
112 return $this->schema;
113 }
114
115 /**
116 * @return 'object'
117 */
118 public function getType(): string
119 {
120 return $this->type;
121 }
122
123 /**
124 * @return array<string, object>|null
125 */
126 public function getProperties(): ?array
127 {
128 return $this->properties;
129 }
130
131 /**
132 * @return array<string>|null
133 */
134 public function getRequired(): ?array
135 {
136 return $this->required;
137 }
138 }
139