| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Server\Handler\Request; |
| 15: | |
| 16: | use Nexus\Mcp\Core\Handler\AbstractContext; |
| 17: | use Nexus\Mcp\Core\Handler\RequestHandlerInterface; |
| 18: | use Nexus\Mcp\Core\Schema\Enum\CacheScope; |
| 19: | use Nexus\Mcp\Core\Schema\Implementation; |
| 20: | use Nexus\Mcp\Core\Schema\JsonRpc\JsonRpcRequest; |
| 21: | use Nexus\Mcp\Core\Schema\MetaObject; |
| 22: | use Nexus\Mcp\Core\Schema\ProtocolVersion; |
| 23: | use Nexus\Mcp\Core\Schema\Result\DiscoverResult; |
| 24: | use Nexus\Mcp\Core\Schema\ServerCapabilities; |
| 25: | use Nexus\Mcp\Server\ServerContext; |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | final readonly class DiscoverRequestHandler implements RequestHandlerInterface |
| 34: | { |
| 35: | |
| 36: | |
| 37: | |
| 38: | public function __construct( |
| 39: | private Implementation $serverInfo, |
| 40: | private ServerCapabilities $capabilities, |
| 41: | private ?string $instructions = null, |
| 42: | private int $ttlMs = 0, |
| 43: | private CacheScope $cacheScope = CacheScope::Private, |
| 44: | private MetaObject $meta = new MetaObject(), |
| 45: | ) { |
| 46: | } |
| 47: | |
| 48: | #[\Override] |
| 49: | public function handle(JsonRpcRequest $request, AbstractContext $context): DiscoverResult |
| 50: | { |
| 51: | return new DiscoverResult( |
| 52: | supportedVersions: ProtocolVersion::SUPPORTED_VERSIONS, |
| 53: | capabilities: $this->capabilities, |
| 54: | serverInfo: $this->serverInfo, |
| 55: | ttlMs: $this->ttlMs, |
| 56: | cacheScope: $this->cacheScope, |
| 57: | instructions: $this->instructions, |
| 58: | meta: $this->meta, |
| 59: | ); |
| 60: | } |
| 61: | } |
| 62: | |