get_disk_info_tool
Check disk usage on any specified path or all mounted disks to manage storage effectively.
Instructions
Retrieve disk usage information.
Args: path: Specific path to check (default: all mounted disks)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/system_info_mcp/tools.py:114-176 (handler)Actual implementation of get_disk_info - retrieves disk usage information. If a specific path is given, gets usage for that mountpoint; otherwise iterates all partitions via psutil.disk_partitions(). Returns a dict with a 'disks' list containing mountpoint, device, fstype, total/used/free bytes, percent usage, and GB-converted values. Uses @cache_result decorator with 10s TTL.
@cache_result("disk_info", ttl=10) def get_disk_info(path: Optional[str] = None) -> Dict[str, Any]: """Retrieve disk usage information.""" try: disks = [] if path: # Get info for specific path try: usage = psutil.disk_usage(path) disks.append( { "mountpoint": path, "device": "N/A", "fstype": "N/A", "total": usage.total, "used": usage.used, "free": usage.free, "percent": round((usage.used / usage.total) * 100, 1), "total_gb": bytes_to_gb(usage.total), "used_gb": bytes_to_gb(usage.used), "free_gb": bytes_to_gb(usage.free), } ) except (OSError, PermissionError) as e: logger.warning(f"Could not get disk info for path {path}: {e}") else: # Get info for all mounted disks partitions = psutil.disk_partitions() for partition in partitions: try: usage = psutil.disk_usage(partition.mountpoint) disks.append( { "mountpoint": partition.mountpoint, "device": partition.device, "fstype": partition.fstype, "total": usage.total, "used": usage.used, "free": usage.free, "percent": ( round((usage.used / usage.total) * 100, 1) if usage.total else 0 ), "total_gb": bytes_to_gb(usage.total), "used_gb": bytes_to_gb(usage.used), "free_gb": bytes_to_gb(usage.free), } ) except (OSError, PermissionError) as e: logger.warning( f"Could not get usage for {partition.mountpoint}: {e}" ) continue return {"disks": disks} except Exception as e: logger.error(f"Error getting disk info: {e}") raise - src/system_info_mcp/tools.py:115-115 (schema)Type signature: get_disk_info(path: Optional[str] = None) -> Dict[str, Any] - the path parameter is optional; when None all mounted disks are returned.
def get_disk_info(path: Optional[str] = None) -> Dict[str, Any]: - src/system_info_mcp/server.py:52-59 (registration)Tool registration via @app.tool() decorator. get_disk_info_tool is the MCP tool wrapper that delegates to get_disk_info(path=path) from the tools module.
@app.tool() def get_disk_info_tool(path: Optional[str] = None) -> Dict[str, Any]: """Retrieve disk usage information. Args: path: Specific path to check (default: all mounted disks) """ return get_disk_info(path=path) - src/system_info_mcp/server.py:9-17 (registration)Import of get_disk_info from .tools module into the server.py where the tool is registered.
from .tools import ( get_cpu_info, get_memory_info, get_disk_info, get_network_info, get_process_list, get_system_uptime, get_temperature_info, ) - src/system_info_mcp/resources.py:8-8 (helper)get_disk_info is also imported in resources.py and used in get_system_overview() to build a comprehensive system snapshot resource.
get_disk_info,