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\ResourceUpdatedNotificationParams;
19:
20: /**
21: * A notification from the server to the client, informing it that a resource has changed and
22: * may need to be read again. This should only be sent if the client previously sent a
23: * resources/subscribe request.
24: *
25: * @extends JsonRpcNotification<'notifications/resources/updated'>
26: *
27: * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#resourceupdatednotification
28: */
29: final readonly class ResourceUpdatedNotification extends JsonRpcNotification implements ServerNotification
30: {
31: public function __construct(ResourceUpdatedNotificationParams $params)
32: {
33: parent::__construct($params);
34: }
35:
36: #[\Override]
37: public static function getMethod(): string
38: {
39: return 'notifications/resources/updated';
40: }
41:
42: #[\Override]
43: public static function fromArray(array $data): static
44: {
45: Assert::that($data)->hasOffset('params', 'missing the required "params" key.');
46: Assert::that($data['params'])
47: ->isArray('"params" must be an object, {type} given.')
48: ->isMap('"params" must be a string-keyed object.')
49: ;
50:
51: return new self(ResourceUpdatedNotificationParams::fromArray($data['params']));
52: }
53: }
54: