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\ProgressNotificationParams;
19:
20: /**
21: * An out-of-band notification used to inform the receiver of a progress update for a long-running request.
22: *
23: * @property-read ProgressNotificationParams $params
24: *
25: * @extends JsonRpcNotification<'notifications/progress'>
26: *
27: * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#progressnotification
28: */
29: final readonly class ProgressNotification extends JsonRpcNotification implements ClientNotification, ServerNotification
30: {
31: public function __construct(ProgressNotificationParams $params)
32: {
33: parent::__construct($params);
34: }
35:
36: #[\Override]
37: public static function getMethod(): string
38: {
39: return 'notifications/progress';
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(ProgressNotificationParams::fromArray($data['params']));
52: }
53: }
54: