Tools Discover

Discover tools from all available sources via ToolResolver

ToolResolver.list_available_sources() is the single entry point for discovering tools from every source — local tools.py, built-in agents tools, the praisonai-tools package, and registered or plugin tools.

Quick Start

python
from praisonai.tool_resolver import ToolResolver

resolver = ToolResolver()
sources = resolver.list_available_sources()

# sources is a dict of {tool_name: source_label}
print(f"Total tools available: {len(sources)}")
for name, source in list(sources.items())[:10]:
    print(f"  {name}: {source}")

Filter by Source Bucket

python
from praisonai.tool_resolver import ToolResolver

resolver = ToolResolver()
sources = resolver.list_available_sources()

local      = [n for n, s in sources.items() if s == "local"]
builtin    = [n for n, s in sources.items() if s == "builtin"]
external   = [n for n, s in sources.items() if s == "external"]
registered = [n for n, s in sources.items() if s == "registered"]

print(f"Local tools ({len(local)}):      {local}")
print(f"Built-in tools ({len(builtin)}): {builtin[:5]}...")
print(f"External tools ({len(external)}): {external[:5]}...")
print(f"Registered tools ({len(registered)}): {registered}")

Source bucket reference:

SourceWhat it includes
localFunctions and classes from your local tools.py
builtinTools shipped with praisonaiagents.tools
externalTools from the optional praisonai-tools package
registeredTools added via ToolRegistry.register_function() or an entry-point plugin under the canonical praisonai.tools group (or its deprecated praisonaiagents.tools / praisonai.tool_sources aliases)
mcpTools from MCP servers configured under mcp.servers.*. CLI listing only — not returned by list_available_sources(); surfaced live by praisonai tools list

Check a Single Tool

python
from praisonai.tool_resolver import ToolResolver

resolver = ToolResolver()

# has_tool() uses the same chain without loading the callable
if resolver.has_tool("internet_search"):
    source = resolver.list_available_sources().get("internet_search")
    print(f"internet_search is available from: {source}")

CLI Equivalent

bash
# Same resolver-backed enumeration from the command line
praisonai tools list

# Filter by bucket
praisonai tools list --source registered
praisonai tools list --source external
praisonai tools list --source local
praisonai tools list --source builtin

# MCP tools from configured mcp.servers.* (CLI-only, live)
praisonai tools list --source mcp

# Full diagnostics (same source of truth)
praisonai tools doctor

How It Works

Diagram

praisonai tools list (CLI only)

ToolResolver.list_available_sources()

local\ntools.py

Dict[name, source]

builtin\npraisonaiagents.tools

external\npraisonai-tools

registered\nToolRegistry / plugins

mcp\nmcp.servers.* (live)

Merged listing

list_available_sources() reflects the same four-source chain that resolve() uses at run time. Every name returned can be passed to resolve(name) and will load successfully — no more “visible in list, fails at runtime” mismatches.

Legacy Discovery (Pre-#2476)

Raw importlib / TOOL_MAPPINGS pattern (deprecated)

Before ToolResolver.list_available_sources() was introduced in PR #2476, each surface walked its own partial subset:

python
# Old pattern — only sees TOOL_MAPPINGS, misses registered/plugin tools
from praisonaiagents import TOOL_MAPPINGS

for tool_name in list(TOOL_MAPPINGS.keys())[:10]:
    print(f"Built-in: {tool_name}")
python
# Old pattern — only sees praisonai_tools, misses builtin/registered
import praisonai_tools.tools as ext_tools
for name in dir(ext_tools):
    if not name.startswith('_') and callable(getattr(ext_tools, name, None)):
        print(f"Found: {name}")

Use ToolResolver.list_available_sources() instead — it covers all four sources in a single call.

Related