conductor-oss/conductor · error · RuntimeException
JSON-RPC error: {error}
Error message
JSON-RPC error: {error} What it means
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().
Source
Thrown at ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java:149
response.statusCode, response.body));
}
// Get response body and content type
String responseBody = response.body;
String contentType = response.contentType;
// Parse response based on content type
JsonNode responseJson;
if (contentType != null && contentType.contains("text/event-stream")) {
// Parse SSE format
responseJson = parseSseResponse(responseBody);
} else {
// Parse as JSON directly
responseJson = objectMapper.readTree(responseBody);
}
if (responseJson.has("error")) {
throw new RuntimeException(
"JSON-RPC error: " + responseJson.get("error").toString());
}
if (!responseJson.has("result")) {
throw new RuntimeException("Invalid JSON-RPC response: missing 'result' field");
}
JsonNode result = responseJson.get("result");
JsonNode toolsNode = result.get("tools");
if (toolsNode == null || !toolsNode.isArray()) {
throw new RuntimeException(
"Invalid response: 'tools' field is missing or not an array");
}
ExternalDataLimits.validateStructure(objectMapper.convertValue(result, Object.class));
// Convert to McpSchema.Tool list
// Use Jackson to deserialize tools directly (same pattern as stdio implementation)View on GitHub (pinned to cf7c3e4a8a)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
List<McpSchema.Tool> tools = mcpService.listTools(serverUrl, headers);
} catch (RuntimeException e) {
// e.getMessage() starts with 'JSON-RPC error: ' followed by the error object.
// Parse code (-32601 method not found, -32602 invalid params) to decide handling.
if (e.getMessage().contains("-32601")) { /* server lacks tools/list */ }
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {error}
- HTTP %d error from MCP server: %s
- Invalid JSON-RPC response: missing 'result' field
- Invalid response: 'tools' field is missing or not an array
- Invalid JSON-RPC response from {endpoint} for '{method}': mi
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/51da8b0982c6b70e.
Report an issue: GitHub.