check_mirrorlist_health
Verify Arch Linux mirror configuration health by checking for inactive mirrors, outdated mirrorlists, and high latency issues.
Instructions
[MIRRORS] Verify mirror configuration health. Checks for common issues like no active mirrors, outdated mirrorlist, high latency. Only works on Arch Linux.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/arch_ops_server/mirrors.py:306-396 (handler)The core handler function implementing check_mirrorlist_health tool logic: checks active mirrors count, tests mirror speeds, computes health score, identifies issues/warnings, and provides recommendations.async def check_mirrorlist_health() -> Dict[str, Any]: """ Verify mirror configuration health. Checks for common issues like no active mirrors, outdated mirrorlist. Returns: Dict with health assessment and recommendations """ if not IS_ARCH: return create_error_response( "NotSupported", "This feature is only available on Arch Linux" ) logger.info("Checking mirrorlist health") try: issues = [] warnings = [] recommendations = [] # Get active mirrors result = await list_active_mirrors() if "error" in result: return result active_mirrors = result.get("active_mirrors", []) # Check: No active mirrors if len(active_mirrors) == 0: issues.append("No active mirrors configured") recommendations.append("Uncomment mirrors in /etc/pacman.d/mirrorlist or use reflector to generate a new mirrorlist") # Check: Only one active mirror (no redundancy) elif len(active_mirrors) == 1: warnings.append("Only one active mirror (no redundancy)") recommendations.append("Enable additional mirrors for redundancy") # Check: Too many active mirrors (can slow down updates) elif len(active_mirrors) > 10: warnings.append(f"Many active mirrors ({len(active_mirrors)}) may slow down updates") recommendations.append("Consider reducing to 3-5 fastest mirrors") # Test mirrors test_result = await test_mirror_speed() if "error" not in test_result: test_results = test_result.get("results", []) # Check: All mirrors failing successful_mirrors = [r for r in test_results if r.get("success", False)] if len(successful_mirrors) == 0: issues.append("All mirrors are unreachable or failing") recommendations.append("Check network connectivity and consider updating mirrorlist") # Check: High latency elif successful_mirrors: avg_latency = sum(m["latency_ms"] for m in successful_mirrors) / len(successful_mirrors) if avg_latency > 1000: warnings.append(f"High average mirror latency ({avg_latency:.0f}ms)") recommendations.append("Consider using geographically closer mirrors") # Health score health_score = 100 health_score -= len(issues) * 40 health_score -= len(warnings) * 15 health_score = max(0, health_score) health_status = "healthy" if health_score < 50: health_status = "critical" elif health_score < 70: health_status = "warning" logger.info(f"Mirror health: {health_status} (score: {health_score})") return { "health_status": health_status, "health_score": health_score, "issues": issues, "warnings": warnings, "recommendations": recommendations, "active_mirrors_count": len(active_mirrors) } except Exception as e: logger.error(f"Failed to check mirror health: {e}") return create_error_response( "HealthCheckError", f"Failed to check mirrorlist health: {str(e)}" )
- The JSON schema definition for the tool in MCP server.list_tools(), specifying no input parameters required.Tool( name="check_mirrorlist_health", description="[MIRRORS] Verify mirror configuration health. Checks for common issues like no active mirrors, outdated mirrorlist, high latency. Only works on Arch Linux.", inputSchema={ "type": "object", "properties": {} } ),
- src/arch_ops_server/server.py:1434-1439 (registration)The dispatch logic in MCP server.call_tool() that handles execution of check_mirrorlist_health by calling the handler function and formatting the JSON response.elif name == "check_mirrorlist_health": if not IS_ARCH: return [TextContent(type="text", text="Error: check_mirrorlist_health only available on Arch Linux systems")] result = await check_mirrorlist_health() return [TextContent(type="text", text=json.dumps(result, indent=2))]
- src/arch_ops_server/__init__.py:61-61 (registration)Import of the check_mirrorlist_health function from mirrors.py into the package namespace.check_mirrorlist_health
- ToolMetadata definition providing category, platform, permissions, workflow, and related tools information for check_mirrorlist_health."check_mirrorlist_health": ToolMetadata( name="check_mirrorlist_health", category="mirrors", platform="arch", permission="read", workflow="verify", related_tools=["list_active_mirrors", "suggest_fastest_mirrors"], prerequisite_tools=[] ),