22
33declare (strict_types=1 );
44
5- namespace PhpMcp \Server \ Support ;
5+ namespace PhpMcp \Server ;
66
77use JsonException ;
88use PhpMcp \Schema \JsonRpc \Request ;
3939use PhpMcp \Server \Protocol ;
4040use PhpMcp \Server \Registry ;
4141use PhpMcp \Server \Session \SubscriptionManager ;
42+ use PhpMcp \Server \Support \SchemaValidator ;
4243use PhpMcp \Server \Traits \ResponseFormatter ;
4344use Psr \Container \ContainerInterface ;
4445use Psr \Log \LoggerInterface ;
4546use Throwable ;
4647
47- class RequestHandler
48+ class Dispatcher
4849{
4950 use ResponseFormatter;
5051
@@ -159,7 +160,7 @@ public function handleToolCall(CallToolRequest $request): CallToolResult
159160 $ toolName = $ request ->name ;
160161 $ arguments = $ request ->arguments ;
161162
162- ['tool ' => $ tool , 'invoker ' => $ invoker ] = $ this ->registry ->getTool ($ toolName );
163+ ['tool ' => $ tool , 'handler ' => $ handler ] = $ this ->registry ->getTool ($ toolName );
163164 if (! $ tool ) {
164165 throw McpServerException::methodNotFound ("Tool ' {$ toolName }' not found. " );
165166 }
@@ -187,7 +188,7 @@ public function handleToolCall(CallToolRequest $request): CallToolResult
187188 }
188189
189190 try {
190- $ result = $ invoker -> invoke ($ this ->container , $ arguments );
191+ $ result = $ handler -> handle ($ this ->container , $ arguments );
191192 $ formattedResult = $ this ->formatToolResult ($ result );
192193
193194 return new CallToolResult ($ formattedResult , false );
@@ -230,15 +231,15 @@ public function handleResourceRead(ReadResourceRequest $request): ReadResourceRe
230231 {
231232 $ uri = $ request ->uri ;
232233
233- ['resource ' => $ resource , 'invoker ' => $ invoker , 'variables ' => $ uriVariables ] = $ this ->registry ->getResource ($ uri );
234+ ['resource ' => $ resource , 'handler ' => $ handler , 'variables ' => $ uriVariables ] = $ this ->registry ->getResource ($ uri );
234235
235236 if (! $ resource ) {
236237 throw McpServerException::invalidParams ("Resource URI ' {$ uri }' not found. " );
237238 }
238239
239240 try {
240241 $ arguments = array_merge ($ uriVariables , ['uri ' => $ uri ]);
241- $ result = $ invoker -> invoke ($ this ->container , $ arguments );
242+ $ result = $ handler -> handle ($ this ->container , $ arguments );
242243 $ contents = $ this ->formatResourceContents ($ result , $ uri , $ resource ->mimeType );
243244
244245 return new ReadResourceResult ($ contents );
@@ -281,7 +282,7 @@ public function handlePromptGet(GetPromptRequest $request): GetPromptResult
281282 $ promptName = $ request ->name ;
282283 $ arguments = $ request ->arguments ;
283284
284- ['prompt ' => $ prompt , 'invoker ' => $ invoker ] = $ this ->registry ->getPrompt ($ promptName );
285+ ['prompt ' => $ prompt , 'handler ' => $ handler ] = $ this ->registry ->getPrompt ($ promptName );
285286 if (! $ prompt ) {
286287 throw McpServerException::invalidParams ("Prompt ' {$ promptName }' not found. " );
287288 }
@@ -295,7 +296,7 @@ public function handlePromptGet(GetPromptRequest $request): GetPromptResult
295296 }
296297
297298 try {
298- $ result = $ invoker -> invoke ($ this ->container , $ arguments );
299+ $ result = $ handler -> handle ($ this ->container , $ arguments );
299300 $ messages = $ this ->formatPromptMessages ($ result );
300301
301302 return new GetPromptResult ($ messages , $ prompt ->description );
0 commit comments