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\LoggingMessageNotificationParams;
19:
20: /**
21: * JSONRPCNotification of a log message passed from server to client. If no logging/setLevel request has been
22: * sent from the client, the server MAY decide which messages to send automatically.
23: *
24: * @property-read LoggingMessageNotificationParams $params
25: *
26: * @extends JsonRpcNotification<'notifications/message'>
27: *
28: * @see https://modelcontextprotocol.io/specification/2025-11-25/schema#loggingmessagenotification
29: */
30: final readonly class LoggingMessageNotification extends JsonRpcNotification implements ServerNotification
31: {
32: public function __construct(LoggingMessageNotificationParams $params)
33: {
34: parent::__construct($params);
35: }
36:
37: #[\Override]
38: public static function getMethod(): string
39: {
40: return 'notifications/message';
41: }
42:
43: #[\Override]
44: public static function fromArray(array $data): static
45: {
46: Assert::that($data)->hasOffset('params', 'missing the required "params" key.');
47: Assert::that($data['params'])
48: ->isArray('"params" must be an object, {type} given.')
49: ->isMap('"params" must be a string-keyed object.')
50: ;
51:
52: return new self(LoggingMessageNotificationParams::fromArray($data['params']));
53: }
54: }
55: