Skip to main content
Glama

list_active_mirrors

Retrieve currently configured package mirrors on Arch Linux systems to verify or manage software sources.

Instructions

[MIRRORS] List currently configured mirrors from mirrorlist. Only works on Arch Linux.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function implementing the list_active_mirrors tool. It reads and parses /etc/pacman.d/mirrorlist, categorizes mirrors as active or commented using regex, handles errors, and returns structured JSON with counts and mirror details.
    async def list_active_mirrors() -> Dict[str, Any]: """ List currently configured mirrors from mirrorlist. Returns: Dict with active and commented mirrors """ if not IS_ARCH: return create_error_response( "NotSupported", "This feature is only available on Arch Linux" ) logger.info("Reading mirrorlist configuration") try: mirrorlist = Path(MIRRORLIST_PATH) if not mirrorlist.exists(): return create_error_response( "NotFound", f"Mirrorlist not found at {MIRRORLIST_PATH}" ) active_mirrors = [] commented_mirrors = [] with open(mirrorlist, 'r') as f: for line in f: line = line.strip() # Skip empty lines and comments that aren't mirrors if not line or (line.startswith('#') and 'Server' not in line): continue # Check if it's a commented mirror if line.startswith('#'): # Extract mirror URL match = re.search(r'Server\s*=\s*(.+)', line) if match: commented_mirrors.append({ "url": match.group(1).strip(), "active": False }) elif line.startswith('Server'): # Active mirror match = re.search(r'Server\s*=\s*(.+)', line) if match: active_mirrors.append({ "url": match.group(1).strip(), "active": True }) logger.info(f"Found {len(active_mirrors)} active, {len(commented_mirrors)} commented mirrors") return { "active_count": len(active_mirrors), "commented_count": len(commented_mirrors), "active_mirrors": active_mirrors, "commented_mirrors": commented_mirrors, "mirrorlist_path": str(mirrorlist) } except Exception as e: logger.error(f"Failed to read mirrorlist: {e}") return create_error_response( "MirrorlistError", f"Failed to read mirrorlist: {str(e)}" )
  • MCP server registration of the tool in @server.list_tools(), defining the tool name, description, and input schema (no parameters). This makes it discoverable to MCP clients.
    name="list_active_mirrors", description="[MIRRORS] List currently configured mirrors from mirrorlist. Only works on Arch Linux.", inputSchema={ "type": "object", "properties": {} } ),
  • Tool dispatcher in @server.call_tool() that invokes the list_active_mirrors handler function and formats the response as JSON text content for MCP.
    elif name == "list_active_mirrors": if not IS_ARCH: return [TextContent(type="text", text="Error: list_active_mirrors only available on Arch Linux systems")] result = await list_active_mirrors() return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Package-level import exposing list_active_mirrors to the __init__.py namespace, allowing server.py to import and use it.
    from .mirrors import ( list_active_mirrors, test_mirror_speed, suggest_fastest_mirrors, check_mirrorlist_health )
  • Tool metadata providing categorization, platform requirements, permissions, workflow context, and relationships to other mirror tools.
    "list_active_mirrors": ToolMetadata( name="list_active_mirrors", category="mirrors", platform="arch", permission="read", workflow="optimize", related_tools=["test_mirror_speed", "check_mirrorlist_health"], 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