Skip to main content
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.
You don’t usually instantiate 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

A merged list of backend tools and locally-registered tools (de-duplicated by id). Each tool has its Configuration set and any agent-graph schema overrides applied.

functions

Framework-ready callables for every tool in .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

Returns the tool with the matching id, or None.

get_tool_by_name

Returns the tool with the matching name (display name), or None.

register_tool (classmethod)

Adds a tool to the global local registry. Used by the @register_tool decorator: you don’t usually call this directly.

should_sync_local_tools

Returns 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

Returns local tools awaiting sync (used internally during agent.aload).

aload_tool_by_id

Standalone tool loading: looks up a tool by its <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)

This pattern is how you call a single platform connector without going through an agent.

@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.
After this runs (typically at module import), calculate_sum is available to every Agents().aget(...) call as a local tool with id "calculate_sum".

Decorator forms

What it does

  1. Inspects the function’s parameters and type hints.
  2. Builds a Pydantic model (<FunctionName>Args) from the parameters: required if no default, optional otherwise.
  3. Constructs a Tool with:
    • id = function name
    • name = function name
    • description = function docstring
    • parameters = generated JSON schema
    • fn = the function
    • is_local = True
    • should_add_to_graph = add_to_graph
  4. Registers the tool in ToolsRepository’s class-level _local_tools list (process-wide singleton).
  5. Returns the original function unchanged: calculate_sum(2, 3) still works as plain Python.

Examples

Async functions are supported

When the agent calls this tool, the SDK awaits the coroutine.

Optional parameters

Defaults become optional fields in the JSON schema.

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 del or rename a function after decoration, the registered Tool keeps its captured reference (the fn attribute): it doesn’t unregister itself.
For per-invocation tools, use 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’s model_json_schema(mode="serialization"). Parameter names, types, and defaults map directly:
generates roughly:
The agent’s LLM sees this schema; the docstring becomes the tool’s description. Write docstrings the way you’d write a tool description: that’s exactly what the LLM reads.

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

A dynamically-generated Pydantic model class derived from tool.parameters. The model’s name is {ToolIdPascalCase}PayloadSchema. If the agent has schema overrides for this tool, they’re applied here.

payload_schema

A wrapper schema with a single 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

Factory that returns a pre-configured invocation function bound to this tool’s connector + configuration. Use for standalone invocation (no agent context):
This skips agent-id and task-id binding: the underlying call hits the connector via 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), set report_activity=True so the call shows up in the task’s activity log:
Inside Agno-driven flows, leave it at 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 exposes MCPServerDetails for declaring servers per task, and a few enums for the supported transports and auth types.
You typically pass a list of these to 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

OAuth2 servers fire 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

These are appended to the agent’s persistent MCP config for this task only.

Limit which tools are exposed

Only 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).