add tool list routes

This commit is contained in:
NA-Wen 2026-03-11 12:06:33 +08:00
parent 7494bad618
commit d48e82f17e
3 changed files with 33 additions and 3 deletions

View File

@ -43,4 +43,4 @@ validate-yamls: ## Validate all YAML configuration files
help: ## Display this help message
@python -c "import re; \
p=r'$(firstword $(MAKEFILE_LIST))'.strip(); \
[print(f'{m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(p, encoding='utf-8').read(), re.M)]" | sort
[print(f'{m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(p, encoding='utf-8').read(), re.M)]" | sort

View File

@ -1,6 +1,6 @@
"""Aggregates API routers."""
from . import artifacts, execute, execute_sync, health, sessions, uploads, vuegraphs, workflows, websocket, batch
from . import artifacts, execute, execute_sync, health, sessions, uploads, vuegraphs, workflows, websocket, batch, tools
ALL_ROUTERS = [
health.router,
@ -12,7 +12,8 @@ ALL_ROUTERS = [
batch.router,
execute.router,
execute_sync.router,
tools.router,
websocket.router,
]
__all__ = ["ALL_ROUTERS"]
__all__ = ["ALL_ROUTERS"]

29
server/routes/tools.py Normal file
View File

@ -0,0 +1,29 @@
from fastapi import APIRouter
from utils.function_catalog import get_function_catalog
router = APIRouter()
@router.get("/api/tools/local")
def list_local_tools():
catalog = get_function_catalog()
metadata = catalog.list_metadata()
tools = []
for name, meta in metadata.items():
tools.append(
{
"name": name,
"description": meta.description,
"parameters": meta.parameters_schema,
"module": meta.module_name,
"file_path": meta.file_path,
}
)
tools.sort(key=lambda item: item["name"])
return {
"success": True,
"count": len(tools),
"tools": tools,
"load_error": str(catalog.load_error) if catalog.load_error else None,
}