Hmbown/CodeWhale · error

missing mcp__ prefix

Error message

missing mcp__ prefix

What it means

parse_qualified_tool_name splits strings of the form mcp__server__tool into (server, tool). If the input does not start with the literal 'mcp__' prefix, there is nothing to parse and the function bails with this message. It is the first validation gate for qualified tool names.

Solutions

  1. Prefix the tool name with 'mcp__' and the server segment: 'mcp__<server>__<tool>'.
  2. Use the manager's qualification helper that builds the qualified name from (server, tool) instead of concatenating strings manually.
  3. If the caller has unqualified names, resolve the server first and use call_tool(server, tool) instead of the qualified API.

Example fix

// before
call_qualified_tool("github__search")   // missing mcp__
// after
call_qualified_tool("mcp__github__search")
Defensive patterns

Strategy: validation

Validate before calling

fn is_qualified_tool_name(s: &str) -> bool {
    s.starts_with("mcp__") && s[5..].split_once("__")
        .map(|(srv, tool)| !srv.is_empty() && !tool.is_empty())
        .unwrap_or(false)
}

Type guard

fn as_qualified(name: &str) -> Option<(&str, &str)> {
    let rest = name.strip_prefix("mcp__")?;
    let (server, tool) = rest.split_once("__")?;
    (!server.is_empty() && !tool.is_empty()).then_some((server, tool))
}

Prevention

When it happens

Trigger: Calling parse_qualified_tool_name (directly or via call_qualified_tool) with a string like "github__search", "search", or "mcp-search" that lacks the exact 'mcp__' prefix.

Common situations: Storing only the tool name and forgetting to qualify it before calling; hand-building qualified names with wrong separators (single underscore, hyphen); passing a tool name from a non-MCP source into the MCP qualified-name API.

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/b88e78b906749484. Report an issue: GitHub.

Appendix: source

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

        let remaining = component_budget - server_len - tool_len;
        if remaining > 0 {
            let server_extra = (server.len() - server_len).min(remaining);
            server_len += server_extra;
            tool_len += (tool.len() - tool_len).min(remaining - server_extra);
        }
        name = format!(
            "mcp__{}__{}{}",
            &server[..server_len],
            &tool[..tool_len],
            suffix
        );
    }
    name
}

fn parse_qualified_tool_name(value: &str) -> Result<(String, String)> {
    let Some(stripped) = value.strip_prefix("mcp__") else {
        bail!("missing mcp__ prefix");
    };
    let mut split = stripped.splitn(2, "__");
    let server = split
        .next()
        .filter(|s| !s.is_empty())
        .map(ToOwned::to_owned)
        .context("missing server segment")?;
    let tool = split
        .next()
        .filter(|s| !s.is_empty())
        .map(ToOwned::to_owned)
        .context("missing tool segment")?;
    Ok((server, tool))
}

#[derive(Debug, Deserialize)]
struct JsonRpcRequest {
    jsonrpc: String,

View on GitHub (pinned to 73e0f67d83)