Skip to main content
Glama

get_pacman_cache_stats

Analyze pacman package cache statistics on Arch Linux to monitor cache size, package count, and cache age for system maintenance.

Instructions

Analyze pacman package cache statistics including size, package count, and cache age. Only works on Arch Linux.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that implements the tool logic: checks if on Arch Linux, scans /var/cache/pacman/pkg for .pkg.tar.* files, counts them, computes total size in bytes/MB/GB, logs info, returns structured stats or error responses.
    async def get_pacman_cache_stats() -> Dict[str, Any]: """ Analyze pacman package cache. Returns: Dict with cache size, package count, statistics """ if not IS_ARCH: return create_error_response( "NotSupported", "Pacman cache analysis is only available on Arch Linux" ) logger.info("Analyzing pacman cache") cache_dir = Path("/var/cache/pacman/pkg") try: if not cache_dir.exists(): return create_error_response( "NotFound", "Pacman cache directory not found" ) # Count packages pkg_files = list(cache_dir.glob("*.pkg.tar.*")) pkg_count = len(pkg_files) # Calculate total size total_size = sum(f.stat().st_size for f in pkg_files) total_size_mb = total_size / (1024 * 1024) total_size_gb = total_size_mb / 1024 logger.info(f"Cache: {pkg_count} packages, {total_size_gb:.2f} GB") return { "cache_dir": str(cache_dir), "package_count": pkg_count, "total_size_bytes": total_size, "total_size_mb": round(total_size_mb, 2), "total_size_gb": round(total_size_gb, 2) } except Exception as e: logger.error(f"Failed to analyze cache: {e}") return create_error_response( "CacheAnalysisError", f"Failed to analyze pacman cache: {str(e)}" )
  • MCP tool registration in list_tools(): defines tool name, description, and input schema (no input parameters required).
    name="get_pacman_cache_stats", description="[MONITORING] Analyze pacman package cache statistics including size, package count, and cache age. Only works on Arch Linux.", inputSchema={ "type": "object", "properties": {} } ),
  • Tool metadata schema defining category (monitoring), platform (arch), permission (read), workflow (diagnose), and related tool (check_disk_space).
    "get_pacman_cache_stats": ToolMetadata( name="get_pacman_cache_stats", category="monitoring", platform="arch", permission="read", workflow="diagnose", related_tools=["check_disk_space"], prerequisite_tools=[] ),
  • Tool dispatch logic in call_tool(): checks IS_ARCH, calls the handler function, serializes result to JSON and returns as TextContent.
    elif name == "get_pacman_cache_stats": if not IS_ARCH: return [TextContent(type="text", text="Error: get_pacman_cache_stats only available on Arch Linux systems")] result = await get_pacman_cache_stats() return [TextContent(type="text", text=json.dumps(result, indent=2))]

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