gitbutlerapp/gitbutler · error

Tool ' ' not found

Error message

Tool '{name}' not found

What it means

`Toolset::call_tool_inner` looks up the requested tool by name in the registered tool set; if `get(name)` returns None it fails with this error before parsing parameters. It means no tool with that exact name was registered in the toolset.

Solutions

  1. List available tools (e.g. the toolset's list/definition output) and correct the tool name
  2. Ensure register_tool is called for the needed tool before call_tool
  3. Check you're invoking the toolset instance that actually has the tool registered
  4. If the caller is an LLM, include the exact tool names in the prompt/schema to reduce hallucination

Example fix

// before
let out = toolset.call_tool("open_pull_request", params)?; // not registered
// after
let name = if toolset.get("open_pull_request").is_some() { "open_pull_request" } else { "open_workspace_pr" };
let out = toolset.call_tool(name, params)?;
Defensive patterns

Strategy: validation

Validate before calling

const available = toolset.list_tools().map(t => t.name);
if (!available.includes(toolName)) {
  throw new Error(`tool "${toolName}" not registered; available: ${available.join(', ')}`);
}

Type guard

function isRegisteredTool(name: string, ts: { get(n: string): unknown }): name is string {
  return ts.get(name) !== undefined;
}

Try / catch

try {
  return await toolset.call_tool(name, params);
} catch (e) {
  if (String(e).includes("Tool '") && String(e).includes("' not found")) {
    return suggestSimilarTool(name, toolset.list_tools());
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling call_tool (or call_tool_inner) with a tool name string that was never registered via register_tool, or that was registered under a different toolset instance than the one being called.

Common situations: LLM/agent emits a hallucinated or slightly-misspelled tool name; tool not yet registered at call time (registration order bug); using a workspace toolset where only workspace tools are registered but an MCP/global tool name is requested.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/22f72cd50d9b8ccd. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-tools/src/tool.rs:41

}

impl<'a> WorkspaceToolset<'a> {
    pub fn new(ctx: &'a mut Context) -> Self {
        WorkspaceToolset {
            ctx,
            tools: BTreeMap::new(),
            commit_mapping: HashMap::new(),
        }
    }

    fn call_tool_inner(
        &mut self,
        name: &str,
        parameters: &str,
    ) -> anyhow::Result<serde_json::Value> {
        let tool = self
            .get(name)
            .ok_or_else(|| anyhow::anyhow!("Tool '{name}' not found"))?;
        let params: serde_json::Value = serde_json::from_str(parameters)
            .map_err(|e| anyhow::anyhow!("Failed to parse parameters: {e}"))?;
        tool.call(params, self.ctx, &mut self.commit_mapping)
    }
}

impl Toolset for WorkspaceToolset<'_> {
    fn register_tool<T: Tool>(&mut self, tool: T) {
        self.tools.insert(tool.name(), Arc::new(tool));
    }

    fn get(&self, name: &str) -> Option<Arc<dyn Tool>> {
        self.tools.get(name).cloned()
    }

    fn list(&self) -> Vec<Arc<dyn Tool>> {
        self.tools.values().cloned().collect()
    }

View on GitHub (pinned to 58e5313667)