Skip to main content
Glama

list_package_files

Lists files owned by an Arch Linux package, with optional regex filtering to find specific files or directories.

Instructions

[ORGANIZATION] List all files owned by a package. Supports optional filtering by pattern. Only works on Arch Linux.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_nameYesName of the package
filter_patternNoOptional regex pattern to filter files (e.g., '*.conf' or '/etc/')

Implementation Reference

  • Core handler function that executes 'pacman -Ql package_name' to list all files installed by the package, optionally filters by regex pattern, parses output, and returns a structured dictionary with file list and metadata.
    async def list_package_files(package_name: str, filter_pattern: Optional[str] = None) -> Dict[str, Any]: """ List all files owned by a package. Args: package_name: Name of package filter_pattern: Optional regex pattern to filter files Returns: Dict with list of files """ if not IS_ARCH: return create_error_response( "NotSupported", "Package file listing is only available on Arch Linux" ) if not check_command_exists("pacman"): return create_error_response( "CommandNotFound", "pacman command not found" ) logger.info(f"Listing files for package: {package_name}") try: exit_code, stdout, stderr = await run_command( ["pacman", "-Ql", package_name], timeout=10, check=False ) if exit_code != 0: logger.error(f"Failed to list files for {package_name}: {stderr}") return create_error_response( "NotFound", f"Package not found or no files: {package_name}", stderr ) # Parse output: "package /path/to/file" files = [] for line in stdout.strip().split('\n'): if not line.strip(): continue parts = line.split(maxsplit=1) if len(parts) == 2: file_path = parts[1] # Apply filter if provided if filter_pattern: if re.search(filter_pattern, file_path): files.append(file_path) else: files.append(file_path) logger.info(f"Found {len(files)} files for {package_name}") return { "package": package_name, "file_count": len(files), "files": files, "filter_applied": filter_pattern is not None } except Exception as e: logger.error(f"File listing failed: {e}") return create_error_response( "CommandError", f"Failed to list package files: {str(e)}" )
  • MCP tool schema definition in @server.list_tools(), specifying input parameters: package_name (required string), filter_pattern (optional string with regex description). Includes tool description.
    name="list_package_files", description="[ORGANIZATION] List all files owned by a package. Supports optional filtering by pattern. Only works on Arch Linux.", inputSchema={ "type": "object", "properties": { "package_name": { "type": "string", "description": "Name of the package" }, "filter_pattern": { "type": "string", "description": "Optional regex pattern to filter files (e.g., '*.conf' or '/etc/')" } }, "required": ["package_name"] } ),
  • Registration and dispatch logic in @server.call_tool(): extracts arguments, checks Arch Linux platform, calls the list_package_files handler, serializes result to JSON.
    elif name == "list_package_files": if not IS_ARCH: return [TextContent(type="text", text="Error: list_package_files only available on Arch Linux systems")] package_name = arguments["package_name"] filter_pattern = arguments.get("filter_pattern", None) result = await list_package_files(package_name, filter_pattern) return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Tool metadata defining category (organization), platform (arch), permission (read), workflow (explore), and related tools.
    "list_package_files": ToolMetadata( name="list_package_files", category="organization", platform="arch", permission="read", workflow="explore", related_tools=["find_package_owner", "search_package_files"], prerequisite_tools=[] ),
  • Import of the list_package_files handler function in server.py, making it available for tool registration and dispatch.
    from . import ( # Wiki functions search_wiki, get_wiki_page_as_text, # AUR functions search_aur, get_aur_info, get_pkgbuild, analyze_pkgbuild_safety, analyze_package_metadata_risk, install_package_secure, # Pacman functions get_official_package_info, check_updates_dry_run, remove_package, remove_packages_batch, list_orphan_packages, remove_orphans, find_package_owner, list_package_files,

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