1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Core\Schema\Notification;
15:
16: use Nexus\Assert\Assert;
17: use Nexus\Mcp\Core\Schema\JsonRpc\JsonRpcNotification;
18: use Nexus\Mcp\Core\Schema\NotificationParams;
19: use Nexus\Mcp\Core\Schema\NotificationParams\SubscriptionsAcknowledgedNotificationParams;
20:
21: /**
22: * Sent by the server to acknowledge that a `subscriptions/listen` subscription has been
23: * established and to report which notification types it agreed to honor. This notification
24: * MUST be the first message the server sends carrying the subscription's ID in
25: * `io.modelcontextprotocol/subscriptionId`. The server MUST NOT send any notification on the
26: * subscription before acknowledging it. On stdio, where every subscription shares one channel,
27: * this ordering is defined per subscription ID and not per channel: messages belonging to other
28: * subscriptions MAY be interleaved before it.
29: *
30: * @property-read SubscriptionsAcknowledgedNotificationParams $params
31: *
32: * @extends JsonRpcNotification<'notifications/subscriptions/acknowledged', array{
33: * jsonrpc: '2.0',
34: * method: 'notifications/subscriptions/acknowledged',
35: * params: template-type<SubscriptionsAcknowledgedNotificationParams, NotificationParams, 'T'>,
36: * }>
37: *
38: * @see https://modelcontextprotocol.io/specification/2026-07-28/schema#subscriptionsacknowledgednotification
39: */
40: final readonly class SubscriptionsAcknowledgedNotification extends JsonRpcNotification implements ServerNotification
41: {
42: public function __construct(SubscriptionsAcknowledgedNotificationParams $params)
43: {
44: parent::__construct(params: $params);
45: }
46:
47: #[\Override]
48: public static function getMethod(): string
49: {
50: return 'notifications/subscriptions/acknowledged';
51: }
52:
53: #[\Override]
54: public static function fromArray(array $data): static
55: {
56: Assert::that($data)->hasOffset('params', 'missing the required "params" key.');
57: Assert::that($data['params'])
58: ->isArray('"params" must be an object, {type} given.')
59: ->isMap('"params" must be a string-keyed object.')
60: ;
61:
62: return new self(params: SubscriptionsAcknowledgedNotificationParams::fromArray($data['params']));
63: }
64:
65: #[\Override]
66: public function toArray(): array
67: {
68: return [
69: 'jsonrpc' => self::JSONRPC_VERSION,
70: 'method' => static::getMethod(),
71: 'params' => $this->params->toArray(),
72: ];
73: }
74: }
75: