Hmbown/CodeWhale · error
server ' ' is not registered
Error message
server '{server_name}' is not registered What it means
Raised by `McpManager::unregister_server` (crates/mcp/src/lib.rs): the given server name has no entry in the manager's config map, so there is nothing to remove. The client entry (if any) is still dropped, but the call returns an error because the named server was never registered.
Solutions
- Check the server is registered first (`list_tools`, configs, or a `contains` check) before unregistering.
- Make teardown idempotent by ignoring this error when it occurs during shutdown.
- Fix the server name to match the registered config key exactly.
Example fix
// before
manager.unregister_server("github")?; // may error if absent
// after
if manager.configs().contains_key("github") {
manager.unregister_server("github").ok();
} Defensive patterns
Strategy: try-catch
Validate before calling
// Rust: only unregister what exists
if manager.has_server("github") {
manager.unregister_server("github")?;
} Type guard
fn registered(manager: &McpManager, name: &str) -> bool { manager.has_server(name) } Try / catch
if let Err(e) = manager.unregister_server("github") {
if !e.to_string().contains("is not registered") {
return Err(e); // ignore only the benign not-registered case
}
} Prevention
- Track registration state alongside your own teardown list.
- Make shutdown paths tolerate 'not registered' errors for idempotency.
- Use exact server-name constants shared between register and unregister call sites.
When it happens
Trigger: Calling `unregister_server(name)` for a name never passed to `register_server`, after a previous unregister already removed it, or with a name that differs in spelling/case from the registered one.
Common situations: Double teardown in cleanup code or drop paths; idempotent-shutdown scripts that unregister twice; typos or renamed servers in config after an upgrade; test fixtures tearing down servers that failed to start.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- MCP server ' ' not found
- MCP server ' ' not found
- MCP server ' ' was not found.
- resource URI ' ' was not advertised by any running MCP…
- resource URI ' ' was not advertised by any running MCP…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/0cce34c6762b10bd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/mcp/src/lib.rs:381
failed,
cancelled,
}
}
/// Stop a running server by removing its client.
pub fn stop_server(&mut self, server_name: &str) -> Result<()> {
self.clients
.remove(server_name)
.with_context(|| format!("server '{server_name}' is not running"))?;
Ok(())
}
/// Remove a server entirely (config and client).
pub fn unregister_server(&mut self, server_name: &str) -> Result<()> {
let had_config = self.configs.remove(server_name).is_some();
self.clients.remove(server_name);
if !had_config {
bail!("server '{server_name}' is not registered");
}
Ok(())
}
/// List all tools from all running servers, applying tool filters.
pub fn list_tools(&self) -> Result<Vec<McpToolDescriptor>> {
Ok(self
.list_tools_with_input_schemas()?
.into_iter()
.map(|(tool, _)| tool)
.collect())
}
fn list_tools_with_input_schemas(&self) -> Result<Vec<(McpToolDescriptor, Value)>> {
let mut out = Vec::new();
let mut qualified_origins: HashMap<String, (String, String)> = HashMap::new();
for (server_name, (_, filter)) in &self.configs {
let Some(client) = self.clients.get(server_name) else {View on GitHub (pinned to 73e0f67d83)