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\EmptyNotificationParams;
19:
20: /**
21: * An optional notification from the server to the client, informing it that the list of
22: * resources it can read from has changed. This may be issued by servers without any previous
23: * subscription from the client.
24: *
25: * @extends JsonRpcNotification<'notifications/resources/list_changed'>
26: *
27: * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#resourcelistchangednotification
28: */
29: final readonly class ResourceListChangedNotification extends JsonRpcNotification implements ServerNotification
30: {
31: #[\Override]
32: public static function getMethod(): string
33: {
34: return 'notifications/resources/list_changed';
35: }
36:
37: #[\Override]
38: public static function fromArray(array $data): static
39: {
40: $params = new EmptyNotificationParams();
41:
42: if (\array_key_exists('params', $data)) {
43: Assert::that($data['params'])
44: ->isArray('"params" must be an object, {type} given.')
45: ->isMap('"params" must be a string-keyed object.')
46: ;
47: $params = EmptyNotificationParams::fromArray($data['params']);
48: }
49:
50: return new self($params);
51: }
52: }
53: