{"record":{"id":"6cb6e7441f4c7840","repo":"Hmbown/CodeWhale","slug":"mcp-error-in-method-error","errorCode":null,"errorMessage":"MCP error in '{method}': {error}","messagePattern":"MCP error in '(.+?)': (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":1231,"sourceCode":"            tools: capabilities.contains_key(\"tools\"),\n            resources: capabilities.contains_key(\"resources\"),\n            prompts: capabilities.contains_key(\"prompts\"),\n        })\n    }\n}\n\nfn response_result<'a>(\n    response: &'a serde_json::Value,\n    method: &str,\n    suppress_server_details: bool,\n) -> Result<Option<&'a serde_json::Value>> {\n    if let Some(error) = response.get(\"error\") {\n        if suppress_server_details {\n            anyhow::bail!(\n                \"Reviewed plugin MCP server returned an error in '{method}' (server details suppressed to protect environment-backed credentials)\"\n            );\n        }\n        anyhow::bail!(\"MCP error in '{method}': {error}\");\n    }\n    Ok(response.get(\"result\"))\n}\n\nasync fn run_optional_discovery<F>(server: &str, method: &str, timeout: Duration, discovery: F)\nwhere\n    F: Future<Output = Result<()>>,\n{\n    match tokio::time::timeout(timeout, discovery).await {\n        Ok(Ok(())) => {}\n        Ok(Err(error)) => {\n            tracing::warn!(\n                target: \"mcp\",\n                server,\n                method,\n                error = %error,\n                \"optional MCP discovery failed; continuing with available capabilities\"\n            );","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/mcp.rs#L1213-L1249","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the code/message inside the error text - it is the server's own diagnosis; fix that (params, auth, method support).","Make the server's initialize response advertise accurate capabilities so unimplemented methods are never called.","Upgrade or align the MCP server version with the methods in use."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match conn.call_tool(tool, args, timeout).await {\n    Ok(value) => value,\n    Err(err) => {\n        let msg = err.to_string();\n        if let Some(rest) = msg.strip_prefix(\"MCP error in \") {\n            // rest is \"'method': {code:..., message:...}\" - classify by code/message\n            tracing::warn!(method_or_error = %rest, \"MCP server reported an error\");\n        }\n        return Err(err);\n    }\n}","preventionTips":["Advertise accurate capabilities in the server's initialize response.","Return empty lists instead of errors for unimplemented list methods.","Align server and client MCP protocol versions."],"tags":["mcp","jsonrpc","protocol"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}