zed-industries/zed · error · anyhow::Error

{error_message}

Error message

{error_message}

What it means

The MCP server answered the CallTool request with `is_error == Some(true)`. The error message is the concatenation of the response's text content blocks, i.e. the server's own tool-level failure relayed verbatim by Zed. The JSON-RPC transport itself succeeded; the tool execution on the server failed.

Source

Thrown at crates/agent/src/tools/context_server_registry.rs:398

            let request = protocol.request::<context_server::types::requests::CallTool>(
                context_server::types::CallToolParams {
                    name: tool_name,
                    arguments,
                    meta: None,
                },
            );

            let response = futures::select! {
                response = request.fuse() => response?,
                _ = event_stream.cancelled_by_user().fuse() => {
                    return Err(anyhow::anyhow!("MCP tool cancelled by user").into());
                }
            };

            if response.is_error == Some(true) {
                let error_message: String =
                    response.content.iter().filter_map(|c| c.text()).collect();
                return Err(anyhow::anyhow!(error_message).into());
            }

            let mut llm_output = Vec::new();
            let mut tool_call_content = Vec::new();
            let mut concatenated_text = String::new();
            for content in response.content {
                match content {
                    context_server::types::ToolResponseContent::Text { text } => {
                        concatenated_text.push_str(&text);
                        tool_call_content.push(acp::ToolCallContent::Content(acp::Content::new(
                            acp::ContentBlock::Text(acp::TextContent::new(text.clone())),
                        )));
                        llm_output.push(LanguageModelToolResultContent::Text(text.into()));
                    }
                    context_server::types::ToolResponseContent::Image { data, mime_type } => {
                        tool_call_content.push(acp::ToolCallContent::Content(acp::Content::new(
                            acp::ContentBlock::Image(acp::ImageContent::new(
                                data.clone(),

View on GitHub (pinned to bc538def45)

Solutions

  1. Read the message — it comes straight from the server and usually names the offending argument.
  2. Validate arguments against the tool's input schema before calling.
  3. Fix credentials or configuration on the server side, then retry.
  4. Restart/refresh the server if its schemas changed so updated tool definitions are re-fetched.

Example fix

// before
if response.is_error == Some(true) {
    let error_message: String = response.content.iter().filter_map(|c| c.text()).collect();
    return Err(anyhow::anyhow!(error_message).into());
}
// after — keep the server context in the message
if response.is_error == Some(true) {
    let error_message: String = response.content.iter().filter_map(|c| c.text()).collect();
    return Err(anyhow::anyhow!("MCP tool {tool_name} failed: {error_message}").into());
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Check required fields against the tool's input schema before calling:
if let Some(required) = tool.input_schema.get("required").and_then(|r| r.as_array()) {
    for name in required {
        let key = name.as_str().unwrap_or_default();
        if arguments.get(key).map(|v| v.is_null()).unwrap_or(true) {
            anyhow::bail!("missing required argument: {key}");
        }
    }
}

Try / catch

if response.is_error == Some(true) {
    let error_message: String = response.content.iter().filter_map(|c| c.text()).collect();
    // Relay the server's text verbatim — it usually names the bad argument.
    return Err(anyhow::anyhow!(error_message).into());
}

Prevention

When it happens

Trigger: Passing arguments the server rejects (wrong types, missing required fields); server-side failures such as missing API keys, rate limits, or absent resources the tool operates on.

Common situations: Schema drift between the advertised input schema and the server implementation; expired credentials for API-backed MCP tools; models hallucinating argument values.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/f5d1f5a1d9829f2f. Report an issue: GitHub.