ToolRegistry¶
Registry for organizing and managing tools.
Quick Example¶
from mamba_agents.tools import ToolRegistry
from mamba_agents.tools import read_file, write_file
registry = ToolRegistry()
# Register tools
registry.register(read_file)
registry.register(write_file)
# Get all tools
all_tools = registry.get_all()
# Use with agent
from mamba_agents import Agent
agent = Agent("gpt-4o", tools=all_tools)
API Reference¶
ToolRegistry
¶
Registry for managing tool functions.
Provides tool registration, enable/disable, and grouping functionality.
Initialize an empty tool registry.
Source code in src/mamba_agents/tools/registry.py
register
¶
register(
func: Callable[..., Any] | None = None,
*,
name: str | None = None,
description: str | None = None,
group: str | None = None,
) -> Callable[..., Any]
Register a tool function.
Can be used as a decorator with or without arguments.
| PARAMETER | DESCRIPTION |
|---|---|
func
|
The tool function to register.
TYPE:
|
name
|
Optional custom name (defaults to function name).
TYPE:
|
description
|
Optional description (defaults to docstring).
TYPE:
|
group
|
Optional group/namespace.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[..., Any]
|
The original function (for decorator use). |
Source code in src/mamba_agents/tools/registry.py
get
¶
Get a tool by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The tool name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ToolInfo | None
|
ToolInfo if found, None otherwise. |
get_enabled
¶
Get all enabled tools.
| RETURNS | DESCRIPTION |
|---|---|
list[ToolInfo]
|
List of enabled ToolInfo objects. |
get_by_group
¶
Get tools by group.
| PARAMETER | DESCRIPTION |
|---|---|
group
|
The group name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[ToolInfo]
|
List of ToolInfo objects in the group. |
Source code in src/mamba_agents/tools/registry.py
enable
¶
Enable a tool.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The tool name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the tool was found and enabled. |
Source code in src/mamba_agents/tools/registry.py
disable
¶
Disable a tool.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The tool name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the tool was found and disabled. |
Source code in src/mamba_agents/tools/registry.py
list_all
¶
as_functions
¶
Get all enabled tools as a list of functions.
| RETURNS | DESCRIPTION |
|---|---|
list[Callable[..., Any]]
|
List of tool functions. |