Hmbown/CodeWhale · error · anyhow::Error

MCP error in '{method}': {error}

Error message

MCP error in '{method}': {error}

What it means

The non-reviewed twin of the suppressed variant: the MCP server answered a JSON-RPC request with an `error` object and Codewhale forwards it verbatim, tagged with the failing method (crates/tui/src/mcp.rs:1231). It surfaces during initialize and the discovery methods for servers without a reviewed-plugin source, so the server's own code and message are visible.

Source

Thrown at crates/tui/src/mcp.rs:1231

            tools: capabilities.contains_key("tools"),
            resources: capabilities.contains_key("resources"),
            prompts: capabilities.contains_key("prompts"),
        })
    }
}

fn response_result<'a>(
    response: &'a serde_json::Value,
    method: &str,
    suppress_server_details: bool,
) -> Result<Option<&'a serde_json::Value>> {
    if let Some(error) = response.get("error") {
        if suppress_server_details {
            anyhow::bail!(
                "Reviewed plugin MCP server returned an error in '{method}' (server details suppressed to protect environment-backed credentials)"
            );
        }
        anyhow::bail!("MCP error in '{method}': {error}");
    }
    Ok(response.get("result"))
}

async fn run_optional_discovery<F>(server: &str, method: &str, timeout: Duration, discovery: F)
where
    F: Future<Output = Result<()>>,
{
    match tokio::time::timeout(timeout, discovery).await {
        Ok(Ok(())) => {}
        Ok(Err(error)) => {
            tracing::warn!(
                target: "mcp",
                server,
                method,
                error = %error,
                "optional MCP discovery failed; continuing with available capabilities"
            );

View on GitHub (pinned to 8880682c63)

Solutions

  1. Read the code/message inside the error text - it is the server's own diagnosis; fix that (params, auth, method support).
  2. Make the server's initialize response advertise accurate capabilities so unimplemented methods are never called.
  3. Upgrade or align the MCP server version with the methods in use.
Defensive patterns

Strategy: try-catch

Try / catch

match conn.call_tool(tool, args, timeout).await {
    Ok(value) => value,
    Err(err) => {
        let msg = err.to_string();
        if let Some(rest) = msg.strip_prefix("MCP error in ") {
            // rest is "'method': {code:..., message:...}" - classify by code/message
            tracing::warn!(method_or_error = %rest, "MCP server reported an error");
        }
        return Err(err);
    }
}

Prevention

When it happens

Trigger: Server returns -32601 method-not-found for a */list call it does not implement (normally avoided when initialize capabilities are accurate), -32602 invalid params, or an application-specific error object.

Common situations: Version mismatch between the client's protocol assumptions and an older/newer server; servers that error instead of returning empty lists; auth failures surfaced as JSON-RPC errors.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/6cb6e7441f4c7840. Report an issue: GitHub.