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\Server\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\Request\GetPromptRequest;
20: use Nexus\Mcp\Core\Schema\Result\GetPromptResult;
21: use Nexus\Mcp\Core\Schema\Result\InputRequiredResult;
22: use Nexus\Mcp\Server\Prompt\PromptStoreInterface;
23: use Nexus\Mcp\Server\ServerContext;
24:
25: /**
26: * Handles the `prompts/get` request by delegating to a `PromptStoreInterface`.
27: *
28: * @implements RequestHandlerInterface<'prompts/get', GetPromptResult|InputRequiredResult, ServerContext>
29: */
30: final readonly class GetPromptRequestHandler implements RequestHandlerInterface
31: {
32: public function __construct(private PromptStoreInterface $store)
33: {
34: }
35:
36: #[\Override]
37: public function handle(JsonRpcRequest $request, AbstractContext $context): GetPromptResult|InputRequiredResult
38: {
39: \assert($request instanceof GetPromptRequest);
40: \assert($context instanceof ServerContext);
41:
42: return $this->store->get($request->params->name, $request->params->arguments, $context);
43: }
44: }
45: