Quick Start
Create a simple tool using the@function_tool decorator:
Tool Creation Methods
Function Tools
The simplest way to create tools is with decorated functions:- Function name becomes the tool name
- Docstring becomes the tool description (helps the LLM understand when to use it)
- Type hints are required for parameters
- Return type should be
stror JSON-serializable
BaseTool Classes
For more complex tools with multiple capabilities:Dynamic Tools with from_function
Create tools dynamically from any function:Using Built-in Tools
Agentor comes with pre-built tools. Reference them by name:get_weather- Weather informationcalculator- Basic arithmeticweb_search- Internet search- And more in the registry
Real-World Tool Examples
API Integration Tool
Database Tool
File Operations Tool
Tool Best Practices
@function_tool
def send_email(to: str, subject: str, body: str) -> str:
"""
Send an email to a recipient.
Use this when the user wants to send an email or contact someone.
Args:
to: Recipient email address
subject: Email subject line
body: Email body content
"""
# Implementation
from typing import List, Optional
@function_tool
def search_products(
query: str,
category: Optional[str] = None,
max_results: int = 10
) -> str:
"""Search for products."""
# Implementation
@function_tool
def fetch_data(url: str) -> str:
"""Fetch data from a URL."""
try:
response = requests.get(url, timeout=10)
response.raise_for_status()
return response.text
except requests.RequestException as e:
return f"Error fetching data: {str(e)}"
@function_tool
def get_user_info(user_id: str) -> str:
"""Get user information."""
user = fetch_user(user_id) # Your implementation
return f"""
Name: {user['name']}
Email: {user['email']}
Status: {user['status']}
Last Login: {user['last_login']}
"""
class APITool(BaseTool):
name = "api_tool"
description = "Access external API"
def __init__(self, api_key: str):
super().__init__(api_key=api_key)
@capability
def fetch(self, endpoint: str) -> str:
"""Fetch data from API endpoint."""
headers = {"Authorization": f"Bearer {self.api_key}"}
# Implementation
# Usage
tool = APITool(api_key=os.environ.get("API_KEY"))
agent = Agentor(name="Agent", model="gpt-5-mini", tools=[tool])
Serving Tools as MCP Servers
You can serve any BaseTool as an MCP server:Next Steps
- Learn about building MCP servers for tool sharing
- Add streaming support to see tool calls in real-time
- Deploy tools with the Celesto CLI