Skip to main content

Module tools

Module tools 

Source
Expand description

Built-in tools (calculator, web search). Built-in Tools for Agent Capabilities

This module provides the tool infrastructure that enables agents to perform actions beyond text generation, such as calculations and web searches.

§Module Structure

  • calculator - Mathematical expression evaluation
  • search - Web search integration (DuckDuckGo, Brave, etc.)
  • registry - Tool registration and discovery

§Available Tools

§Calculator

Evaluates mathematical expressions safely:

let result = calculator::evaluate("2 + 2 * 3")?;  // Returns 8

Searches the web and returns relevant results:

let results = search::web_search("rust programming", 5).await?;
for result in results {
    println!("{}: {}", result.title, result.url);
}

§Tool Registry

The registry module manages tool discovery and execution:

let registry = ToolRegistry::default();
let tools = registry.list_tools();  // Get available tool schemas
let result = registry.execute("calculator", json!({"expr": "2+2"})).await?;

§MCP Integration

Tools can also be provided via MCP (Model Context Protocol) servers. See the mcp module for external tool integration.

Modules§

calculator
Calculator tool for arithmetic operations.
registry
Tool registry for managing available tools.
search
Web search tool using DuckDuckGo.