Hmbown/CodeWhale · error

tool ' ' on MCP server ' ' is blocked by the tool filter

Error message

tool '{tool_name}' on MCP server '{server_name}' is blocked by the tool filter

What it means

This error is thrown by McpManager::call_tool when the requested tool name exists on the server but is rejected by a per-server tool filter configured in `configs`. The filter acts as an allow/deny list; `allowed_by_filter` returns false and the call fails closed instead of reaching the MCP client. It prevents calls to tools the operator deliberately excluded.

Solutions

  1. Check the tool filter configured for that server (self.configs / manager config) and add the tool to the allow list or remove it from the deny list.
  2. Verify the exact tool name spelling matches what the server advertises via list_tools; fix the filter or the call site to use the correct name.
  3. If the tool should genuinely be unavailable, change the calling code to stop requesting it (skip or pick another tool).

Example fix

// before (config)
filters: { "github": deny: ["*write*"] }
manager.call_tool("github", "create_issue", args)  // blocked
// after
filters: { "github": deny: ["delete_repo"] }
manager.call_tool("github", "create_issue", args)
Defensive patterns

Strategy: validation

Validate before calling

fn tool_allowed(manager: &McpManager, server: &str, tool: &str) -> bool {
    manager.configs.get(server)
        .map(|(_, filter)| allowed_by_filter(tool, filter))
        .unwrap_or(true)
}
// check before calling: if !tool_allowed(&manager, "github", "create_issue") { skip }

Try / catch

match manager.call_tool(server, tool, args) {
    Err(e) if e.to_string().contains("blocked by the tool filter") => {
        tracing::warn!("tool {tool} filtered on {server}; skipping");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling McpManager::call_tool(server_name, tool_name, arguments) for a server that has an entry in self.configs whose filter does not allow tool_name. Also occurs indirectly through call_qualified_tool, which delegates to call_tool.

Common situations: Config file lists an allow/deny filter for the MCP server but the application later tries to invoke a tool outside it; a model hallucinates a tool name that is filtered; filter patterns were written after tools were renamed; tests like manager_call_tool_enforces_deny_filter exercise this deliberately.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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

Appendix: source

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

            }
        }
        Ok(out)
    }

    /// Call a tool on a specific server by name.
    ///
    /// The server's [`ToolFilter`] is enforced on invocation, not just at
    /// listing time: a denied (or not-allowed) tool cannot be executed by
    /// addressing the server directly, whether by bare or qualified name.
    pub fn call_tool(&self, server_name: &str, tool_name: &str, arguments: Value) -> Result<Value> {
        let client = self
            .clients
            .get(server_name)
            .with_context(|| format!("MCP server '{server_name}' not available"))?;
        if let Some((_, filter)) = self.configs.get(server_name)
            && !allowed_by_filter(tool_name, filter)
        {
            bail!("tool '{tool_name}' on MCP server '{server_name}' is blocked by the tool filter");
        }
        client.call_tool(tool_name, arguments)
    }

    /// Call a tool using its fully qualified name (e.g., `mcp__server__tool`).
    pub fn call_qualified_tool(
        &self,
        qualified_tool_name: &str,
        arguments: Value,
    ) -> Result<Value> {
        let parsed = parse_qualified_tool_name(qualified_tool_name)
            .with_context(|| format!("invalid qualified MCP tool name: {qualified_tool_name}"));

        // An exact registration is the answer. Whatever the tool returns —
        // including an error — is returned as-is: falling through to the scan
        // below on a *call* failure would re-execute the same tool, and for a
        // file write, a commit, or a paid API call that second invocation is a
        // second real side effect. Only a failed *lookup* falls through.

View on GitHub (pinned to 73e0f67d83)