Fix tools/call routing - avoid recursive calls and variable name conflicts
Showing
1 changed file
with
9 additions
and
3 deletions
| ... | @@ -169,11 +169,17 @@ | ... | @@ -169,11 +169,17 @@ |
| 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 | ec.logger.info("MCP ToolsCall: Routing tools/call with name '${actualToolName}' to ${actualTargetServiceName}") | ||
| 176 | return ec.service.sync().name(actualTargetServiceName) | ||
| 177 | .parameters(actualArguments ?: [:]) | ||
| 175 | .call() | 178 | .call() |
| 176 | } else { | 179 | } else { |
| 180 | throw new Exception("Unknown tool name: ${actualToolName}") | ||
| 181 | } | ||
| 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) |
| 179 | .parameters(arguments ?: [:]) | 185 | .parameters(arguments ?: [:]) | ... | ... |
-
Please register or sign in to post a comment