"""Storage tools — disk space queries across the media stack.""" from ._common import arr_get def sonarr_disk_space(): """Disk space on the paths Sonarr cares about (Plex TV Shows mount, downloads, etc.).""" data = arr_get("sonarr", "/api/v3/diskspace") out = [] for d in data: out.append({ "path": d.get("path"), "label": d.get("label"), "total_tb": round((d.get("totalSpace", 0) or 0) / 1e12, 2), "free_tb": round((d.get("freeSpace", 0) or 0) / 1e12, 2), "free_pct": round(100 * (d.get("freeSpace", 0) or 0) / max((d.get("totalSpace", 0) or 1), 1), 1), }) return {"mounts": out} TOOLS = [ { "name": "storage_disk_space", "description": "Report free / total disk space for each mount visible to Sonarr (covers the Plex library mounts, downloads, and any attached shares). Use when the user asks 'how much space is left', 'is the NAS full', 'how much room on Darrow'.", "input_schema": {"type": "object", "properties": {}}, "read_only": True, "fn": sonarr_disk_space, }, ]