Skip to main content
Glama

check_disk_space

Monitor disk space usage on critical filesystem paths like root, home, var, and pacman cache. Get alerts when storage capacity runs low to prevent system issues.

Instructions

Check disk space usage for critical filesystem paths including root, home, var, and pacman cache. Warns when space is low. Works on any system.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that executes the check_disk_space tool. It checks disk usage on key paths (/, /home, /var, and Arch-specific pacman cache), parses df -h output, adds warnings for low space, and returns structured results.
    async def check_disk_space() -> Dict[str, Any]: """ Check disk space for critical paths. Returns: Dict with disk usage for /, /home, /var, /var/cache/pacman/pkg """ logger.info("Checking disk space") paths_to_check = ["/", "/home", "/var"] if IS_ARCH: paths_to_check.append("/var/cache/pacman/pkg") disk_info = {} try: for path in paths_to_check: if not Path(path).exists(): continue exit_code, stdout, _ = await run_command( ["df", "-h", path], timeout=5, check=False ) if exit_code == 0: lines = stdout.strip().split('\n') if len(lines) >= 2: # Parse df output parts = lines[1].split() if len(parts) >= 5: disk_info[path] = { "size": parts[1], "used": parts[2], "available": parts[3], "use_percent": parts[4], "mounted_on": parts[5] if len(parts) > 5 else path } # Check if space is critically low use_pct = int(parts[4].rstrip('%')) if use_pct > 90: disk_info[path]["warning"] = "Critical: Less than 10% free" elif use_pct > 80: disk_info[path]["warning"] = "Low: Less than 20% free" logger.info(f"Checked disk space for {len(disk_info)} paths") return { "disk_usage": disk_info, "paths_checked": len(disk_info) } except Exception as e: logger.error(f"Failed to check disk space: {e}") return create_error_response( "DiskCheckError", f"Failed to check disk space: {str(e)}" )
  • MCP tool registration in list_tools(), defining the tool name, description, and empty input schema (no parameters required).
    name="check_disk_space", description="[MONITORING] Check disk space usage for critical filesystem paths including root, home, var, and pacman cache. Warns when space is low. Works on any system.", inputSchema={ "type": "object", "properties": {} } ),
  • Dispatch logic in call_tool() that invokes the check_disk_space handler and formats the response as JSON text content.
    elif name == "check_disk_space": result = await check_disk_space() return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Tool metadata defining category, platform, permissions, workflow, and related tools for check_disk_space.
    "check_disk_space": ToolMetadata( name="check_disk_space", category="monitoring", platform="any", permission="read", workflow="diagnose", related_tools=["get_pacman_cache_stats", "list_orphan_packages"], prerequisite_tools=[]
  • Imports helper functions used by the handler: IS_ARCH to conditionally check pacman cache, run_command to execute df, create_error_response for error handling.
    from .utils import ( IS_ARCH, run_command, create_error_response, check_command_exists )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nihalxkumar/arch-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server