convertkit
/
vendor
/
wordpress
/
php-mcp-schema
/
src
/
Client
/
Lifecycle
/
DTO
/
ClientCapabilities.php
ClientCapabilities.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at vendor/wordpress/php-mcp-schema/src/Client/Lifecycle/DTO/ClientCapabilities.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace WP\McpSchema\Client\Lifecycle\DTO; |
| 6 | |
| 7 | use WP\McpSchema\Common\AbstractDataTransferObject; |
| 8 | use WP\McpSchema\Common\Traits\ValidatesRequiredFields; |
| 9 | |
| 10 | /** |
| 11 | * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client 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 Client |
| 17 | * @mcp-subdomain Lifecycle |
| 18 | * @mcp-version 2025-11-25 |
| 19 | */ |
| 20 | class ClientCapabilities extends AbstractDataTransferObject |
| 21 | { |
| 22 | use ValidatesRequiredFields; |
| 23 | |
| 24 | /** |
| 25 | * Experimental, non-standard capabilities that the client 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 client supports listing roots. |
| 35 | * |
| 36 | * @since 2024-11-05 |
| 37 | * |
| 38 | * @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesRoots|null |
| 39 | */ |
| 40 | protected ?ClientCapabilitiesRoots $roots; |
| 41 | |
| 42 | /** |
| 43 | * Present if the client supports sampling from an LLM. |
| 44 | * |
| 45 | * @since 2024-11-05 |
| 46 | * |
| 47 | * @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesSampling|null |
| 48 | */ |
| 49 | protected ?ClientCapabilitiesSampling $sampling; |
| 50 | |
| 51 | /** |
| 52 | * Present if the client supports elicitation from the server. |
| 53 | * |
| 54 | * @since 2025-06-18 |
| 55 | * |
| 56 | * @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesElicitation|null |
| 57 | */ |
| 58 | protected ?ClientCapabilitiesElicitation $elicitation; |
| 59 | |
| 60 | /** |
| 61 | * Present if the client supports task-augmented requests. |
| 62 | * |
| 63 | * @since 2025-11-25 |
| 64 | * |
| 65 | * @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesTasks|null |
| 66 | */ |
| 67 | protected ?ClientCapabilitiesTasks $tasks; |
| 68 | |
| 69 | /** |
| 70 | * @param array<string, object>|null $experimental @since 2024-11-05 |
| 71 | * @param \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesRoots|null $roots @since 2024-11-05 |
| 72 | * @param \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesSampling|null $sampling @since 2024-11-05 |
| 73 | * @param \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesElicitation|null $elicitation @since 2025-06-18 |
| 74 | * @param \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesTasks|null $tasks @since 2025-11-25 |
| 75 | */ |
| 76 | public function __construct( |
| 77 | ?array $experimental = null, |
| 78 | ?ClientCapabilitiesRoots $roots = null, |
| 79 | ?ClientCapabilitiesSampling $sampling = null, |
| 80 | ?ClientCapabilitiesElicitation $elicitation = null, |
| 81 | ?ClientCapabilitiesTasks $tasks = null |
| 82 | ) { |
| 83 | $this->experimental = $experimental; |
| 84 | $this->roots = $roots; |
| 85 | $this->sampling = $sampling; |
| 86 | $this->elicitation = $elicitation; |
| 87 | $this->tasks = $tasks; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Creates an instance from an array. |
| 92 | * |
| 93 | * @param array{ |
| 94 | * experimental?: array<string, object>|null, |
| 95 | * roots?: array<string, mixed>|\WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesRoots|null, |
| 96 | * sampling?: array<string, mixed>|\WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesSampling|null, |
| 97 | * elicitation?: array<string, mixed>|\WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesElicitation|null, |
| 98 | * tasks?: array<string, mixed>|\WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesTasks|null |
| 99 | * } $data |
| 100 | * @phpstan-param array<string, mixed> $data |
| 101 | * @return self |
| 102 | */ |
| 103 | public static function fromArray(array $data): self |
| 104 | { |
| 105 | /** @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesRoots|null $roots */ |
| 106 | $roots = isset($data['roots']) |
| 107 | ? (is_array($data['roots']) |
| 108 | ? ClientCapabilitiesRoots::fromArray(self::asArray($data['roots'])) |
| 109 | : $data['roots']) |
| 110 | : null; |
| 111 | |
| 112 | /** @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesSampling|null $sampling */ |
| 113 | $sampling = isset($data['sampling']) |
| 114 | ? (is_array($data['sampling']) |
| 115 | ? ClientCapabilitiesSampling::fromArray(self::asArray($data['sampling'])) |
| 116 | : $data['sampling']) |
| 117 | : null; |
| 118 | |
| 119 | /** @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesElicitation|null $elicitation */ |
| 120 | $elicitation = isset($data['elicitation']) |
| 121 | ? (is_array($data['elicitation']) |
| 122 | ? ClientCapabilitiesElicitation::fromArray(self::asArray($data['elicitation'])) |
| 123 | : $data['elicitation']) |
| 124 | : null; |
| 125 | |
| 126 | /** @var \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesTasks|null $tasks */ |
| 127 | $tasks = isset($data['tasks']) |
| 128 | ? (is_array($data['tasks']) |
| 129 | ? ClientCapabilitiesTasks::fromArray(self::asArray($data['tasks'])) |
| 130 | : $data['tasks']) |
| 131 | : null; |
| 132 | |
| 133 | return new self( |
| 134 | self::asObjectMapOrNull($data['experimental'] ?? null), |
| 135 | $roots, |
| 136 | $sampling, |
| 137 | $elicitation, |
| 138 | $tasks |
| 139 | ); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Converts the instance to an array. |
| 144 | * |
| 145 | * @return array<string, mixed> |
| 146 | */ |
| 147 | public function toArray(): array |
| 148 | { |
| 149 | $result = []; |
| 150 | |
| 151 | if ($this->experimental !== null) { |
| 152 | $result['experimental'] = $this->experimental; |
| 153 | } |
| 154 | if ($this->roots !== null) { |
| 155 | $result['roots'] = $this->roots->toArray(); |
| 156 | } |
| 157 | if ($this->sampling !== null) { |
| 158 | $result['sampling'] = $this->sampling->toArray(); |
| 159 | } |
| 160 | if ($this->elicitation !== null) { |
| 161 | $result['elicitation'] = $this->elicitation->toArray(); |
| 162 | } |
| 163 | if ($this->tasks !== null) { |
| 164 | $result['tasks'] = $this->tasks->toArray(); |
| 165 | } |
| 166 | |
| 167 | return $result; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * @return array<string, object>|null |
| 172 | */ |
| 173 | public function getExperimental(): ?array |
| 174 | { |
| 175 | return $this->experimental; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * @return \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesRoots|null |
| 180 | */ |
| 181 | public function getRoots(): ?ClientCapabilitiesRoots |
| 182 | { |
| 183 | return $this->roots; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * @return \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesSampling|null |
| 188 | */ |
| 189 | public function getSampling(): ?ClientCapabilitiesSampling |
| 190 | { |
| 191 | return $this->sampling; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * @return \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesElicitation|null |
| 196 | */ |
| 197 | public function getElicitation(): ?ClientCapabilitiesElicitation |
| 198 | { |
| 199 | return $this->elicitation; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * @return \WP\McpSchema\Client\Lifecycle\DTO\ClientCapabilitiesTasks|null |
| 204 | */ |
| 205 | public function getTasks(): ?ClientCapabilitiesTasks |
| 206 | { |
| 207 | return $this->tasks; |
| 208 | } |
| 209 | } |
| 210 |