Skip to main content
Glama

analyze_pacman_conf

Parse and analyze pacman configuration to identify enabled repositories, ignored packages, parallel download settings, and other system configurations on Arch Linux systems.

Instructions

Parse and analyze pacman.conf. Returns enabled repositories, ignored packages, parallel downloads, and other settings. Only works on Arch Linux.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that parses /etc/pacman.conf, extracts repositories, ignored packages/groups, parallel downloads, signature levels, and other key configuration options. Returns structured JSON data or error response.
    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)}" )
  • MCP tool schema definition in list_tools(), specifying no input parameters and description. The tool returns JSON-structured configuration data.
    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": {} } ),
  • Dispatch logic in @server.call_tool() that executes the analyze_pacman_conf handler when the tool is called via MCP protocol.
    elif name == "analyze_pacman_conf": if not IS_ARCH: return [TextContent(type="text", text="Error: analyze_pacman_conf only available on Arch Linux systems")] result = await analyze_pacman_conf() return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Tool metadata including category, platform requirements, permissions, related tools, used for tool discovery and workflow guidance.
    "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=[] ),
  • Helper function to parse INI-like pacman.conf file, handling sections, 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

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