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\TaskStatusNotificationParams;
19:
20: /**
21: * An optional notification from the receiver to the requestor, informing them
22: * that a task's status has changed. Receivers are not required to send these
23: * notifications.
24: *
25: * @extends JsonRpcNotification<'notifications/tasks/status'>
26: *
27: * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#taskstatusnotification
28: */
29: final readonly class TaskStatusNotification extends JsonRpcNotification implements ClientNotification, ServerNotification
30: {
31: public function __construct(TaskStatusNotificationParams $params)
32: {
33: parent::__construct($params);
34: }
35:
36: #[\Override]
37: public static function getMethod(): string
38: {
39: return 'notifications/tasks/status';
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(TaskStatusNotificationParams::fromArray($data['params']));
52: }
53: }
54: