conductor-oss/conductor · error · RuntimeException

{error}

Error message

{error}

What it means

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).

Source

Thrown at ai/src/main/java/org/conductoross/conductor/ai/mcp/MCPService.java:263

                                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(responseJson.get("error").toString());
            }

            if (!responseJson.has("result")) {
                throw new RuntimeException("Invalid JSON-RPC response: missing 'result' field");
            }

            JsonNode resultNode = responseJson.get("result");

            // Process the result JSON to parse text content as JSON where applicable
            processResultJson(resultNode);

            // Return as Map to preserve parsed field
            Map<String, Object> result = objectMapper.convertValue(resultNode, Map.class);
            ExternalDataLimits.validateStructure(result);

            log.debug(
                    "Successfully called tool '{}' via direct JSON-RPC on {}", toolName, serverUrl);
            return result;

View on GitHub (pinned to cf7c3e4a8a)

Solutions

  1. Parse the embedded error.code/message from the exception string to classify it.
  2. Confirm toolName is in the listTools() output for that server.
  3. Validate arguments against the tool's inputSchema before calling.
  4. If the server requires initialize, use a client that performs the handshake.

Example fix

// before
Map<String,Object> r = mcpService.callTool(url, name, args, headers);
// after
List<McpSchema.Tool> tools = mcpService.listTools(url, headers);
boolean exists = tools.stream().anyMatch(t -> t.name().equals(name));
if (!exists) throw new IllegalArgumentException("Unknown MCP tool: " + name);
Map<String,Object> r = mcpService.callTool(url, name, args, headers);
Defensive patterns

Strategy: validation

Validate before calling

// Validate arguments against the tool's inputSchema before calling.
List<McpSchema.Tool> tools = mcpService.listTools(serverUrl, headers);
McpSchema.Tool tool = tools.stream().filter(t -> t.name().equals(toolName)).findFirst()
    .orElseThrow(() -> new IllegalArgumentException("Unknown tool: " + toolName));
// schema-validate `arguments` against tool.inputSchema() here

Try / catch

try {
    Map<String,Object> r = mcpService.callTool(serverUrl, toolName, arguments, headers);
} catch (RuntimeException e) {
    // e.getMessage() is the RAW error object string (no prefix); parse it for code/message.
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Tool name typo or tool disabled server-side; arguments don't match the tool's JSON schema; server enforces initialize before tools/call.

Related errors


AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14). Data as JSON: /api/errors/d428c43ce13cef21. Report an issue: GitHub.