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