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\Message\JsonRpcRequest;
17: use Nexus\Mcp\Schema\Message\RequestId;
18:
19: /**
20: * A ping, issued by either the server or the client, to check that the other party is still alive.
21: * The receiver must promptly respond, or else may be disconnected.
22: *
23: * @extends JsonRpcRequest<array{
24: * jsonrpc: '2.0',
25: * id: int|non-empty-string,
26: * method: 'ping',
27: * params?: array{
28: * _meta?: array<string, mixed>,
29: * }
30: * }>
31: */
32: final readonly class PingRequest extends JsonRpcRequest implements ClientRequest, ServerRequest
33: {
34: /**
35: * @param null|array<string, mixed> $meta Reserved by MCP to allow clients and servers to attach
36: * additional metadata to their interactions.
37: */
38: public function __construct(RequestId $id, ?array $meta = null)
39: {
40: $params = isset($meta) ? ['_meta' => $meta] : null;
41:
42: parent::__construct(self::JSON_RPC_VERSION, $id, 'ping', $params);
43: }
44: }
45: