Skip to main content
Glama

get_pacman_cache_stats

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

Instructions

[MONITORING] 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

  • Core implementation of the get_pacman_cache_stats tool: checks for Arch Linux, scans /var/cache/pacman/pkg for .pkg.tar.* files, computes count and total size in bytes/MB/GB, logs results, handles errors with standardized 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 server registration of the tool in list_tools(), defining name, description, and empty input schema (no parameters required).
    Tool( 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": {} } ),
  • JSON schema for tool input: empty object since the tool takes no parameters.
    inputSchema={ "type": "object", "properties": {} }
  • Dispatcher in call_tool() that invokes the handler if on Arch Linux, wraps result in TextContent with JSON, handles platform check.
    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))]
  • ToolMetadata providing categorization (monitoring), platform (arch), permission (read), workflow (diagnose), and related tools for discovery and organization.
    "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=[] ),

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