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\CompleteRequest;
20: use Nexus\Mcp\Core\Schema\Result\CompleteResult;
21: use Nexus\Mcp\Server\Completion\CompletionStoreInterface;
22: use Nexus\Mcp\Server\ServerContext;
23:
24: /**
25: * Handles the `completion/complete` request by delegating to a `CompletionStoreInterface`.
26: *
27: * @implements RequestHandlerInterface<'completion/complete', CompleteResult, ServerContext>
28: */
29: final readonly class CompleteRequestHandler implements RequestHandlerInterface
30: {
31: public function __construct(private CompletionStoreInterface $store)
32: {
33: }
34:
35: #[\Override]
36: public function handle(JsonRpcRequest $request, AbstractContext $context): CompleteResult
37: {
38: \assert($request instanceof CompleteRequest);
39:
40: $params = $request->params;
41:
42: return $this->store->complete(
43: $params->ref,
44: $params->argument['name'],
45: $params->argument['value'],
46: $params->context['arguments'] ?? null,
47: $context,
48: );
49: }
50: }
51: