check_updates_dry_run
Check for pending system updates on Arch Linux without applying them. Displays upgrade packages and sizes for safe review before updating.
Instructions
[LIFECYCLE] Check for available system updates without applying them. Only works on Arch Linux systems. Requires pacman-contrib package. Safe read-only operation that shows pending updates. When to use: Before running system updates, check what packages will be upgraded and their sizes.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "check_updates_dry_run"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/arch_ops_server/pacman.py:219-290 (handler)Core handler function for check_updates_dry_run. Checks for Arch Linux, validates checkupdates command exists, runs 'checkupdates', parses output, and returns list of available updates or error responses.
async def check_updates_dry_run() -> Dict[str, Any]: """ Check for available system updates without applying them. Only works on Arch Linux systems with checkupdates command. Requires pacman-contrib package. Returns: Dict with list of available updates or error response """ logger.info("Checking for system updates (dry run)") # Only supported on Arch Linux if not IS_ARCH: return create_error_response( "NotSupported", "Update checking is only supported on Arch Linux systems", "This server is not running on Arch Linux" ) # Check if checkupdates command exists if not check_command_exists("checkupdates"): return create_error_response( "CommandNotFound", "checkupdates command not found", "Install pacman-contrib package: pacman -S pacman-contrib" ) try: exit_code, stdout, stderr = await run_command( ["checkupdates"], timeout=30, # Can take longer for sync check=False ) # Exit code 0: updates available # Exit code 2: no updates available # Other: error if exit_code == 2 or not stdout.strip(): logger.info("No updates available") return { "updates_available": False, "count": 0, "packages": [] } if exit_code != 0: logger.error(f"checkupdates failed with code {exit_code}: {stderr}") return create_error_response( "CommandError", f"checkupdates command failed: {stderr}", f"Exit code: {exit_code}" ) # Parse checkupdates output updates = _parse_checkupdates_output(stdout) logger.info(f"Found {len(updates)} available updates") return { "updates_available": True, "count": len(updates), "packages": updates } except Exception as e: logger.error(f"Update check failed: {e}") return create_error_response( "UpdateCheckError", f"Failed to check for updates: {str(e)}" ) - Helper function that parses the raw output from the checkupdates command, extracting package name, current version, and new version using regex.
def _parse_checkupdates_output(output: str) -> List[Dict[str, str]]: """ Parse checkupdates command output. Format: "package current_version -> new_version" Args: output: Raw checkupdates output Returns: List of update dicts """ updates = [] for line in output.strip().split('\n'): if not line.strip(): continue # Match pattern: "package old_ver -> new_ver" match = re.match(r'^(\S+)\s+(\S+)\s+->\s+(\S+)$', line) if match: updates.append({ "package": match.group(1), "current_version": match.group(2), "new_version": match.group(3) }) return updates - src/arch_ops_server/server.py:688-696 (registration)Tool registration in list_tools() - defines the tool name, description, empty input schema, and read-only annotation for the MCP server.
Tool( name="check_updates_dry_run", description="[LIFECYCLE] Check for available system updates without applying them. Only works on Arch Linux systems. Requires pacman-contrib package. Safe read-only operation that shows pending updates. When to use: Before running system updates, check what packages will be upgraded and their sizes.", inputSchema={ "type": "object", "properties": {} }, annotations=ToolAnnotations(readOnlyHint=True) ), - src/arch_ops_server/server.py:1120-1125 (registration)Tool dispatch in call_tool() - routes the 'check_updates_dry_run' tool name to the actual handler, with platform check.
elif name == "check_updates_dry_run": if not IS_ARCH: return [TextContent(type="text", text=create_platform_error_message("check_updates_dry_run"))] result = await check_updates_dry_run() return [TextContent(type="text", text=json.dumps(result, indent=2))] - Tool metadata definition: marks the tool as category='lifecycle', platform='arch', permission='read', workflow='update' with related tools.
"check_updates_dry_run": ToolMetadata( name="check_updates_dry_run", category="lifecycle", platform="arch", permission="read", workflow="update", related_tools=["check_critical_news", "check_disk_space"], prerequisite_tools=[] ),