Skip to main content
Glama

verify_package_integrity

Read-only

Check if installed package files have been modified, missing, or corrupted. Use after system crashes or disk errors to verify package integrity on Arch Linux.

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

  • The core implementation of verify_package_integrity. Runs `pacman -Qkk` (thorough) or `pacman -Qk` (standard) to verify installed package files, parses warnings/missing files, and returns results with issues count.
    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 (package_name required, thorough optional) and description for the verify_package_integrity tool.
    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)
    ),
  • The call_tool dispatcher that routes 'verify_package_integrity' invocations to the actual handler function, including platform check for Arch Linux.
    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))]
  • Import of verify_package_integrity from pacman module into the package namespace.
    from .pacman import (
        get_official_package_info,
        check_updates_dry_run,
        remove_package,
        remove_packages_batch,
        remove_packages,
        list_orphan_packages,
        remove_orphans,
        manage_orphans,
        find_package_owner,
        list_package_files,
        search_package_files,
        query_file_ownership,
        verify_package_integrity,
        list_explicit_packages,
        mark_as_explicit,
        mark_as_dependency,
        manage_install_reason,
        check_database_freshness,
    )
  • ToolMetadata definition for verify_package_integrity (category: maintenance, platform: arch, permission: read, workflow: verify) with related tools.
    "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=[]
    ),

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.1/5.0
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.