|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +/* |
| 4 | + * This file is part of the API Platform project. |
| 5 | + * |
| 6 | + * (c) Kévin Dunglas <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +declare(strict_types=1); |
| 13 | + |
3 | 14 | /* |
4 | 15 | * This file is part of the official PHP MCP SDK. |
5 | 16 | * |
|
11 | 22 |
|
12 | 23 | namespace ApiPlatform\Mcp\Server; |
13 | 24 |
|
14 | | -use ApiPlatform\Mcp\State\ToolProvider; |
| 25 | +use ApiPlatform\Metadata\Exception\RuntimeException; |
| 26 | +use ApiPlatform\Metadata\HttpOperation; |
15 | 27 | use ApiPlatform\Metadata\Operation\Factory\OperationMetadataFactoryInterface; |
16 | 28 | use ApiPlatform\State\ProcessorInterface; |
17 | 29 | use ApiPlatform\State\ProviderInterface; |
18 | | -use Mcp\Capability\Registry\ReferenceHandlerInterface; |
19 | | -use Mcp\Capability\RegistryInterface; |
20 | | -use Mcp\Exception\ToolCallException; |
21 | | -use Mcp\Exception\ToolNotFoundException; |
22 | | -use Mcp\Schema\Content\TextContent; |
23 | 30 | use Mcp\Schema\JsonRpc\Error; |
24 | 31 | use Mcp\Schema\JsonRpc\Request; |
25 | 32 | use Mcp\Schema\JsonRpc\Response; |
@@ -64,6 +71,10 @@ public function handle(Request $request, SessionInterface $session): Response|Er |
64 | 71 |
|
65 | 72 | $operation = $this->operationMetadataFactory->create($toolName); |
66 | 73 |
|
| 74 | + if (!$operation instanceof HttpOperation) { |
| 75 | + throw new RuntimeException(\sprintf('Operation "%s" must be an instance of HttpOperation.', $toolName)); |
| 76 | + } |
| 77 | + |
67 | 78 | $uriVariables = []; |
68 | 79 | foreach ($operation->getUriVariables() ?? [] as $key => $link) { |
69 | 80 | if (isset($arguments[$key])) { |
|
0 commit comments