How the Agentor tool system works: function tools, BaseTool classes, the global registry, and integration with external MCP servers for agent capabilities.
Agentor provides a flexible tool system that allows agents to interact with external APIs, databases, and services. Tools can be registered globally, created as reusable classes, or defined inline.
Create simple tools using the @function_tool decorator:
from agentor import function_tool@function_tooldef get_weather(city: str) -> str: """Returns the weather in the given city.""" return f"The weather in {city} is sunny"agent = Agentor( name="Weather Agent", tools=[get_weather])
Register tools globally for reuse across agents (src/agentor/tools/registry.py:23):
from agentor.tools.registry import register_global_toolfrom agents import RunContextWrapperfrom agentor.tools.registry import CelestoConfig@register_global_tooldef get_weather(wrapper: RunContextWrapper[CelestoConfig], city: str) -> str: """Returns the weather in the given city.""" api_key = wrapper.context.weather_api_key # Fetch weather using API key return f"Weather in {city}"
Use registered tools by name:
agent = Agentor( name="Agent", tools=["get_weather"] # Reference by string name)
Create a tool from any function (src/agentor/tools/base.py:100):
from agentor.tools.base import BaseTooldef weather_tool(city: str): """This function returns the weather of the city.""" return f"Weather in {city} is warm and sunny."tool = BaseTool.from_function(weather_tool)result = tool.run("London")print(result) # Weather in London is warm and sunny.