From 8df2b4704a6aac0517a3a032d14dcc54f97e61ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alptekin=20G=C3=BClcan?= <5773704+alpgul@users.noreply.github.com> Date: Wed, 12 Nov 2025 04:13:50 +0300 Subject: [PATCH] Fix: Handle ToolName in CallToolRequest to Resolve Server Discovery Issues (#429) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/controllers/openApiController.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/openApiController.ts b/src/controllers/openApiController.ts index 49c38bd..224d336 100644 --- a/src/controllers/openApiController.ts +++ b/src/controllers/openApiController.ts @@ -100,7 +100,7 @@ export const executeToolViaOpenAPI = async (req: Request, res: Response): Promis try { // Decode URL-encoded parameters to handle slashes in server/tool names const serverName = decodeURIComponent(req.params.serverName); - const toolName = decodeURIComponent(req.params.toolName); + let toolName = decodeURIComponent(req.params.toolName); // Import handleCallToolRequest function const { handleCallToolRequest } = await import('../services/mcpService.js'); @@ -115,8 +115,11 @@ export const executeToolViaOpenAPI = async (req: Request, res: Response): Promis const tool = serverInfo.tools.find( (t: any) => t.name === fullToolName || t.name === toolName, ); - if (tool && tool.inputSchema) { - inputSchema = tool.inputSchema as Record; + if (tool) { + toolName = tool.name; // Use the matched tool's actual name (with server prefix if applicable) for the subsequent call to handleCallToolRequest. + if (tool.inputSchema) { + inputSchema = tool.inputSchema as Record; + } } }