Skip to main content
Glama

check_database_freshness

Verify when Arch Linux package databases were last updated and identify if they are stale (older than 24 hours) to ensure reliable package management operations.

Instructions

Check when package databases were last synchronized. Warns if databases are stale (> 24 hours). Only works on Arch Linux.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that implements the check_database_freshness tool. It examines the modification times of pacman database files in /var/lib/pacman/sync to determine freshness and provides warnings and recommendations.
    async def check_database_freshness() -> Dict[str, Any]: """ Check when package databases were last synchronized. Returns: Dict with database sync timestamps per repository """ if not IS_ARCH: return create_error_response( "NotSupported", "Database freshness check is only available on Arch Linux" ) logger.info("Checking database freshness") try: from pathlib import Path from datetime import datetime, timedelta sync_dir = Path("/var/lib/pacman/sync") if not sync_dir.exists(): return create_error_response( "NotFound", "Pacman sync directory not found" ) # Get all .db files db_files = list(sync_dir.glob("*.db")) if not db_files: return create_error_response( "NotFound", "No database files found" ) databases = [] now = datetime.now() oldest_db = None oldest_age = timedelta(0) for db_file in db_files: mtime = datetime.fromtimestamp(db_file.stat().st_mtime) age = now - mtime hours_old = age.total_seconds() / 3600 db_info = { "repository": db_file.stem, # Remove .db extension "last_sync": mtime.isoformat(), "hours_old": round(hours_old, 1) } # Warn if older than 24 hours if hours_old > 24: db_info["warning"] = f"Database is {hours_old:.0f} hours old (> 24h)" databases.append(db_info) # Track oldest if oldest_db is None or age > oldest_age: oldest_db = db_info["repository"] oldest_age = age # Sort by hours_old descending (oldest first) databases.sort(key=lambda x: x["hours_old"], reverse=True) logger.info(f"Checked {len(databases)} databases, oldest: {oldest_age.total_seconds() / 3600:.1f}h") recommendations = [] if oldest_age.total_seconds() / 3600 > 24: recommendations.append("Databases are stale (> 24h). Run 'sudo pacman -Sy' to synchronize.") if oldest_age.total_seconds() / 3600 > 168: # 1 week recommendations.append("Databases are very stale (> 1 week). Consider full system update.") return { "database_count": len(databases), "databases": databases, "oldest_database": oldest_db, "oldest_age_hours": round(oldest_age.total_seconds() / 3600, 1), "recommendations": recommendations, "needs_sync": oldest_age.total_seconds() / 3600 > 24 } except Exception as e: logger.error(f"Failed to check database freshness: {e}") return create_error_response( "CheckError", f"Failed to check database freshness: {str(e)}" )
  • MCP tool registration in @server.list_tools(), including the tool name, description, and empty input schema (no parameters).
    Tool( name="check_database_freshness", description="[MAINTENANCE] Check when package databases were last synchronized. Warns if databases are stale (> 24 hours). Only works on Arch Linux.", inputSchema={ "type": "object", "properties": {} } ),
  • The input schema definition for the tool (empty object since no input parameters required). Note: output handled by the handler function.
    Tool( name="check_database_freshness", description="[MAINTENANCE] Check when package databases were last synchronized. Warns if databases are stale (> 24 hours). Only works on Arch Linux.", inputSchema={ "type": "object", "properties": {} } ),
  • Tool metadata providing categorization, platform requirements, permissions, workflow info, and related tools.
    "check_database_freshness": ToolMetadata( name="check_database_freshness", category="maintenance", platform="arch", permission="read", workflow="verify", related_tools=["get_database_sync_history"], prerequisite_tools=[] ),
  • Tool dispatch logic in @server.call_tool() that invokes the handler function and formats the JSON response.
    elif name == "check_database_freshness": if not IS_ARCH: return [TextContent(type="text", text="Error: check_database_freshness only available on Arch Linux systems")] result = await check_database_freshness() 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