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 / Client / Elicitation / DTO / ElicitRequest.php
commercebird / vendor / wordpress / php-mcp-schema / src / Client / Elicitation / DTO Last commit date
BooleanSchema.php 3 months ago ElicitRequest.php 3 months ago ElicitRequestFormParams.php 3 months ago ElicitRequestFormParamsRequestedSchema.php 3 months ago ElicitRequestURLParams.php 3 months ago ElicitResult.php 3 months ago ElicitationCompleteNotification.php 3 months ago ElicitationCompleteNotificationParams.php 3 months ago LegacyTitledEnumSchema.php 3 months ago NumberSchema.php 3 months ago StringSchema.php 3 months ago TitledMultiSelectEnumSchema.php 3 months ago TitledMultiSelectEnumSchemaItems.php 3 months ago TitledSingleSelectEnumSchema.php 3 months ago UntitledMultiSelectEnumSchema.php 3 months ago UntitledMultiSelectEnumSchemaItems.php 3 months ago UntitledSingleSelectEnumSchema.php 3 months ago
ElicitRequest.php
107 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Client\Elicitation\DTO;
6
7 use WP\McpSchema\Client\Elicitation\Factory\ElicitRequestParamsFactory;
8 use WP\McpSchema\Client\Elicitation\Union\ElicitRequestParamsInterface;
9 use WP\McpSchema\Common\JsonRpc\DTO\JSONRPCRequest;
10 use WP\McpSchema\Common\Protocol\Union\ServerRequestInterface;
11 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
12
13 /**
14 * A request from the server to elicit additional information from the user via the client.
15 *
16 * @since 2025-06-18
17 * @last-updated 2025-11-25 (modified property: params)
18 *
19 * @mcp-domain Client
20 * @mcp-subdomain Elicitation
21 * @mcp-version 2025-11-25
22 */
23 class ElicitRequest extends JSONRPCRequest implements ServerRequestInterface
24 {
25 use ValidatesRequiredFields;
26
27 public const METHOD = 'elicitation/create';
28
29 public const DISCRIMINATOR_FIELD = 'method';
30 public const DISCRIMINATOR_VALUE = 'elicitation/create';
31
32 /**
33 * @var \WP\McpSchema\Client\Elicitation\Union\ElicitRequestParamsInterface
34 */
35 protected ElicitRequestParamsInterface $typedParams;
36
37 /**
38 * @param '2.0' $jsonrpc @since 2025-11-25
39 * @param string|number $id @since 2025-11-25
40 * @param \WP\McpSchema\Client\Elicitation\Union\ElicitRequestParamsInterface $params @since 2025-06-18
41 */
42 public function __construct(
43 string $jsonrpc,
44 $id,
45 ElicitRequestParamsInterface $params
46 ) {
47 parent::__construct(self::METHOD, $jsonrpc, $id, null);
48 $this->typedParams = $params;
49 }
50
51 /**
52 * Creates an instance from an array.
53 *
54 * @param array{
55 * jsonrpc: '2.0',
56 * id: string|number,
57 * method: 'elicitation/create',
58 * params: array<string, mixed>|\WP\McpSchema\Client\Elicitation\Union\ElicitRequestParamsInterface
59 * } $data
60 * @phpstan-param array<string, mixed> $data
61 * @return self
62 */
63 public static function fromArray(array $data): self
64 {
65 self::assertRequired($data, ['jsonrpc', 'id', 'params']);
66
67 /** @var '2.0' $jsonrpc */
68 $jsonrpc = self::asString($data['jsonrpc']);
69
70 /** @var string|number $id */
71 $id = self::asStringOrNumber($data['id']);
72
73 /** @var \WP\McpSchema\Client\Elicitation\Union\ElicitRequestParamsInterface $params */
74 $params = is_array($data['params'])
75 ? ElicitRequestParamsFactory::fromArray(self::asArray($data['params']))
76 : $data['params'];
77
78 return new self(
79 $jsonrpc,
80 $id,
81 $params
82 );
83 }
84
85 /**
86 * Converts the instance to an array.
87 *
88 * @return array<string, mixed>
89 */
90 public function toArray(): array
91 {
92 $result = parent::toArray();
93
94 $result['params'] = $this->typedParams->toArray();
95
96 return $result;
97 }
98
99 /**
100 * @return \WP\McpSchema\Client\Elicitation\Union\ElicitRequestParamsInterface
101 */
102 public function getTypedParams(): ElicitRequestParamsInterface
103 {
104 return $this->typedParams;
105 }
106 }
107