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\Handler\Request;
15:
16: use Nexus\Mcp\Core\Handler\AbstractContext;
17: use Nexus\Mcp\Core\Handler\RequestHandlerInterface;
18: use Nexus\Mcp\Core\Schema\JsonRpc\JsonRpcRequest;
19: use Nexus\Mcp\Core\Schema\MetaObject;
20: use Nexus\Mcp\Core\Schema\Result\EmptyResult;
21:
22: /**
23: * Acknowledges a `ping` with an empty result. Bidirectional per spec: both
24: * server and client register this handler.
25: *
26: * @implements RequestHandlerInterface<'ping', EmptyResult, AbstractContext>
27: */
28: final readonly class PingRequestHandler implements RequestHandlerInterface
29: {
30: public function __construct(private MetaObject $meta = new MetaObject())
31: {
32: }
33:
34: #[\Override]
35: public function handle(JsonRpcRequest $request, AbstractContext $context): EmptyResult
36: {
37: return new EmptyResult($this->meta);
38: }
39: }
40: