tool_loader

Auto-discover and load tools from a directory of Python scripts.

Each .py file in the tools directory must expose either:

Single-tool format (one tool per file):

  • TOOL_NAME – unique name for the tool (str).

  • TOOL_DESCRIPTION – human-readable description (str).

  • TOOL_PARAMETERS – JSON Schema object for accepted args (dict).

  • async def run(**kwargs) -> str – the tool handler.

Multi-tool format (multiple tools per file):

  • TOOLS – a list of dicts, each with keys: name, description, parameters, handler.

Malformed files are logged as warnings but do not prevent the rest of the tools from loading.

tool_loader.load_tools(directory, registry)[source]

Scan directory for .py tool scripts and register them.

Parameters:
  • directory (str | Path) – Path to the tools directory (e.g. "tools").

  • registry (ToolRegistry) – The ToolRegistry to register discovered tools into.

Return type:

None