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\Request;
15:
16: use Nexus\Mcp\Schema\Enum\LoggingLevel;
17: use Nexus\Mcp\Schema\Message\JsonRpcRequest;
18: use Nexus\Mcp\Schema\Message\RequestId;
19:
20: /**
21: * A request from the client to the server, to enable or adjust logging.
22: *
23: * @extends JsonRpcRequest<array{
24: * jsonrpc: '2.0',
25: * id: int|non-empty-string,
26: * method: 'requests/setLevel',
27: * params: array{
28: * _meta?: array<string, mixed>,
29: * level: non-empty-string,
30: * }
31: * }>
32: */
33: final readonly class SetLevelRequest extends JsonRpcRequest implements ClientRequest
34: {
35: /**
36: * @param LoggingLevel $level The level of logging that the client wants to receive from the server.
37: * The server should send all logs at this level and higher (i.e., more
38: * severe) to the client as `notifications/message`.
39: * @param null|array<string, mixed> $meta Reserved by MCP to allow clients and servers to attach
40: * additional metadata to their interactions.
41: */
42: public function __construct(RequestId $id, LoggingLevel $level, ?array $meta = null)
43: {
44: parent::__construct(self::JSON_RPC_VERSION, $id, 'requests/setLevel', array_filter([
45: '_meta' => $meta,
46: 'level' => $level->value,
47: ], static fn(mixed $value): bool => null !== $value));
48: }
49: }
50: