|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App; |
| 4 | + |
| 5 | +use App\Manager\PromptManager; |
| 6 | +use App\Manager\ResourceManager; |
| 7 | +use App\Manager\ToolManager; |
| 8 | +use PhpLlm\McpSdk\Server\NotificationHandler; |
| 9 | +use PhpLlm\McpSdk\Server\NotificationHandler\InitializedHandler; |
| 10 | +use PhpLlm\McpSdk\Server\RequestHandler; |
| 11 | +use PhpLlm\McpSdk\Server\RequestHandler\InitializeHandler; |
| 12 | +use PhpLlm\McpSdk\Server\RequestHandler\PingHandler; |
| 13 | +use PhpLlm\McpSdk\Server\RequestHandler\PromptGetHandler; |
| 14 | +use PhpLlm\McpSdk\Server\RequestHandler\PromptListHandler; |
| 15 | +use PhpLlm\McpSdk\Server\RequestHandler\ResourceListHandler; |
| 16 | +use PhpLlm\McpSdk\Server\RequestHandler\ResourceReadHandler; |
| 17 | +use PhpLlm\McpSdk\Server\RequestHandler\ToolCallHandler; |
| 18 | +use PhpLlm\McpSdk\Server\RequestHandler\ToolListHandler; |
| 19 | + |
| 20 | +class Builder |
| 21 | +{ |
| 22 | + /** |
| 23 | + * @return list<RequestHandler> |
| 24 | + */ |
| 25 | + public static function buildRequestHandlers(): array |
| 26 | + { |
| 27 | + $promptManager = new PromptManager(); |
| 28 | + $resourceManager = new ResourceManager(); |
| 29 | + $toolManager = new ToolManager(); |
| 30 | + |
| 31 | + return [ |
| 32 | + new InitializeHandler(), |
| 33 | + new PingHandler(), |
| 34 | + new PromptListHandler($promptManager), |
| 35 | + new PromptGetHandler($promptManager), |
| 36 | + new ResourceListHandler($resourceManager), |
| 37 | + new ResourceReadHandler($resourceManager), |
| 38 | + new ToolCallHandler($toolManager), |
| 39 | + new ToolListHandler($toolManager), |
| 40 | + ]; |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * @return list<NotificationHandler> |
| 45 | + */ |
| 46 | + public static function buildNotificationHandlers(): array |
| 47 | + { |
| 48 | + return [ |
| 49 | + new InitializedHandler(), |
| 50 | + ]; |
| 51 | + } |
| 52 | +} |
0 commit comments