93d60083 by Ean Schuessler

Fix tools/call routing - avoid recursive calls and variable name conflicts

1 parent 3829e3be
...@@ -169,10 +169,16 @@ ...@@ -169,10 +169,16 @@
169 actualArguments = [sessionId: sessionId] 169 actualArguments = [sessionId: sessionId]
170 } 170 }
171 171
172 // Recursively call the actual tool 172 // Route to the actual tool service, not recursive ToolsCall
173 return ec.service.sync().name("McpServices.mcp#ToolsCall") 173 def actualTargetServiceName = protocolMethodMappings[actualToolName]
174 .parameters([sessionId: sessionId, name: actualToolName, arguments: actualArguments]) 174 if (actualTargetServiceName) {
175 .call() 175 ec.logger.info("MCP ToolsCall: Routing tools/call with name '${actualToolName}' to ${actualTargetServiceName}")
176 return ec.service.sync().name(actualTargetServiceName)
177 .parameters(actualArguments ?: [:])
178 .call()
179 } else {
180 throw new Exception("Unknown tool name: ${actualToolName}")
181 }
176 } else { 182 } else {
177 // For other protocol methods, call the target service with provided arguments 183 // For other protocol methods, call the target service with provided arguments
178 def serviceResult = ec.service.sync().name(targetServiceName) 184 def serviceResult = ec.service.sync().name(targetServiceName)
......