{"record":{"id":"d428c43ce13cef21","repo":"conductor-oss/conductor","slug":"error","errorCode":null,"errorMessage":"{error}","messagePattern":"\\{error\\}","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java","lineNumber":263,"sourceCode":"                                response.statusCode, response.body));\n            }\n\n            // Get response body and content type\n            String responseBody = response.body;\n            String contentType = response.contentType;\n\n            // Parse response based on content type\n            JsonNode responseJson;\n            if (contentType != null && contentType.contains(\"text/event-stream\")) {\n                // Parse SSE format\n                responseJson = parseSseResponse(responseBody);\n            } else {\n                // Parse as JSON directly\n                responseJson = objectMapper.readTree(responseBody);\n            }\n\n            if (responseJson.has(\"error\")) {\n                throw new RuntimeException(responseJson.get(\"error\").toString());\n            }\n\n            if (!responseJson.has(\"result\")) {\n                throw new RuntimeException(\"Invalid JSON-RPC response: missing 'result' field\");\n            }\n\n            JsonNode resultNode = responseJson.get(\"result\");\n\n            // Process the result JSON to parse text content as JSON where applicable\n            processResultJson(resultNode);\n\n            // Return as Map to preserve parsed field\n            Map<String, Object> result = objectMapper.convertValue(resultNode, Map.class);\n            ExternalDataLimits.validateStructure(result);\n\n            log.debug(\n                    \"Successfully called tool '{}' via direct JSON-RPC on {}\", toolName, serverUrl);\n            return result;","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java#L245-L281","documentation":"Thrown by callToolDirectHttp when the parsed JSON-RPC response contains an `error` field. Unlike error 161 (which prefixes with 'JSON-RPC error: '), this throw uses ONLY the error object's toString() as the message — so the exception message is the raw JSON-RPC error object stringified, with no label. This is the protocol-level failure for tools/call (e.g. tool not found, invalid arguments, or the tool itself returned an MCP error).","triggerScenarios":"Calling a toolName the server does not expose (-32602 invalid params / unknown tool); arguments that fail the tool's input schema; the tool raised an MCP-level error (isError result or a server-reported error object); session not initialized so tools/call is rejected.","commonSituations":"Tool name typo or tool disabled server-side; arguments don't match the tool's JSON schema; server enforces initialize before tools/call.","solutions":["Parse the embedded error.code/message from the exception string to classify it.","Confirm toolName is in the listTools() output for that server.","Validate arguments against the tool's inputSchema before calling.","If the server requires initialize, use a client that performs the handshake."],"exampleFix":"// before\nMap<String,Object> r = mcpService.callTool(url, name, args, headers);\n// after\nList<McpSchema.Tool> tools = mcpService.listTools(url, headers);\nboolean exists = tools.stream().anyMatch(t -> t.name().equals(name));\nif (!exists) throw new IllegalArgumentException(\"Unknown MCP tool: \" + name);\nMap<String,Object> r = mcpService.callTool(url, name, args, headers);","handlingStrategy":"validation","validationCode":"// Validate arguments against the tool's inputSchema before calling.\nList<McpSchema.Tool> tools = mcpService.listTools(serverUrl, headers);\nMcpSchema.Tool tool = tools.stream().filter(t -> t.name().equals(toolName)).findFirst()\n    .orElseThrow(() -> new IllegalArgumentException(\"Unknown tool: \" + toolName));\n// schema-validate `arguments` against tool.inputSchema() here","typeGuard":null,"tryCatchPattern":"try {\n    Map<String,Object> r = mcpService.callTool(serverUrl, toolName, arguments, headers);\n} catch (RuntimeException e) {\n    // e.getMessage() is the RAW error object string (no prefix); parse it for code/message.\n    throw e;\n}","preventionTips":["Remember this exception message has NO prefix — it is the raw JSON-RPC error object.","Validate arguments against the tool schema before calling to avoid invalid-params errors.","Confirm the tool name via listTools first."],"tags":["mcp","json-rpc","protocol-error","tool-call"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}