Hmbown/CodeWhale · error

MCP server ' ' collides with already-registered server ' '…

Error message

MCP server '{}' collides with already-registered server '{existing}': both qualify tools as 'mcp__{}__*'

What it means

Raised by `McpManager::register_server` (crates/mcp/src/lib.rs): the new server's name, after sanitizing to a tool-namespace component, is already claimed by a previously registered server, so both would qualify tools as `mcp__<sanitized>__*` and calls could hit the wrong server. Registration fails closed before any tool is exposed.

Solutions

  1. Rename the new server so its sanitized form is unique (use only characters that survive sanitizing distinctly, e.g. letters/underscores).
  2. Unregister the conflicting server first if it is no longer needed.
  3. Audit all server names in your config for collisions after sanitizing before loading them.
  4. If replacement is intended, use the replace path — re-registering the exact same name replaces it; only distinct-but-colliding names are rejected.

Example fix

// before: both sanitize to 'github'
{"mcpServers": {"github": {...}, "github.com": {...}}}
// after
{"mcpServers": {"github": {...}, "github_enterprise": {...}}}
Defensive patterns

Strategy: validation

Validate before calling

// Rust: check sanitized-name uniqueness across configs before register
let sanitized = sanitize_component(&config.name);
for existing in manager.server_names() {
    anyhow::ensure!(sanitize_component(existing) != sanitized,
        "sanitized collision: {} vs {}", existing, config.name);
}

Type guard

fn names_distinct(a: &str, b: &str) -> bool {
    sanitize_component(a) != sanitize_component(b)
}

Try / catch

match manager.register_server(config, filter, client) {
    Err(e) if e.to_string().contains("collides with already-registered server") => {
        // rename and retry
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `register_server` with a `McpServerConfig` whose `name` differs from an existing one only in characters removed by `sanitize_component` (e.g. 'my-server' vs 'my.server' vs 'my server'), or literally re-registering a colliding name while intending a new server.

Common situations: Config files defining multiple MCP servers whose names normalize to the same prefix (dashes, dots, underscores, case); renaming a server without removing the old entry; merging two config sources with overlapping server names.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/79c3fefc5bf77958. Report an issue: GitHub.

Appendix: source

Thrown at crates/mcp/src/lib.rs:262

}

impl McpManager {
    /// Register an MCP server with its config, tool filter, and client implementation.
    ///
    /// Fails when the server's name collides with an already-registered server
    /// after `sanitize_component` folding. Qualified tool names are built
    /// from the sanitized name, so `my-server`, `my_server`, and `My.Server`
    /// all produce `mcp__my_server__*`: registering two of them would let
    /// either server answer a qualified name meant for the other. Re-registering
    /// the same name replaces it, which is how restart works.
    pub fn register_server(
        &mut self,
        config: McpServerConfig,
        filter: ToolFilter,
        client: Box<dyn McpManagedClient>,
    ) -> Result<()> {
        if let Some(existing) = self.colliding_server_name(&config.name) {
            bail!(
                "MCP server '{}' collides with already-registered server '{existing}': \
                 both qualify tools as 'mcp__{}__*'",
                config.name,
                sanitize_component(&config.name)
            );
        }
        self.clients.insert(config.name.clone(), client);
        self.configs.insert(config.name.clone(), (config, filter));
        Ok(())
    }

    /// Returns a registered server whose sanitized name matches `name`'s but
    /// which is not `name` itself.
    fn colliding_server_name(&self, name: &str) -> Option<&str> {
        let sanitized = sanitize_component(name);
        self.configs
            .keys()
            .find(|existing| existing.as_str() != name && sanitize_component(existing) == sanitized)

View on GitHub (pinned to 73e0f67d83)