| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | /** |
| 6: | * This file is part of the Nexus MCP SDK package. |
| 7: | * |
| 8: | * (c) 2025 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\Schema\Notification; |
| 15: | |
| 16: | use Nexus\Mcp\Schema\Message\JsonRpcNotification; |
| 17: | |
| 18: | /** |
| 19: | * A notification from the server to the client, informing it that a resource has changed |
| 20: | * and may need to be read again. This should only be sent if the client previously sent a |
| 21: | * `resources/subscribe` request. |
| 22: | * |
| 23: | * @extends JsonRpcNotification<array{ |
| 24: | * jsonrpc: '2.0', |
| 25: | * method: 'notifications/resources/updated', |
| 26: | * params: array{ |
| 27: | * _meta?: array<string, mixed>, |
| 28: | * uri: non-empty-string, |
| 29: | * } |
| 30: | * }> |
| 31: | */ |
| 32: | final readonly class ResourceUpdatedNotification extends JsonRpcNotification implements ServerNotification |
| 33: | { |
| 34: | /** |
| 35: | * @param non-empty-string $uri The URI of the resource that has been updated. |
| 36: | * This might be a sub-resource of the one that the client actually subscribed to. |
| 37: | * @param null|array<string, mixed> $meta Reserved by MCP to allow clients and servers to attach |
| 38: | * additional metadata to their interactions. |
| 39: | */ |
| 40: | public function __construct(string $uri, ?array $meta = null) |
| 41: | { |
| 42: | parent::__construct(self::JSON_RPC_VERSION, 'notifications/resources/updated', array_filter([ |
| 43: | '_meta' => $meta, |
| 44: | 'uri' => $uri, |
| 45: | ], static fn(mixed $value): bool => null !== $value)); |
| 46: | } |
| 47: | } |
| 48: |