Mithril — Tools — The Armory




Purpose
🛡️
24 executable tools that agents can invoke: file I/O, git, web search, terminal,
Files
10
LOC
1,753

Key Concept

Every tool implements the Tool trait (name, description, params, execute). The registry makes them available to agents as function-calling definitions.

The Tool Trait

Every tool implements 4 things:

How Agents Use Tools

  1. The orchestrator sends tool definitions to the LLM as JSON Schema
  2. The LLM decides to call a tool → returns {"name": "read_psi", "arguments": {"target": "main.rs"}}
  3. Mithril executes the tool via execute_tool_safe() (with panic protection)
  4. The result is fed back to the LLM as a system message
  5. The LLM can call more tools or respond to the user

Download as CSV
Category Tools Count
File read_psi, write_file, edit_file, delete_file, apply_patch 5
Discovery list_files, grep_files, find_file, file_stats, glob_files 5
Git git_status, git_log, git_diff, git_blame, git_branch 5
Web web_search, fetch_page 2
Code search_symbols, document_outline 2
Terminal run_terminal (sandboxed) 1
Knowledge lore_write, lore_read 2
Interaction todo_write, question 2

New Tool Template

pub struct MyNewTool;

impl Tool for MyNewTool {
    fn name(&self) -> &str { "my_tool" }
    
    fn description(&self) -> &str {
        "Does something useful — shown to the LLM"
    }
    
    fn parameters(&self) -> Vec<ToolParam> {
        vec![
            ToolParam { name: "input".into(), param_type: "string".into(),
                        description: "What to process".into(), required: true },
        ]
    }
    
    fn execute(&self, args: &HashMap<String, String>) -> ToolResult {
        let input = args.get("input").unwrap_or(&String::new());
        // Do the work...
        ToolResult::ok(format!("Processed: {}", input))
    }
}

// Then register in src/tools/mod.rs create_default_registry():
registry.register(MyNewTool);

FilePurpose
implementations/file_tools.rs
implementations/git_tools.rs
implementations/lore_tools.rs
implementations/mod.rsTool implementations split by category.
implementations/scan_tools.rs
implementations/terminal_tools.rs
implementations/utility_tools.rs
implementations/web_tools.rs
mod.rsMCP Tools — 21 built-in tools the LLM can invoke.
registry.rs