Skip to main content
Glama

get_official_package_info

Retrieve detailed information about official Arch Linux repository packages including Core, Extra, and other repositories. Query package details using local pacman or archlinux.org API to access official package data.

Instructions

Get information about an official Arch repository package (Core, Extra, etc.). Uses local pacman if available, otherwise queries archlinux.org API. Always prefer official packages over AUR when available.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_nameYesExact package name

Implementation Reference

  • Main asynchronous handler function implementing the tool logic. Uses local pacman query if available on Arch Linux, falls back to remote Arch Linux API.
    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)
  • ToolMetadata definition providing schema-like information: input expectations (package_name: str), output type (Dict[str, Any]), category, platform compatibility, permissions, and related tools.
    "get_official_package_info": ToolMetadata( name="get_official_package_info", category="discovery", platform="any", permission="read", workflow="research", related_tools=["search_aur", "install_package_secure"], prerequisite_tools=[] ),
  • Import statement registering the tool function by exposing it from the package __init__.py for MCP server integration.
    from .pacman import ( get_official_package_info, check_updates_dry_run, remove_package, remove_packages_batch, list_orphan_packages, remove_orphans, find_package_owner, list_package_files, search_package_files, verify_package_integrity, list_package_groups, list_group_packages, list_explicit_packages, mark_as_explicit, mark_as_dependency, check_database_freshness )
  • Helper function for local pacman database query using 'pacman -Si' command.
    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
  • Remote API fetcher and pacman output parser helpers supporting the main handler with detailed package info extraction and error handling.
    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() data = response.json() results = data.get("results", []) if not results: return create_error_response( "NotFound", f"Official package '{package_name}' not found in repositories" ) # Take first exact match (there should only be one) pkg = results[0] info = { "source": "remote", "name": pkg.get("pkgname"), "repository": pkg.get("repo"), "version": pkg.get("pkgver"), "release": pkg.get("pkgrel"), "epoch": pkg.get("epoch"), "description": pkg.get("pkgdesc"), "url": pkg.get("url"), "architecture": pkg.get("arch"), "maintainers": pkg.get("maintainers", []), "packager": pkg.get("packager"), "build_date": pkg.get("build_date"), "last_update": pkg.get("last_update"), "licenses": pkg.get("licenses", []), "groups": pkg.get("groups", []), "provides": pkg.get("provides", []), "depends": pkg.get("depends", []), "optdepends": pkg.get("optdepends", []), "conflicts": pkg.get("conflicts", []), "replaces": pkg.get("replaces", []), } logger.info(f"Successfully fetched {package_name} info remotely") return info except httpx.TimeoutException: logger.error(f"Remote package info fetch timed out for: {package_name}") return create_error_response( "TimeoutError", f"Package info fetch timed out for: {package_name}" ) except httpx.HTTPStatusError as e: logger.error(f"Remote package info HTTP error: {e}") return create_error_response( "HTTPError", f"Package info fetch failed with status {e.response.status_code}", str(e) ) except Exception as e: logger.error(f"Remote package info fetch failed: {e}") return create_error_response( "InfoError", f"Failed to get package info: {str(e)}" ) def _parse_pacman_output(output: str) -> Optional[Dict[str, Any]]: """ Parse pacman -Si output into structured dict. Args: output: Raw pacman -Si output Returns: Parsed package info or None """ if not output.strip(): return None info = {} current_key = None for line in output.split('\n'): # Match "Key : Value" pattern match = re.match(r'^(\w[\w\s]*?)\s*:\s*(.*)$', line) if match: key = match.group(1).strip().lower().replace(' ', '_') value = match.group(2).strip() # Handle special fields if key in ['depends_on', 'optional_deps', 'required_by', 'conflicts_with', 'replaces', 'groups', 'provides']: # These can be multi-line or space-separated if value.lower() == 'none': info[key] = [] else: info[key] = [v.strip() for v in value.split() if v.strip()] else: info[key] = value current_key = key elif current_key and line.startswith(' '): # Continuation line (indented) continuation = line.strip() if continuation and current_key in info: if isinstance(info[current_key], list): info[current_key].extend([v.strip() for v in continuation.split() if v.strip()]) else: info[current_key] += ' ' + continuation return info if info else None

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