{"record":{"id":"51da8b0982c6b70e","repo":"conductor-oss/conductor","slug":"json-rpc-error-error","errorCode":null,"errorMessage":"JSON-RPC error: {error}","messagePattern":"JSON-RPC error: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java","lineNumber":149,"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(\n                        \"JSON-RPC error: \" + 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 result = responseJson.get(\"result\");\n            JsonNode toolsNode = result.get(\"tools\");\n\n            if (toolsNode == null || !toolsNode.isArray()) {\n                throw new RuntimeException(\n                        \"Invalid response: 'tools' field is missing or not an array\");\n            }\n            ExternalDataLimits.validateStructure(objectMapper.convertValue(result, Object.class));\n\n            // Convert to McpSchema.Tool list\n            // Use Jackson to deserialize tools directly (same pattern as stdio implementation)","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java#L131-L167","documentation":"Thrown by listToolsDirectHttp when the parsed JSON-RPC response contains an `error` field. JSON-RPC 2.0 uses an error object {code, message, data} for protocol-level failures (e.g. -32601 Method not found, -32602 Invalid params, -32700 Parse error). The thrown message embeds the whole error object's toString().","triggerScenarios":"Calling listTools against a server that does not implement tools/list (returns -32601 method not found); sending a malformed id or params that the server rejects as -32602; a server that requires an initialized session id and returns -32000 because initialize was never called.","commonSituations":"Server is an older/other protocol that ignores tools/list; session negotiation was skipped; server enforces a capability negotiation (initialize) that this client bypasses by using direct JSON-RPC.","solutions":["Read the embedded error.code in the message to classify (-32601 => server lacks tools/list; -32xxx => protocol/session problem).","If the server needs initialization, switch to an MCP client transport that performs initialize/initialized first.","Confirm the server actually advertises the tools capability in its initialize response.","Check the server version supports tools/list with the exact param shape sent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    List<McpSchema.Tool> tools = mcpService.listTools(serverUrl, headers);\n} catch (RuntimeException e) {\n    // e.getMessage() starts with 'JSON-RPC error: ' followed by the error object.\n    // Parse code (-32601 method not found, -32602 invalid params) to decide handling.\n    if (e.getMessage().contains(\"-32601\")) { /* server lacks tools/list */ }\n    throw e;\n}","preventionTips":["Confirm the server implements tools/list before relying on listTools.","Use a full MCP client if the server requires initialize/initialized.","Map JSON-RPC error codes to user-facing guidance."],"tags":["mcp","json-rpc","protocol-error","method-not-found"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}