{"record":{"id":"22f72cd50d9b8ccd","repo":"gitbutlerapp/gitbutler","slug":"tool-name-not-found","errorCode":null,"errorMessage":"Tool '{name}' not found","messagePattern":"Tool '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-tools/src/tool.rs","lineNumber":41,"sourceCode":"}\n\nimpl<'a> WorkspaceToolset<'a> {\n    pub fn new(ctx: &'a mut Context) -> Self {\n        WorkspaceToolset {\n            ctx,\n            tools: BTreeMap::new(),\n            commit_mapping: HashMap::new(),\n        }\n    }\n\n    fn call_tool_inner(\n        &mut self,\n        name: &str,\n        parameters: &str,\n    ) -> anyhow::Result<serde_json::Value> {\n        let tool = self\n            .get(name)\n            .ok_or_else(|| anyhow::anyhow!(\"Tool '{name}' not found\"))?;\n        let params: serde_json::Value = serde_json::from_str(parameters)\n            .map_err(|e| anyhow::anyhow!(\"Failed to parse parameters: {e}\"))?;\n        tool.call(params, self.ctx, &mut self.commit_mapping)\n    }\n}\n\nimpl Toolset for WorkspaceToolset<'_> {\n    fn register_tool<T: Tool>(&mut self, tool: T) {\n        self.tools.insert(tool.name(), Arc::new(tool));\n    }\n\n    fn get(&self, name: &str) -> Option<Arc<dyn Tool>> {\n        self.tools.get(name).cloned()\n    }\n\n    fn list(&self) -> Vec<Arc<dyn Tool>> {\n        self.tools.values().cloned().collect()\n    }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-tools/src/tool.rs#L23-L59","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["List available tools (e.g. the toolset's list/definition output) and correct the tool name","Ensure register_tool is called for the needed tool before call_tool","Check you're invoking the toolset instance that actually has the tool registered","If the caller is an LLM, include the exact tool names in the prompt/schema to reduce hallucination"],"exampleFix":"// before\nlet out = toolset.call_tool(\"open_pull_request\", params)?; // not registered\n// after\nlet name = if toolset.get(\"open_pull_request\").is_some() { \"open_pull_request\" } else { \"open_workspace_pr\" };\nlet out = toolset.call_tool(name, params)?;","handlingStrategy":"validation","validationCode":"const available = toolset.list_tools().map(t => t.name);\nif (!available.includes(toolName)) {\n  throw new Error(`tool \"${toolName}\" not registered; available: ${available.join(', ')}`);\n}","typeGuard":"function isRegisteredTool(name: string, ts: { get(n: string): unknown }): name is string {\n  return ts.get(name) !== undefined;\n}","tryCatchPattern":"try {\n  return await toolset.call_tool(name, params);\n} catch (e) {\n  if (String(e).includes(\"Tool '\") && String(e).includes(\"' not found\")) {\n    return suggestSimilarTool(name, toolset.list_tools());\n  }\n  throw e;\n}","preventionTips":["Expose the exact registered tool names to LLM callers in the tool schema","Register all needed tools before first call_tool","Fuzzy-match near-miss tool names and correct them","Scope toolsets so the right tools are in the invoked instance"],"tags":["tools","not-found","mcp","agent"],"backgroundTag":"resource-not-found","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}