Skip to main content
Glama

check_disk_space

Monitor disk space usage on critical filesystem paths to detect low storage conditions and prevent system issues.

Instructions

[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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that executes the disk space check using 'df -h' on key paths, parses the output, detects low disk space with warnings (>80% or >90% used), and returns a structured dictionary with usage details.
    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 schema definition: no input parameters required, provides description for the tool in the server's list_tools().
    Tool( 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": {} } ),
  • Registers the execution handler in the MCP server's unified call_tool() dispatcher, calling the system.py function and formatting output as JSON.
    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 support, permissions, workflow, and related tools for discovery and usage guidance.
    "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 the check_disk_space function into the package namespace, making it available for server registration.
    from .system import ( get_system_info, check_disk_space,

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