Skip to main content
Glama

verify_package_integrity

Read-only

Verify integrity of installed Arch Linux package files by comparing checksums, detecting modified, missing, or corrupted files.

Instructions

[MAINTENANCE] Verify the integrity of installed package files. Detects modified, missing, or corrupted files. Only works on Arch Linux. When to use: After system crash or disk errors, verify 'linux' package files match expected checksums.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_nameYesName of the package to verify
thoroughNoPerform thorough check including file attributes. Default: false

Implementation Reference

  • Core handler function that verifies package integrity by running pacman -Qk (or -Qkk for thorough) against a package name. Parses output for warnings/missing files and returns structured results.
    async def verify_package_integrity(package_name: str, thorough: bool = False) -> Dict[str, Any]:
        """
        Verify integrity of an installed package.
    
        Args:
            package_name: Name of package to verify
            thorough: If True, perform thorough check (pacman -Qkk)
    
        Returns:
            Dict with verification results
        """
        if not IS_ARCH:
            return create_error_response(
                "NotSupported",
                "Package verification is only available on Arch Linux"
            )
    
        if not check_command_exists("pacman"):
            return create_error_response(
                "CommandNotFound",
                "pacman command not found"
            )
    
        logger.info(f"Verifying package integrity: {package_name} (thorough={thorough})")
    
        try:
            cmd = ["pacman", "-Qkk" if thorough else "-Qk", package_name]
    
            exit_code, stdout, stderr = await run_command(
                cmd,
                timeout=30,
                check=False
            )
    
            if exit_code != 0 and "was not found" in stderr:
                return create_error_response(
                    "NotFound",
                    f"Package not installed: {package_name}"
                )
    
            # Parse verification output
            issues = []
            for line in stdout.strip().split('\n'):
                if "warning" in line.lower() or "missing" in line.lower():
                    issues.append(line.strip())
    
            logger.info(f"Found {len(issues)} issues for {package_name}")
    
            return {
                "package": package_name,
                "thorough": thorough,
                "issues_found": len(issues),
                "issues": issues,
                "all_ok": len(issues) == 0
            }
    
        except Exception as e:
            logger.error(f"Package verification failed: {e}")
            return create_error_response(
                "CommandError",
                f"Failed to verify package: {str(e)}"
            )
  • Tool registration with input schema defining package_name (required string) and thorough (optional boolean) parameters.
    Tool(
        name="verify_package_integrity",
        description="[MAINTENANCE] Verify the integrity of installed package files. Detects modified, missing, or corrupted files. Only works on Arch Linux. When to use: After system crash or disk errors, verify 'linux' package files match expected checksums.",
        inputSchema={
            "type": "object",
            "properties": {
                "package_name": {
                    "type": "string",
                    "description": "Name of the package to verify"
                },
                "thorough": {
                    "type": "boolean",
                    "description": "Perform thorough check including file attributes. Default: false",
                    "default": False
                }
            },
            "required": ["package_name"]
        },
        annotations=ToolAnnotations(readOnlyHint=True)
    ),
  • Tool dispatcher in call_tool() that routes 'verify_package_integrity' requests to the handler, with Arch Linux platform check.
    elif name == "verify_package_integrity":
        if not IS_ARCH:
            return [TextContent(type="text", text=create_platform_error_message("verify_package_integrity"))]
    
        package_name = arguments["package_name"]
        thorough = arguments.get("thorough", False)
        result = await verify_package_integrity(package_name, thorough)
        return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Imports helper utilities from .utils including IS_ARCH, run_command, create_error_response, and check_command_exists used by the handler.
    # SPDX-License-Identifier: GPL-3.0-only OR MIT
    """
    Pacman/Official Repository interface module.
    Provides package info and update checks with hybrid local/remote approach.
    """
    
    import logging
    import re
    from pathlib import Path
    from typing import Dict, Any, List, Optional, Union
    import httpx
    
    from .utils import (
        IS_ARCH,
        run_command,
        create_error_response,
        check_command_exists
    )
    
    logger = logging.getLogger(__name__)
    
    # Arch Linux package API
    ARCH_PACKAGES_API = "https://archlinux.org/packages/search/json/"
    
    # HTTP client settings
    DEFAULT_TIMEOUT = 10.0
    
    
    async def get_official_package_info(package_name: str) -> Dict[str, Any]:
        """
        Get information about an official repository package.
        
        Uses hybrid approach:
        - If on Arch Linux: Execute `pacman -Si` for local database query
        - Otherwise: Query archlinux.org API
        
        Args:
            package_name: Package name
        
        Returns:
            Dict with package information
        """
        logger.info(f"Fetching info for official package: {package_name}")
        
        # Try local pacman first if on Arch
        if IS_ARCH and check_command_exists("pacman"):
            info = await _get_package_info_local(package_name)
            if info is not None:
                return info
            logger.warning(f"Local pacman query failed for {package_name}, trying remote API")
        
        # Fallback to remote API
        return await _get_package_info_remote(package_name)
    
    
    async def _get_package_info_local(package_name: str) -> Optional[Dict[str, Any]]:
        """
        Query package info using local pacman command.
        
        Args:
            package_name: Package name
        
        Returns:
            Package info dict or None if failed
        """
        try:
            exit_code, stdout, stderr = await run_command(
                ["pacman", "-Si", package_name],
                timeout=5,
                check=False
            )
            
            if exit_code != 0:
                logger.debug(f"pacman -Si failed for {package_name}")
                return None
            
            # Parse pacman output
            info = _parse_pacman_output(stdout)
            
            if info:
                info["source"] = "local"
                logger.info(f"Successfully fetched {package_name} info locally")
                return info
            
            return None
            
        except Exception as e:
            logger.warning(f"Local pacman query failed: {e}")
            return None
    
    
    async def _get_package_info_remote(package_name: str) -> Dict[str, Any]:
        """
        Query package info using archlinux.org API.
        
        Args:
            package_name: Package name
        
        Returns:
            Package info dict or error response
        """
        params = {
            "name": package_name,
            "exact": "on"  # Exact match only
        }
        
        try:
            async with httpx.AsyncClient(timeout=DEFAULT_TIMEOUT) as client:
                response = await client.get(ARCH_PACKAGES_API, params=params)
                response.raise_for_status()
  • Tool metadata definition: category=maintenance, platform=arch, permission=read, related_tools include query_package_history and query_file_ownership.
    "verify_package_integrity": ToolMetadata(
        name="verify_package_integrity",
        category="maintenance",
        platform="arch",
        permission="read",
        workflow="verify",
        related_tools=["query_package_history", "query_file_ownership"],
        prerequisite_tools=[]
    ),
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare readOnlyHint=true, which is consistent with the description. The description adds that it detects specific file issues and is limited to Arch Linux. It does not detail what occurs on failure or require privileges, but provides sufficient transparency beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Every sentence adds value: purpose, platform restriction, usage guideline. Front-loaded with [MAINTENANCE] tag. No redundant information. Very concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has no output schema, and the description does not explain return values or error behavior. For a verification tool, this omission is notable. However, the description is adequate for an agent to understand the core functionality. Missing details on output format lower the score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description mentions verifying 'linux' package files as an example but does not add significant semantic meaning beyond the schema for 'package_name' and 'thorough'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it verifies integrity of installed package files, detecting modified, missing, or corrupted files. The [MAINTENANCE] tag and specific verb-resource combination make the purpose unambiguous. It distinguishes from sibling tools by focusing on integrity verification post-crash/disk errors.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'When to use: After system crash or disk errors' which gives clear context. It does not specify when not to use or directly name alternatives, but the context is sufficient for an agent to decide.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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-linux-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server