zed-industries/zed · error · anyhow::Error
Context server not found
Error message
Context server not found
What it means
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.
Source
Thrown at crates/agent/src/tools/context_server_registry.rs:345
Ok(match schema {
serde_json::Value::Null => {
serde_json::json!({ "type": "object", "properties": [] })
}
serde_json::Value::Object(map) if map.is_empty() => {
serde_json::json!({ "type": "object", "properties": [] })
}
_ => schema,
})
}
fn run(
self: Arc<Self>,
input: ToolInput<serde_json::Value>,
event_stream: ToolCallEventStream,
cx: &mut App,
) -> Task<Result<AgentToolOutput, AgentToolOutput>> {
let Some(server) = self.store.read(cx).get_running_server(&self.server_id) else {
return Task::ready(Err(anyhow::anyhow!("Context server not found").into()));
};
let tool_name = self.tool.name.clone();
let tool_id = mcp_tool_id(&self.server_id.0, &self.tool.name);
let display_name = self.tool.name.clone();
let initial_title = self.initial_title(serde_json::Value::Null, cx);
let authorize =
event_stream.authorize_third_party_tool(initial_title, tool_id, display_name, cx);
cx.spawn(async move |cx| {
let input = input
.recv()
.await
.map_err(|e| anyhow::anyhow!(e.to_string()))?;
authorize
.await
.map_err(|e| anyhow::anyhow!(e.to_string()))?;
View on GitHub (pinned to bc538def45)
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.
Example fix
// before
let server = self.store.read(cx).get_running_server(&self.server_id); // None → error at run time
// after
let Some(server) = self.store.read(cx).get_running_server(&self.server_id) else {
return Task::ready(Err(anyhow::anyhow!("server {} is not running — start it before calling tools", self.server_id.0).into()));
}; Defensive patterns
Strategy: validation
Validate before calling
let server_running = cx
.update(|cx| store.read(cx).get_running_server(&server_id).is_some())?;
if !server_running {
anyhow::bail!("context server '{server_id}' is not running — start it before calling tools");
} Type guard
fn is_context_server_running(
store: &Entity<ContextServerStore>,
server_id: &ContextServerId,
cx: &App,
) -> bool {
store.read(cx).get_running_server(server_id).is_some()
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Context server not initialized
- Project state not found for session
- {e}
- {error_message}
- Could not find UNIT_DATA in the file
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/3ae42a6cf561a739.
Report an issue: GitHub.