{"record":{"id":"84c1a89a4071e635","repo":"zed-industries/zed","slug":"context-server-request-timeout","errorCode":null,"errorMessage":"Context server request timeout","messagePattern":"Context server request timeout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context_server/src/client.rs","lineNumber":483,"sourceCode":"                            return Err(err);\n                        }\n                        anyhow::bail!(\"cancelled\")\n                    }\n                }\n            }\n            _ = cancel_fut => {\n                self.notify(\n                    Cancelled::METHOD,\n                    ClientNotification::Cancelled(CancelledParams {\n                        request_id: RequestId::Int(id),\n                        reason: None\n                    })\n                ).log_err();\n                anyhow::bail!(RequestCanceled)\n            }\n            _ = timeout_fut => {\n                log::error!(\"cancelled csp request task for {method:?} id {id} which took over {:?}\", timeout.unwrap());\n                anyhow::bail!(\"Context server request timeout\");\n            }\n        }\n    }\n\n    /// Sends a notification to the context server without expecting a response.\n    /// This function serializes the notification and sends it through the outbound channel.\n    pub fn notify(&self, method: &str, params: impl Serialize) -> Result<()> {\n        let notification = serde_json::to_string(&Notification {\n            jsonrpc: JSON_RPC_VERSION,\n            method,\n            params,\n        })\n        .unwrap();\n        self.outbound_tx.try_send(notification)?;\n        Ok(())\n    }\n\n    /// Notify the underlying transport of the negotiated MCP protocol version","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/context_server/src/client.rs#L465-L501","documentation":"Zed's context-server (MCP) client wraps every request with an optional timeout; when the server does not answer within it, the pending request task is cancelled and this error is returned, with an accompanying `log::error!` naming the method, request id, and timeout duration. It signals a slow or hung MCP server, not a protocol error.","triggerScenarios":"Any MCP request (`tools/list`, `tools/call`, `prompts/get`, ...) exceeding the configured `request_timeout` for that server: server tool doing slow I/O, server waiting on a downstream API, or a deadlocked server process. Trigger fires from the `timeout_fut` branch of the select over cancel/timeout.","commonSituations":"MCP tool that hits a slow external API (search, build, index) exceeding the default timeout; server stuck on startup initialization; overloaded machine; timeout configured too low for legitimately long operations in Zed settings (`context_servers.request_timeout` or per-server).","solutions":["Increase the request timeout for the server in Zed settings (`context_servers` → `request_timeout` in seconds).","Check the MCP server's own logs — if it errors instead of hanging, fix the server; if it is just slow, tune the timeout above its real duration.","Restart the context server (or Zed) to clear hung states; a server that never replies to `tools/list` is likely broken, not slow.","For operations known to be long, prefer tools that return progress/async results rather than blocking the request."],"exampleFix":"// before: default/short timeout; long tool call fails\n// settings.json (Zed):\n// \"context_servers\": { \"my-server\": { \"settings\": { ... } } }\n\n// after: raise the timeout for MCP requests\n// settings.json (Zed):\n\"context_servers\": {\n  \"request_timeout\": 180,\n  \"my-server\": { \"settings\": { \"url\": \"...\" } }\n}","handlingStrategy":"retry","validationCode":"// Before a long operation, check the configured budget matches expectations\nif let Some(timeout) = request_timeout {\n    anyhow::ensure!(expected_max_duration < timeout, \"operation will exceed the MCP request_timeout\");\n}","typeGuard":null,"tryCatchPattern":"match context_server.request(method, params, Some(timeout)).await {\n    Err(err) if err.to_string() == \"Context server request timeout\" => {\n        // request was cancelled server-side; only retry if idempotent\n        if idempotent { context_server.request(method, params, Some(timeout * 2)).await } else { Err(err) }\n    }\n    result => result,\n}","preventionTips":["Set `context_servers.request_timeout` above the slowest legitimate tool duration.","Watch for `cancelled csp request task ... which took over ...` log lines to identify which method times out.","Only retry idempotent requests on timeout; cancelled tasks may have partially executed."],"tags":["mcp","context-server","timeout","jsonrpc"],"backgroundTag":"request-timeout","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"}