PluginProbe
ZIP AI – AI Website Builder & AI Agent (Beta) / 0.0.8
ZIP AI – AI Website Builder & AI Agent (Beta) v0.0.8
0.0.10 0.0.9 trunk 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8
zip-ai / lib / php-mcp-schema / src / Server / Lifecycle / DTO / ServerCapabilities.php

ServerCapabilities.php in ZIP AI – AI Website Builder & AI Agent (Beta) 0.0.8, at lib/php-mcp-schema/src/Server/Lifecycle/DTO/ServerCapabilities.php

260 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Server\Lifecycle\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
12 *
13 * @since 2024-11-05
14 * @last-updated 2025-11-25 (added properties: tasks)
15 *
16 * @mcp-domain Server
17 * @mcp-subdomain Lifecycle
18 * @mcp-version 2025-11-25
19 */
20 class ServerCapabilities extends AbstractDataTransferObject
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * Experimental, non-standard capabilities that the server supports.
26 *
27 * @since 2024-11-05
28 *
29 * @var array<string, object>|null
30 */
31 protected ?array $experimental;
32
33 /**
34 * Present if the server supports sending log messages to the client.
35 *
36 * @since 2024-11-05
37 *
38 * @var object|null
39 */
40 protected ?object $logging;
41
42 /**
43 * Present if the server supports argument autocompletion suggestions.
44 *
45 * @since 2025-03-26
46 *
47 * @var object|null
48 */
49 protected ?object $completions;
50
51 /**
52 * Present if the server offers any prompt templates.
53 *
54 * @since 2024-11-05
55 *
56 * @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesPrompts|null
57 */
58 protected ?ServerCapabilitiesPrompts $prompts;
59
60 /**
61 * Present if the server offers any resources to read.
62 *
63 * @since 2024-11-05
64 *
65 * @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesResources|null
66 */
67 protected ?ServerCapabilitiesResources $resources;
68
69 /**
70 * Present if the server offers any tools to call.
71 *
72 * @since 2024-11-05
73 *
74 * @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTools|null
75 */
76 protected ?ServerCapabilitiesTools $tools;
77
78 /**
79 * Present if the server supports task-augmented requests.
80 *
81 * @since 2025-11-25
82 *
83 * @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTasks|null
84 */
85 protected ?ServerCapabilitiesTasks $tasks;
86
87 /**
88 * @param array<string, object>|null $experimental @since 2024-11-05
89 * @param object|null $logging @since 2024-11-05
90 * @param object|null $completions @since 2025-03-26
91 * @param \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesPrompts|null $prompts @since 2024-11-05
92 * @param \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesResources|null $resources @since 2024-11-05
93 * @param \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTools|null $tools @since 2024-11-05
94 * @param \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTasks|null $tasks @since 2025-11-25
95 */
96 public function __construct(
97 ?array $experimental = null,
98 ?object $logging = null,
99 ?object $completions = null,
100 ?ServerCapabilitiesPrompts $prompts = null,
101 ?ServerCapabilitiesResources $resources = null,
102 ?ServerCapabilitiesTools $tools = null,
103 ?ServerCapabilitiesTasks $tasks = null
104 ) {
105 $this->experimental = $experimental;
106 $this->logging = $logging;
107 $this->completions = $completions;
108 $this->prompts = $prompts;
109 $this->resources = $resources;
110 $this->tools = $tools;
111 $this->tasks = $tasks;
112 }
113
114 /**
115 * Creates an instance from an array.
116 *
117 * @param array{
118 * experimental?: array<string, object>|null,
119 * logging?: object|null,
120 * completions?: object|null,
121 * prompts?: array<string, mixed>|\WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesPrompts|null,
122 * resources?: array<string, mixed>|\WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesResources|null,
123 * tools?: array<string, mixed>|\WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTools|null,
124 * tasks?: array<string, mixed>|\WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTasks|null
125 * } $data
126 * @phpstan-param array<string, mixed> $data
127 * @return self
128 */
129 public static function fromArray(array $data): self
130 {
131 /** @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesPrompts|null $prompts */
132 $prompts = isset($data['prompts'])
133 ? (is_array($data['prompts'])
134 ? ServerCapabilitiesPrompts::fromArray(self::asArray($data['prompts']))
135 : $data['prompts'])
136 : null;
137
138 /** @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesResources|null $resources */
139 $resources = isset($data['resources'])
140 ? (is_array($data['resources'])
141 ? ServerCapabilitiesResources::fromArray(self::asArray($data['resources']))
142 : $data['resources'])
143 : null;
144
145 /** @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTools|null $tools */
146 $tools = isset($data['tools'])
147 ? (is_array($data['tools'])
148 ? ServerCapabilitiesTools::fromArray(self::asArray($data['tools']))
149 : $data['tools'])
150 : null;
151
152 /** @var \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTasks|null $tasks */
153 $tasks = isset($data['tasks'])
154 ? (is_array($data['tasks'])
155 ? ServerCapabilitiesTasks::fromArray(self::asArray($data['tasks']))
156 : $data['tasks'])
157 : null;
158
159 return new self(
160 self::asObjectMapOrNull($data['experimental'] ?? null),
161 self::asObjectOrNull($data['logging'] ?? null),
162 self::asObjectOrNull($data['completions'] ?? null),
163 $prompts,
164 $resources,
165 $tools,
166 $tasks
167 );
168 }
169
170 /**
171 * Converts the instance to an array.
172 *
173 * @return array<string, mixed>
174 */
175 public function toArray(): array
176 {
177 $result = [];
178
179 if ($this->experimental !== null) {
180 $result['experimental'] = $this->experimental;
181 }
182 if ($this->logging !== null) {
183 $result['logging'] = $this->logging;
184 }
185 if ($this->completions !== null) {
186 $result['completions'] = $this->completions;
187 }
188 if ($this->prompts !== null) {
189 $result['prompts'] = $this->prompts->toArray();
190 }
191 if ($this->resources !== null) {
192 $result['resources'] = $this->resources->toArray();
193 }
194 if ($this->tools !== null) {
195 $result['tools'] = $this->tools->toArray();
196 }
197 if ($this->tasks !== null) {
198 $result['tasks'] = $this->tasks->toArray();
199 }
200
201 return $result;
202 }
203
204 /**
205 * @return array<string, object>|null
206 */
207 public function getExperimental(): ?array
208 {
209 return $this->experimental;
210 }
211
212 /**
213 * @return object|null
214 */
215 public function getLogging(): ?object
216 {
217 return $this->logging;
218 }
219
220 /**
221 * @return object|null
222 */
223 public function getCompletions(): ?object
224 {
225 return $this->completions;
226 }
227
228 /**
229 * @return \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesPrompts|null
230 */
231 public function getPrompts(): ?ServerCapabilitiesPrompts
232 {
233 return $this->prompts;
234 }
235
236 /**
237 * @return \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesResources|null
238 */
239 public function getResources(): ?ServerCapabilitiesResources
240 {
241 return $this->resources;
242 }
243
244 /**
245 * @return \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTools|null
246 */
247 public function getTools(): ?ServerCapabilitiesTools
248 {
249 return $this->tools;
250 }
251
252 /**
253 * @return \WP\McpSchema\Server\Lifecycle\DTO\ServerCapabilitiesTasks|null
254 */
255 public function getTasks(): ?ServerCapabilitiesTasks
256 {
257 return $this->tasks;
258 }
259 }
260