Overview
The tools module provides an extensible system for agent capabilities. Tools can:- Call external APIs
- Interact with the marketplace
- Execute sandboxed code (via WASM)
- Delegate tasks to other services
- Build new software and tools dynamically
Core Types
Tool Trait
The main trait that all tools must implement.Methods
fn(&self) -> &str
Return the tool name (must be unique in registry)
fn(&self) -> &str
Human-readable description of what the tool does
fn(&self) -> serde_json::Value
JSON Schema defining the tool’s parameters
async fn(&self, params: Value, ctx: &JobContext) -> Result<ToolOutput>
Execute the tool with given parameters and context
fn(&self, params: &Value) -> Option<Decimal>
Estimate the cost of running this tool (optional)
fn(&self, params: &Value) -> ApprovalRequirement
Whether this invocation requires approval
fn(&self) -> ToolDomain
Where this tool should execute (Orchestrator or Container)
fn(&self) -> Option<ToolRateLimitConfig>
Rate limiting configuration for this tool
Example
ToolRegistry
Manages the collection of available tools.fn() -> Self
Create a new empty tool registry
fn(&mut self, tool: Arc<dyn Tool>) -> Result<()>
Register a tool in the registry (fails if name already exists)
fn(&self, name: &str) -> Option<Arc<dyn Tool>>
Get a tool by name
fn(&self) -> Vec<&str>
List all registered tool names
fn(&self) -> Vec<ToolDefinition>
Get all tool schemas for LLM function calling
Example
ToolOutput
Result returned by tool execution.serde_json::Value
The result data (JSON value)
Option<Decimal>
Cost incurred (if any)
Duration
Time taken to execute
Option<String>
Raw output before sanitization (for debugging)
Constructors
fn(result: Value, duration: Duration) -> Self
Create a successful output with JSON result
fn(text: impl Into<String>, duration: Duration) -> Self
Create a text output (convenience for string results)
fn(self, cost: Decimal) -> Self
Add cost information to the output
fn(self, raw: impl Into<String>) -> Self
Add raw output for debugging
Example
ToolError
Error types for tool execution.String
Parameters don’t match the schema or are invalid
String
Tool execution failed with an error
Duration
Tool execution exceeded timeout
String
User not authorized to use this tool
Option<Duration>
Rate limit exceeded, retry after duration
String
External service error (API, network, etc.)
String
Sandbox/WASM execution error
ApprovalRequirement
Defines how much approval a tool invocation needs.()
No approval needed (safe, read-only tools)
()
Needs approval unless user has auto-approved this tool
()
Always requires explicit approval (destructive operations)
Example
ToolDomain
Where a tool should execute.()
Safe to run in the main agent process (pure functions, memory, job management)
()
Must run inside a sandboxed container (filesystem, shell, code execution)
ToolRateLimitConfig
Rate limiting configuration for tools.u32
default:"60"
Maximum invocations per minute per user
u32
default:"1000"
Maximum invocations per hour per user
fn(requests_per_minute: u32, requests_per_hour: u32) -> Self
Create a custom rate limit config
fn() -> Self
Default: 60/min, 1000/hour
Schema Validation
validate_tool_schema
fn(schema: &Value, params: &Value) -> Result<()>
Validate parameters against a JSON Schema. Returns error if validation fails.
Rate Limiting
RateLimiter
Per-user rate limiting for tool invocations.fn() -> Self
Create a new rate limiter
fn(&self, user_id: &str, tool_name: &str, config: &ToolRateLimitConfig) -> Result<(), Duration>
Check if request is allowed and increment counter. Returns error with retry-after duration if rate limited.
Software Builder
Dynamically build and deploy new tools at runtime.SoftwareBuilder
Trait for building software from natural language specifications.LlmSoftwareBuilder
LLM-powered software builder that generates code from specs.fn(llm: Arc<dyn LlmProvider>, config: BuilderConfig) -> Self
Create a new LLM-based software builder
async fn(&self, requirements: &BuildRequirement) -> Result<BuildResult>
Build software from requirements using LLM code generation
BuildRequirement
String
Name of the software/tool to build
String
What the software should do
Language
Target language (Rust, Python, JavaScript, etc.)
SoftwareType
Type (Tool, Library, Service, etc.)
Vec<String>
Required dependencies
Vec<TestCase>
Test cases to validate the implementation
BuildResult
String
Generated source code
BuildMetadata
Build information (language, version, etc.)
Vec<TestResult>
Results of running test cases
Vec<ValidationError>
Any validation errors found
Example
MCP (Model Context Protocol)
Integration with external MCP servers for tool discovery.McpClient
Client for connecting to MCP servers and loading tools.async fn(server_url: &str) -> Result<Self>
Connect to an MCP server
async fn(&self) -> Result<Vec<ToolDefinition>>
List available tools from the MCP server
async fn(&self, name: &str) -> Result<Arc<dyn Tool>>
Load a specific tool from the MCP server
WASM Tools
Load and execute tools compiled to WebAssembly.WasmTool
A tool implementation that runs in a WASM sandbox.async fn(wasm_bytes: &[u8]) -> Result<Self>
Load a WASM module as a tool
async fn(path: &Path) -> Result<Self>
Load a WASM module from a file
Built-in Tools
IronClaw includes several built-in tools in thebuiltin module:
EchoTool- Echo back input (testing)TimeTool- Get current timeJsonTool- Parse and manipulate JSONHttpTool- Make HTTP requestsMemoryReadTool- Read from workspaceMemoryWriteTool- Write to workspaceMemorySearchTool- Search workspaceShellTool- Execute shell commands (container)FileReadTool- Read files (container)FileWriteTool- Write files (container)
Related Modules
Agent Module
Agent orchestration and tool execution
Workspace Module
Memory tools for persistent storage