75 lines
2.3 KiB
Python
75 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Verifica P6: tool live Irrigazione + Turni."""
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, "/srv" if os.path.isdir("/srv/app") else os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
def main() -> int:
|
|
from app.integrations import irrigazione, turni
|
|
from app.mcp import tools
|
|
|
|
user = os.environ.get("MCP_TEST_USER", "daniele")
|
|
claims = {
|
|
"sub": user,
|
|
"scope": "irrigation:read turni:read home:read admin",
|
|
}
|
|
errors = []
|
|
|
|
print("=== P6 integrations ===")
|
|
print("irrigazione configured:", irrigazione.is_configured(user))
|
|
print("turni configured:", turni.is_configured(user))
|
|
|
|
if irrigazione.is_configured(user):
|
|
for tool, args in (
|
|
("get_irrigation_status", {}),
|
|
("get_irrigation_zones", {}),
|
|
("get_irrigation_history", {"limit": 5}),
|
|
):
|
|
try:
|
|
out = tools.call_tool(tool, args, claims)
|
|
data = json.loads(out["content"][0]["text"])
|
|
print(f"OK {tool}: type={type(data).__name__}")
|
|
except Exception as exc:
|
|
print(f"FAIL {tool}: {exc}")
|
|
errors.append(tool)
|
|
else:
|
|
errors.append("irrigazione-not-configured")
|
|
|
|
try:
|
|
out = tools.call_tool("get_turni_status", {}, claims)
|
|
data = json.loads(out["content"][0]["text"])
|
|
print(f"OK get_turni_status: build={data.get('buildVersion', '')[:30]}")
|
|
except Exception as exc:
|
|
print(f"FAIL get_turni_status: {exc}")
|
|
errors.append("get_turni_status")
|
|
|
|
if turni.is_configured(user):
|
|
for tool, args in (
|
|
("list_turni_doctors", {}),
|
|
("get_my_shifts", {"limit": 10}),
|
|
):
|
|
try:
|
|
out = tools.call_tool(tool, args, claims)
|
|
data = json.loads(out["content"][0]["text"])
|
|
print(f"OK {tool}: keys={list(data.keys())[:6]}")
|
|
except Exception as exc:
|
|
print(f"FAIL {tool}: {exc}")
|
|
errors.append(tool)
|
|
else:
|
|
errors.append("turni-not-configured")
|
|
|
|
if errors:
|
|
print("P6 FAILED:", errors)
|
|
return 1
|
|
print("P6 OK")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|