Skip to main content
Glama

get_database_sync_history

Retrieve synchronization history showing when package database updates were performed on Arch Linux systems using pacman -Sy command.

Instructions

Get database synchronization history. Shows when 'pacman -Sy' was run. Only works on Arch Linux.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of sync events to return (default 20)

Implementation Reference

  • The core handler function that implements the tool logic by parsing /var/log/pacman.log for 'synchronizing package lists' and 'starting full system upgrade' events, returning recent sync history.
    async def get_database_sync_history(limit: int = 20) -> Dict[str, Any]: """ Get database synchronization history. Shows when 'pacman -Sy' was run. Args: limit: Maximum number of sync events to return (default 20) Returns: Dict with database sync history """ if not IS_ARCH: return create_error_response( "NotSupported", "This feature is only available on Arch Linux" ) logger.info(f"Getting database sync history (limit={limit})") try: pacman_log = Path(PACMAN_LOG) if not pacman_log.exists(): return create_error_response( "NotFound", f"Pacman log file not found at {PACMAN_LOG}" ) sync_events = [] with open(pacman_log, 'r') as f: lines = f.readlines() # Process in reverse order for most recent first for line in reversed(lines): if len(sync_events) >= limit: break # Look for database synchronization entries if "synchronizing package lists" in line.lower() or "starting full system upgrade" in line.lower(): timestamp_match = re.match(r'\[(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2})\]', line) if timestamp_match: timestamp = f"{timestamp_match.group(1)}T{timestamp_match.group(2)}:00" event_type = "sync" if "starting full system upgrade" in line.lower(): event_type = "full_upgrade" sync_events.append({ "timestamp": timestamp, "type": event_type, "message": line.strip() }) logger.info(f"Found {len(sync_events)} sync events") return { "count": len(sync_events), "sync_events": sync_events } except Exception as e: logger.error(f"Failed to get sync history: {e}") return create_error_response( "LogParseError", f"Failed to get database sync history: {str(e)}" )
  • MCP tool registration in @server.list_tools(), including the tool name, description, and input schema definition.
    Tool( name="get_database_sync_history", description="[HISTORY] Get database synchronization history. Shows when 'pacman -Sy' was run. Only works on Arch Linux.", inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Maximum number of sync events to return (default 20)", "default": 20 } }, "required": [] } ),
  • Tool dispatcher in @server.call_tool() that validates platform and invokes the actual handler with arguments.
    elif name == "get_database_sync_history": if not IS_ARCH: return [TextContent(type="text", text="Error: get_database_sync_history only available on Arch Linux systems")] limit = arguments.get("limit", 20) result = await get_database_sync_history(limit=limit) return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Tool metadata definition categorizing it under 'history', specifying platform requirements and related tools.
    "get_database_sync_history": ToolMetadata( name="get_database_sync_history", category="history", platform="arch", permission="read", workflow="audit", related_tools=["check_database_freshness"], 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