forked from modelcontextprotocol/php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPingHandler.php
More file actions
37 lines (31 loc) · 1021 Bytes
/
PingHandler.php
File metadata and controls
37 lines (31 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Server\Handler\Request;
use Mcp\Schema\JsonRpc\HasMethodInterface;
use Mcp\Schema\JsonRpc\Response;
use Mcp\Schema\Request\PingRequest;
use Mcp\Schema\Result\EmptyResult;
use Mcp\Server\Handler\MethodHandlerInterface;
use Mcp\Server\Session\SessionInterface;
/**
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
final class PingHandler implements MethodHandlerInterface
{
public function supports(HasMethodInterface $message): bool
{
return $message instanceof PingRequest;
}
public function handle(PingRequest|HasMethodInterface $message, SessionInterface $session): Response
{
\assert($message instanceof PingRequest);
return new Response($message->getId(), new EmptyResult());
}
}