Newer
Older
navi-1 / navi / tools / list_tools.py
"""Built-in tool that returns the current list of available tools."""

from .base import Tool, ToolResult


class ListToolsTool(Tool):
    name = "list_tools"
    description = (
        "Returns the actual list of tools currently available to you, with their descriptions. "
        "Call this when asked what you can do, or before creating a new tool to check if it already exists."
    )
    parameters = {
        "type": "object",
        "properties": {},
        "required": [],
    }

    def __init__(self, registry=None) -> None:
        self._registry = registry

    async def execute(self, params: dict) -> ToolResult:
        if self._registry is None:
            return ToolResult(success=False, output="Registry not available.", error="no_registry")

        lines = []
        for tool in self._registry.all():
            lines.append(f"• {tool.name}: {tool.description}")

        return ToolResult(success=True, output="\n".join(lines))