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 / Tools / DTO / ToolExecution.php

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

94 lines 2.2 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\Tools\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Execution-related properties for a tool.
12 *
13 * @since 2025-11-25
14 *
15 * @mcp-domain Server
16 * @mcp-subdomain Tools
17 * @mcp-version 2025-11-25
18 */
19 class ToolExecution extends AbstractDataTransferObject
20 {
21 use ValidatesRequiredFields;
22
23 /**
24 * Indicates whether this tool supports task-augmented execution.
25 * This allows clients to handle long-running operations through polling
26 * the task system.
27 *
28 * - "forbidden": Tool does not support task-augmented execution (default when absent)
29 * - "optional": Tool may support task-augmented execution
30 * - "required": Tool requires task-augmented execution
31 *
32 * Default: "forbidden"
33 *
34 * @since 2025-11-25
35 *
36 * @var 'forbidden'|'optional'|'required'|null
37 */
38 protected ?string $taskSupport;
39
40 /**
41 * @param 'forbidden'|'optional'|'required'|null $taskSupport @since 2025-11-25
42 */
43 public function __construct(
44 ?string $taskSupport = null
45 ) {
46 $this->taskSupport = $taskSupport;
47 }
48
49 /**
50 * Creates an instance from an array.
51 *
52 * @param array{
53 * taskSupport?: 'forbidden'|'optional'|'required'|null
54 * } $data
55 * @phpstan-param array<string, mixed> $data
56 * @return self
57 */
58 public static function fromArray(array $data): self
59 {
60 /** @var 'forbidden'|'optional'|'required'|null $taskSupport */
61 $taskSupport = isset($data['taskSupport'])
62 ? self::asStringOrNull($data['taskSupport'])
63 : null;
64
65 return new self(
66 $taskSupport
67 );
68 }
69
70 /**
71 * Converts the instance to an array.
72 *
73 * @return array<string, mixed>
74 */
75 public function toArray(): array
76 {
77 $result = [];
78
79 if ($this->taskSupport !== null) {
80 $result['taskSupport'] = $this->taskSupport;
81 }
82
83 return $result;
84 }
85
86 /**
87 * @return 'forbidden'|'optional'|'required'|null
88 */
89 public function getTaskSupport(): ?string
90 {
91 return $this->taskSupport;
92 }
93 }
94