Tools¶
The miminions.tools module provides a unified interface for defining tools that work across multiple AI frameworks.
Features¶
- Single definition — write a tool once, export to LangChain, AutoGen, or AGNO
- Automatic schema — extracts JSON schema from Python type annotations
@tooldecorator — clean, declarative syntax- MCP adapter — load tools from any MCP server
Quick Start¶
from miminions.tools import tool
@tool(name="calculator", description="Perform basic arithmetic")
def calculate(operation: str, a: int, b: int) -> int:
if operation == "add":
return a + b
elif operation == "subtract":
return a - b
elif operation == "multiply":
return a * b
return 0
result = calculate.run(operation="add", a=5, b=3)
print(result) # 8
Using with an Agent¶
from miminions.agent import create_minion
agent = create_minion("my_agent")
agent.register_tool("calculator", "Perform arithmetic", calculate)
Or use the lower-level Minion class directly:
from miminions.tools import create_tool
from miminions.agent import Agent
agent = Agent("my_agent", "A helpful agent")
calc = create_tool("calculator", "Perform arithmetic", calculate)
agent.add_tool(calc)
result = agent.execute_tool("calculator", operation="multiply", a=4, b=7)
Framework Adapters¶
MCP Integration¶
Type Mapping¶
Python types are automatically converted to JSON Schema types:
| Python | JSON Schema |
|---|---|
int |
"integer" |
float |
"number" |
bool |
"boolean" |
str |
"string" |
| Other | "string" |
API Reference¶
@tool(name, description)¶
Decorator that wraps a function as a GenericTool.
create_tool(name, description, func) -> GenericTool¶
Factory function for creating a tool without the decorator.
GenericTool¶
| Method/Property | Description |
|---|---|
run(**kwargs) |
Execute the tool |
schema |
JSON schema object |
to_dict() |
Schema as a plain dict |