{"record":{"id":"134b1c7e115646fa","repo":"zed-industries/zed","slug":"mcp-tool-cancelled-by-user","errorCode":null,"errorMessage":"MCP tool cancelled by user","messagePattern":"MCP tool cancelled by user","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/context_server_registry.rs","lineNumber":391,"sourceCode":"\n            log::trace!(\n                \"Running tool: {} with arguments: {:?}\",\n                tool_name,\n                arguments\n            );\n\n            let request = protocol.request::<context_server::types::requests::CallTool>(\n                context_server::types::CallToolParams {\n                    name: tool_name,\n                    arguments,\n                    meta: None,\n                },\n            );\n\n            let response = futures::select! {\n                response = request.fuse() => response?,\n                _ = event_stream.cancelled_by_user().fuse() => {\n                    return Err(anyhow::anyhow!(\"MCP tool cancelled by user\").into());\n                }\n            };\n\n            if response.is_error == Some(true) {\n                let error_message: String =\n                    response.content.iter().filter_map(|c| c.text()).collect();\n                return Err(anyhow::anyhow!(error_message).into());\n            }\n\n            let mut llm_output = Vec::new();\n            let mut tool_call_content = Vec::new();\n            let mut concatenated_text = String::new();\n            for content in response.content {\n                match content {\n                    context_server::types::ToolResponseContent::Text { text } => {\n                        concatenated_text.push_str(&text);\n                        tool_call_content.push(acp::ToolCallContent::Content(acp::Content::new(\n                            acp::ContentBlock::Text(acp::TextContent::new(text.clone())),","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent/src/tools/context_server_registry.rs#L373-L409","documentation":"Raised when the user cancels an in-flight MCP CallTool request: the futures::select race between the server response and event_stream.cancelled_by_user() resolves to cancellation, and the tool reports this error instead of a result.","triggerScenarios":"Thrown at crates/agent/src/tools/context_server_registry.rs:391 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["No recovery needed; the user intentionally cancelled the tool execution","Inform the model the tool was cancelled so it can adapt its plan","Re-run the tool only if the user requests it again"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}