list_pools
Retrieve and display all available storage pools on TrueNAS Core systems using this tool, enabling efficient storage monitoring and management.
Instructions
List all storage pools
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"title": "list_poolsArguments",
"type": "object"
}
Implementation Reference
- The handler function that implements the list_pools tool. It retrieves pool data from the TrueNAS API, calculates usage statistics, formats sizes, processes topology, and returns a structured response with pools list and metadata.async def list_pools(self) -> Dict[str, Any]: """ List all storage pools Returns: Dictionary containing list of pools with their status """ await self.ensure_initialized() pools = await self.client.get("/pool") pool_list = [] for pool in pools: # Calculate usage percentage size = pool.get("size", 0) allocated = pool.get("allocated", 0) free = pool.get("free", 0) usage_percent = (allocated / size * 100) if size > 0 else 0 pool_info = { "name": pool.get("name"), "status": pool.get("status"), "healthy": pool.get("healthy"), "encrypted": pool.get("encrypt", 0) > 0, "size": self.format_size(size), "allocated": self.format_size(allocated), "free": self.format_size(free), "usage_percent": round(usage_percent, 2), "fragmentation": pool.get("fragmentation"), "scan": pool.get("scan", {}).get("state") if pool.get("scan") else None, "topology": { "data_vdevs": len(pool.get("topology", {}).get("data", [])), "cache_vdevs": len(pool.get("topology", {}).get("cache", [])), "log_vdevs": len(pool.get("topology", {}).get("log", [])), "spare_vdevs": len(pool.get("topology", {}).get("spare", [])) } } pool_list.append(pool_info) # Calculate totals total_size = sum(p.get("size", 0) for p in pools) total_allocated = sum(p.get("allocated", 0) for p in pools) total_free = sum(p.get("free", 0) for p in pools) return { "success": True, "pools": pool_list, "metadata": { "pool_count": len(pool_list), "healthy_pools": sum(1 for p in pool_list if p["healthy"]), "degraded_pools": sum(1 for p in pool_list if not p["healthy"]), "total_capacity": self.format_size(total_size), "total_allocated": self.format_size(total_allocated), "total_free": self.format_size(total_free), "overall_usage_percent": round((total_allocated / total_size * 100) if total_size > 0 else 0, 2) } }
- truenas_mcp_server/tools/storage.py:12-33 (registration)The get_tool_definitions method registers the list_pools tool (line 15) along with other storage tools. The registration tuple specifies the tool name, handler method, description, and input schema (empty dict for list_pools).def get_tool_definitions(self) -> list: """Get tool definitions for storage management""" return [ ("list_pools", self.list_pools, "List all storage pools", {}), ("get_pool_status", self.get_pool_status, "Get detailed status of a specific pool", {"pool_name": {"type": "string", "required": True}}), ("list_datasets", self.list_datasets, "List all datasets", {}), ("get_dataset", self.get_dataset, "Get detailed information about a dataset", {"dataset": {"type": "string", "required": True}}), ("create_dataset", self.create_dataset, "Create a new dataset", {"pool": {"type": "string", "required": True}, "name": {"type": "string", "required": True}, "compression": {"type": "string", "required": False}, "quota": {"type": "string", "required": False}, "recordsize": {"type": "string", "required": False}}), ("delete_dataset", self.delete_dataset, "Delete a dataset", {"dataset": {"type": "string", "required": True}, "recursive": {"type": "boolean", "required": False}}), ("update_dataset", self.update_dataset, "Update dataset properties", {"dataset": {"type": "string", "required": True}, "properties": {"type": "object", "required": True}}), ]
- Input schema for list_pools tool: empty dictionary indicating no required parameters.("list_pools", self.list_pools, "List all storage pools", {}),