[TOOLS] Tool Gateway подключён к секретарю через MCP: mcp.servers.toolgateway (stdio, env TG_URL/TG_TOKEN), агент вызывает 10 инструментов нативно. Проверено: hub.status (74/0), calendar.create (201, удалено), ha.states+ha.call (свет), аудит в SQLite. Добавлены ретрай hub.status, валидация аргументов (400), selfcheck-проверка Tool Gateway. Дальше: подтверждения через Matrix, rate limit, family-токен

This commit is contained in:
root committed 2026-11-17 16:19:51 +03:00
1 parent 623acdc690
commit a026315f08
5 files changed
+187 -3

No files matched your search

+19 -1
View File
@@ -63,7 +63,16 @@ def basic(user, pw):
# ---------- инструменты ----------
def t_hub_status(args):
st, body = http("GET", HUB + "/status.json")
last = None
for _ in range(3):
try:
st, body = http("GET", HUB + "/status.json", timeout=30)
break
except Exception as e:
last = e
time.sleep(2)
else:
raise last or RuntimeError("hub status unavailable")
d = json.loads(body)
svc = d.get("services", [])
down = [s["name"] for s in svc if not s.get("up")]
@@ -261,6 +270,15 @@ class Handler(BaseHTTPRequestHandler):
if actor not in allowed:
return self._send(403, {"error": "forbidden for actor", "actor": actor,
"allowed": allowed})
required = {
"ha.call": ["domain", "service"],
"calendar.create": ["title", "start"],
"hub.notify": ["message"],
}.get(tool, [])
missing = [k for k in required if not args.get(k)]
if missing:
return self._send(400, {"error": "missing_args", "missing": missing,
"tool": tool, "required": required})
if spec["confirm"] and not req.get("confirm"):
return self._send(409, {"error": "confirmation_required", "tool": tool,
"hint": "повторите с confirm=true"})