analyze_pacman_conf
Parse and analyze pacman.conf to identify enabled repositories, ignored packages, parallel downloads, and configuration settings for Arch Linux system management.
Instructions
[CONFIG] Parse and analyze pacman.conf. Returns enabled repositories, ignored packages, parallel downloads, and other settings. Only works on Arch Linux.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/arch_ops_server/config.py:95-169 (handler)Main tool handler function that parses /etc/pacman.conf, extracts repositories, ignored packages/groups, parallel downloads, signature levels, and returns structured analysis.async def analyze_pacman_conf() -> Dict[str, Any]: """ Parse and analyze pacman.conf. Returns: Dict with parsed pacman configuration """ if not IS_ARCH: return create_error_response( "NotSupported", "This feature is only available on Arch Linux" ) logger.info("Analyzing pacman.conf") try: pacman_conf = Path(PACMAN_CONF) if not pacman_conf.exists(): return create_error_response( "NotFound", f"pacman.conf not found at {PACMAN_CONF}" ) config = parse_config_file(PACMAN_CONF) # Extract specific important options options = config.get("options", {}) # Parse multi-value options ignored_packages = [] ignored_groups = [] for key, value in options.items(): if key == "IgnorePkg": ignored_packages = [p.strip() for p in value.split()] elif key == "IgnoreGroup": ignored_groups = [g.strip() for g in value.split()] # Parse ParallelDownloads parallel_downloads = options.get("ParallelDownloads", "1") try: parallel_downloads = int(parallel_downloads) except ValueError: parallel_downloads = 1 # Extract repository list repositories = [repo["name"] for repo in config.get("repositories", [])] # Check for security settings sig_level = options.get("SigLevel", "") local_file_sig_level = options.get("LocalFileSigLevel", "") logger.info(f"Parsed pacman.conf: {len(repositories)} repos, {parallel_downloads} parallel downloads") return { "config_path": str(pacman_conf), "repositories": repositories, "repository_count": len(repositories), "parallel_downloads": parallel_downloads, "ignored_packages": ignored_packages, "ignored_groups": ignored_groups, "sig_level": sig_level, "local_file_sig_level": local_file_sig_level, "all_options": options, "raw_config": config } except Exception as e: logger.error(f"Failed to analyze pacman.conf: {e}") return create_error_response( "ConfigParseError", f"Failed to analyze pacman.conf: {str(e)}" )
- src/arch_ops_server/server.py:1113-1119 (registration)MCP tool registration in @server.list_tools(), defining the tool name, description, and input schema (no parameters).name="analyze_pacman_conf", description="[CONFIG] Parse and analyze pacman.conf. Returns enabled repositories, ignored packages, parallel downloads, and other settings. Only works on Arch Linux.", inputSchema={ "type": "object", "properties": {} } ),
- Input schema definition for the tool: empty object (no input parameters required)."type": "object", "properties": {} }
- src/arch_ops_server/config.py:24-92 (helper)Helper function to parse INI-like pacman.conf file into structured dict with options, repositories, and comments.def parse_config_file(file_path: str) -> Dict[str, Any]: """ Parse a configuration file with INI-like format. Args: file_path: Path to configuration file Returns: Dict with parsed configuration data """ config = { "options": {}, "repositories": [], "comments": [] } current_section = None try: with open(file_path, 'r') as f: for line_num, line in enumerate(f, 1): original_line = line line = line.strip() # Skip empty lines if not line: continue # Store comments if line.startswith('#'): config["comments"].append({ "line": line_num, "text": line }) continue # Section headers [SectionName] section_match = re.match(r'\[(\w+)\]', line) if section_match: current_section = section_match.group(1) # If it's a repository section if current_section not in ["options", "Options"]: config["repositories"].append({ "name": current_section, "line": line_num }) continue # Key = Value pairs if '=' in line: key, value = line.split('=', 1) key = key.strip() value = value.strip() if current_section and current_section.lower() == "options": config["options"][key] = value elif current_section: # Add to repository config for repo in config["repositories"]: if repo["name"] == current_section: if "config" not in repo: repo["config"] = {} repo["config"][key] = value except Exception as e: logger.error(f"Failed to parse config file {file_path}: {e}") return config
- Tool metadata definition providing category, platform, permissions, related tools for analyze_pacman_conf."analyze_pacman_conf": ToolMetadata( name="analyze_pacman_conf", category="config", platform="arch", permission="read", workflow="explore", related_tools=["check_ignored_packages", "get_parallel_downloads_setting"], prerequisite_tools=[] ),