Hmbown/CodeWhale · error

qualified MCP tool name

Error message

qualified MCP tool name '{qualified_tool_name}' is ambiguous across servers: {}

What it means

call_qualified_tool resolves a qualified tool name (mcp__server__tool form, or sanitized variants) to a server. When the tool portion matches tools advertised by MORE than one running server, resolution cannot pick one, so the manager fails closed with the list of conflicting servers. This prevents silently invoking the wrong server's tool.

Solutions

  1. Use the fully unambiguous qualified form including the exact server segment (the raw server name, not a sanitized/collision-prone one), e.g. mcp__github__search instead of a sanitized shorthand.
  2. Rename or remove the duplicate tool on one of the servers, or disconnect one of the conflicting servers.
  3. Inspect the server list in the error message and pick the intended server explicitly, calling client.call_tool(server, tool) via the manager's per-server API.

Example fix

// before
manager.call_qualified_tool("mcp__search")  // ambiguous: fs, web
// after
manager.call_qualified_tool("mcp__web__search")
Defensive patterns

Strategy: validation

Validate before calling

fn is_unambiguous(manager: &McpManager, qualified: &str) -> Result<(), String> {
    let tool = qualified.rsplit("__").next().unwrap_or(qualified);
    let owners: Vec<_> = manager.clients.iter()
        .filter(|(s, _)| manager.tool_exists(s, tool))
        .map(|(s, _)| s.clone()).collect();
    if owners.len() > 1 { Err(format!("ambiguous: {}", owners.join(", "))) } else { Ok(()) }
}

Try / catch

match manager.call_qualified_tool(name) {
    Err(e) if e.to_string().contains("is ambiguous across servers") => {
        // parse server list from message, prompt user or pick configured default server
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling McpManager::call_qualified_tool with a qualified name whose tool segment (or sanitized/truncated form) matches tools on two or more connected servers that advertise the same tool name.

Common situations: Two MCP servers expose identically named tools (e.g., both expose 'search'); sanitized names collide after character normalization; truncated names from long server/tool names collide; connecting a second server that duplicates an existing one's tool catalog.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

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

            }
        }
        match matches.len() {
            0 => {}
            1 => {
                let (server_name, tool_name) = &matches[0];
                let client = self
                    .clients
                    .get(*server_name)
                    .with_context(|| format!("MCP server '{server_name}' not available"))?;
                return client.call_tool(tool_name, arguments);
            }
            _ => {
                matches.sort();
                let servers: Vec<&str> = matches
                    .iter()
                    .map(|(server_name, _)| server_name.as_str())
                    .collect();
                bail!(
                    "qualified MCP tool name '{qualified_tool_name}' is ambiguous across servers: \
                     {}",
                    servers.join(", ")
                );
            }
        }

        let (server_name, tool_name) = parsed?;
        self.call_tool(&server_name, &tool_name, arguments)
    }

    /// List all resources from all running servers.
    pub fn list_resources(&self) -> Result<Vec<McpResourceDescriptor>> {
        Ok(self
            .list_resources_with_metadata()?
            .into_iter()
            .map(|(resource, _)| resource)
            .collect())

View on GitHub (pinned to 73e0f67d83)