Coverage for app / routers / tools.py: 93%
15 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-31 11:23 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-31 11:23 +0000
1from typing import Any
3from fastapi import APIRouter
4from pydantic import BaseModel
6from app.tools.registry import BUILTIN_TOOLS
8router = APIRouter(prefix="/tools", tags=["tools"])
11class ToolInfo(BaseModel):
12 name: str
13 description: str
14 category: str # "general" | "specialist"
15 schema: dict[str, Any]
18class ToolListResponse(BaseModel):
19 tools: list[ToolInfo]
22@router.get("/available", response_model=ToolListResponse)
23def list_available_tools() -> ToolListResponse:
24 """Return all built-in tools with their category.
26 ``category`` is "general" for tools auto-injected into every agent and
27 "specialist" for tools that must be explicitly configured.
28 Sourced from the BUILTIN_TOOLS registry so the list stays in sync with
29 registered implementations automatically.
30 """
31 return ToolListResponse(
32 tools=[
33 ToolInfo(
34 name=defn.name,
35 description=defn.description,
36 category=defn.category.value,
37 schema=defn.schema,
38 )
39 for defn in BUILTIN_TOOLS.values()
40 ]
41 )