find_package_owner
Identify which Arch Linux package owns a specific system file to troubleshoot issues and understand file origins.
Instructions
[ORGANIZATION] Find which package owns a specific file on the system. Useful for troubleshooting and understanding file origins. Only works on Arch Linux.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Absolute path to the file (e.g., /usr/bin/vim) |
Implementation Reference
- src/arch_ops_server/pacman.py:631-694 (handler)Core handler function implementing the 'find_package_owner' tool logic using 'pacman -Qo' command to query file ownership.async def find_package_owner(file_path: str) -> Dict[str, Any]: """ Find which package owns a specific file. Args: file_path: Absolute path to file Returns: Dict with package owner information """ if not IS_ARCH: return create_error_response( "NotSupported", "Package ownership queries are only available on Arch Linux" ) if not check_command_exists("pacman"): return create_error_response( "CommandNotFound", "pacman command not found" ) logger.info(f"Finding owner of file: {file_path}") try: exit_code, stdout, stderr = await run_command( ["pacman", "-Qo", file_path], timeout=5, check=False ) if exit_code != 0: logger.info(f"No package owns {file_path}") return create_error_response( "NotFound", f"No package owns this file: {file_path}", stderr ) # Parse output: "/path/to/file is owned by package 1.0-1" match = re.search(r'is owned by (\S+)\s+(\S+)', stdout) if match: package_name = match.group(1) version = match.group(2) logger.info(f"File {file_path} is owned by {package_name} {version}") return { "file": file_path, "package": package_name, "version": version } return create_error_response( "ParseError", f"Could not parse pacman output: {stdout}" ) except Exception as e: logger.error(f"Package ownership query failed: {e}") return create_error_response( "CommandError", f"Failed to find package owner: {str(e)}" )
- src/arch_ops_server/server.py:761-773 (registration)MCP tool registration in list_tools(), including name, description, and input schema (file_path: str).name="find_package_owner", description="[ORGANIZATION] Find which package owns a specific file on the system. Useful for troubleshooting and understanding file origins. Only works on Arch Linux.", inputSchema={ "type": "object", "properties": { "file_path": { "type": "string", "description": "Absolute path to the file (e.g., /usr/bin/vim)" } }, "required": ["file_path"] } ),
- src/arch_ops_server/server.py:1257-1264 (registration)Tool dispatcher in call_tool() that invokes the find_package_owner handler with parsed arguments.elif name == "find_package_owner": if not IS_ARCH: return [TextContent(type="text", text="Error: find_package_owner only available on Arch Linux systems")] file_path = arguments["file_path"] result = await find_package_owner(file_path) return [TextContent(type="text", text=json.dumps(result, indent=2))]
- Tool metadata definition categorizing it as organization/read tool with related tools."find_package_owner": ToolMetadata( name="find_package_owner", category="organization", platform="arch", permission="read", workflow="debug", related_tools=["list_package_files", "verify_package_integrity"], prerequisite_tools=[] ),
- src/arch_ops_server/__init__.py:21-28 (registration)Import of find_package_owner from pacman.py for re-export in package __init__.from .pacman import ( get_official_package_info, check_updates_dry_run, remove_package, remove_packages_batch, list_orphan_packages, remove_orphans, find_package_owner,