ToolsRepository is the registry that holds every tool an agent can call. There are two kinds:
- Backend tools: connectors and OpenAPI imports configured in the Workbench. Loaded automatically when you
agents.aget(...)an agent. - Local tools: Python functions you decorate with
@register_tool. Registered in-process and merged into the agent’s tool list.
ToolsRepository directly: accessing agent.tools gives you the configured instance for that agent.
Class layout
Constructor
In practice,
agents.aget(...) constructs a ToolsRepository for you with all four arguments populated.
Properties
list
id). Each tool has its Configuration set and any agent-graph schema overrides applied.
functions
.list. Each callable accepts a single payload argument validated against the tool’s auto-generated Pydantic schema. The callable’s __name__ is the tool id and its __doc__ includes a usage example.
This is what Backend.aget_args injects into your framework agent’s tools=... parameter: you rarely need it directly. Useful when binding tools to a custom framework manually.
Methods
get_tool_by_id
id, or None.
get_tool_by_name
name (display name), or None.
register_tool (classmethod)
@register_tool decorator: you don’t usually call this directly.
should_sync_local_tools
True when at least one local tool is marked should_add_to_graph=True and hasn’t been synced yet.
get_local_tools_for_sync
agent.aload).
aload_tool_by_id
<connector_id>_<operation_id> form and seeds it into the repository. Useful when you want to invoke a single tool without loading an agent.
The id is the connector’s UUID and the operation’s catalog id joined by a single underscore, for example "07687ac7-d474-4d24-8ec6-6debac476b00_6a581606eaade0ae8b8f2c9c". Both halves come from List Connector Operations.
The sync sibling is load_tool_by_id.
Patterns
Iterate every tool
Bind tools to a custom framework
Standalone invocation (no agent context)
@register_tool
@register_tool turns a Python function into a tool the agent can invoke. The SDK extracts type hints and the docstring to build a schema and description automatically: there’s no manual schema writing.
calculate_sum is available to every Agents().aget(...) call as a local tool with id "calculate_sum".
Decorator forms
What it does
- Inspects the function’s parameters and type hints.
- Builds a Pydantic model (
<FunctionName>Args) from the parameters: required if no default, optional otherwise. - Constructs a
Toolwith:id= function namename= function namedescription= function docstringparameters= generated JSON schemafn= the functionis_local = Trueshould_add_to_graph = add_to_graph
- Registers the tool in
ToolsRepository’s class-level_local_toolslist (process-wide singleton). - Returns the original function unchanged:
calculate_sum(2, 3)still works as plain Python.
Examples
Async functions are supported
Optional parameters
Push to the agent graph
add_to_graph=True makes the tool visible in the platform’s graph view for the next agents.aget(...): the SDK sync runs in the background after aget returns.
Use the function directly
Visibility rules
The decorator registers tools at module-import time on a process-wide registry. That means:- Every agent loaded by
Agents().aget(...)in this process inherits the local tools. - Tools defined inside a function body register the first time the function runs, but stay registered for the rest of the process’s lifetime.
- If you
delor rename a function after decoration, the registeredToolkeeps its captured reference (thefnattribute): it doesn’t unregister itself.
Backend.aget_args(tools=[fn]) instead: that adds callables to one specific aget_args call without polluting the global registry.
Schema details
The generated schema uses Pydantic’smodel_json_schema(mode="serialization"). Parameter names, types, and defaults map directly:
Related
Toolclass: what the decorator creates.@on_tool_before/@on_tool_after/@on_tool_error: lifecycle hooks around any tool invocation.
Tool class
Tool represents a single callable an agent can invoke: a connector operation, an OpenAPI endpoint, an MCP tool, or a local Python function registered with @register_tool. You normally get one from agent.tools.list or agent.tools.get_tool_by_id(...).
Attributes
Computed properties
schema
tool.parameters. The model’s name is {ToolIdPascalCase}PayloadSchema. If the agent has schema overrides for this tool, they’re applied here.
payload_schema
payload field whose type is tool.schema. Useful when a framework expects every tool call to be wrapped in {"payload": {...}}.
Methods
ainvoke / invoke
Invoke the tool. Validates the payload against tool.schema, executes locally (is_local=True) or remotely, and returns a ToolInvocationResult.
Returns a
ToolInvocationResult (see below). Sync sibling: tool.invoke(...).
ainvoke runs the configured tool lifecycle hooks (@on_tool_before / @on_tool_after / @on_tool_error) around the call.
acall_remote_tool / call_remote_tool
Lower-level: makes the API call without local-tool fallback or hook execution. Used internally by ainvoke when is_local=False. Use directly only for advanced cases (preflight checks, custom invocation pipelines).
agraph_preflight_check / graph_preflight_check
Asks the platform to validate a hypothetical tool invocation without executing it. Used internally for graph routing.
get_invocation_function
connector_id_operation_id and returns the raw response wrapped in ToolInvocationResult. Use it after ToolsRepository.aload_tool_by_id(...) to call a single connector without an agent.
ToolInvocationResult
The shape returned by ainvoke and the standalone invocation function.
is_success and is_error are mutually exclusive in normal operation: check is_error first to branch on failure cases.
Examples
Inspect tool schema
Per-call configuration override
Reporting activity for non-Agno callers
When invoking a tool outside an Agno-driven flow (e.g. from your own agent loop), setreport_activity=True so the call shows up in the task’s activity log:
False: the Agno hook reports the call automatically and you’d otherwise double-emit events.
MCP types
The Model Context Protocol (MCP) lets agents connect to external tool servers. The SDK exposesMCPServerDetails for declaring servers per task, and a few enums for the supported transports and auth types.
Agent.acreate_task(mcp_servers=[...]) to attach servers for a single run; servers configured in the Workbench are added automatically.
MCPServerDetails
Enums
MCPServerType
MCPServerTransport
MCPServerAuthType
Examples
Local server (stdio)
Remote with API key
Remote with OAuth2
auth_events during a run when end-user authorization is required. Register an @on_auth_event handler to route the OAuth URL to your UI.
Per-task server attachment
Limit which tools are exposed
search_repositories and get_issue will be exposed to the agent: every other tool the server offers is hidden.
OAuth response types (for @on_auth_event payloads)
When OAuth flows fire, event.data is shaped like one of these:
MCPOAuthResponseType values: not_supported, login_required, token_issue, token_ready.
Use these in your auth handler to display the right state to the end user (login URL vs. “we’re working on it” vs. success).
