{"record":{"id":"3ae42a6cf561a739","repo":"zed-industries/zed","slug":"context-server-not-found","errorCode":null,"errorMessage":"Context server not found","messagePattern":"Context server not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent/src/tools/context_server_registry.rs","lineNumber":345,"sourceCode":"        Ok(match schema {\n            serde_json::Value::Null => {\n                serde_json::json!({ \"type\": \"object\", \"properties\": [] })\n            }\n            serde_json::Value::Object(map) if map.is_empty() => {\n                serde_json::json!({ \"type\": \"object\", \"properties\": [] })\n            }\n            _ => schema,\n        })\n    }\n\n    fn run(\n        self: Arc<Self>,\n        input: ToolInput<serde_json::Value>,\n        event_stream: ToolCallEventStream,\n        cx: &mut App,\n    ) -> Task<Result<AgentToolOutput, AgentToolOutput>> {\n        let Some(server) = self.store.read(cx).get_running_server(&self.server_id) else {\n            return Task::ready(Err(anyhow::anyhow!(\"Context server not found\").into()));\n        };\n        let tool_name = self.tool.name.clone();\n        let tool_id = mcp_tool_id(&self.server_id.0, &self.tool.name);\n        let display_name = self.tool.name.clone();\n        let initial_title = self.initial_title(serde_json::Value::Null, cx);\n        let authorize =\n            event_stream.authorize_third_party_tool(initial_title, tool_id, display_name, cx);\n\n        cx.spawn(async move |cx| {\n            let input = input\n                .recv()\n                .await\n                .map_err(|e| anyhow::anyhow!(e.to_string()))?;\n\n            authorize\n                .await\n                .map_err(|e| anyhow::anyhow!(e.to_string()))?;\n","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent/src/tools/context_server_registry.rs#L327-L363","documentation":"An MCP (context-server) tool was invoked, but `ContextServerStore::get_running_server` returned None for the server id — no running server is registered under it. The tool never executes; `run` immediately returns a ready error task.","triggerScenarios":"Calling an MCP tool when the server failed to start (bad command, missing runtime), crashed, was stopped or deleted, or has not completed its first startup; also stale tool advertisements after uninstalling the providing extension.","commonSituations":"npx/uvx-based servers failing because Node/Python is missing or installs run offline; server entry removed from settings while the model still recalls its tools; dev servers not yet spawned when the agent acts.","solutions":["Open context-server/extension settings and confirm the server is installed and its command runs in a terminal.","Check agent/extension logs for the server's startup error and fix it (install the runtime, correct path/args/env).","Restart or re-enable the server, wait for it to reach the running state, then retry the tool once.","Remove references to uninstalled servers so their stale tools stop reaching the model."],"exampleFix":"// before\nlet server = self.store.read(cx).get_running_server(&self.server_id); // None → error at run time\n// after\nlet Some(server) = self.store.read(cx).get_running_server(&self.server_id) else {\n    return Task::ready(Err(anyhow::anyhow!(\"server {} is not running — start it before calling tools\", self.server_id.0).into()));\n};","handlingStrategy":"validation","validationCode":"let server_running = cx\n    .update(|cx| store.read(cx).get_running_server(&server_id).is_some())?;\nif !server_running {\n    anyhow::bail!(\"context server '{server_id}' is not running — start it before calling tools\");\n}","typeGuard":"fn is_context_server_running(\n    store: &Entity<ContextServerStore>,\n    server_id: &ContextServerId,\n    cx: &App,\n) -> bool {\n    store.read(cx).get_running_server(server_id).is_some()\n}","tryCatchPattern":null,"preventionTips":["Start context servers and await their running state before exposing their tools to the model.","Surface server startup failures in logs/UI so stale tools are not invoked.","Uninstall or disable servers you no longer run so their tools disappear from the prompt."],"tags":["mcp","context-server","agent","tooling","startup"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}