Skip to main content
Glama

remove_packages_batch

Remove multiple Arch Linux packages in a single transaction to efficiently uninstall software and manage system dependencies.

Instructions

Remove multiple packages in a single transaction. More efficient than removing packages one by one. Only works on Arch Linux. Requires sudo access.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_namesYesList of package names to remove
remove_dependenciesNoRemove packages and their dependencies. Default: false

Implementation Reference

  • Core async handler function implementing batch package removal. Executes sudo pacman -R or -Rs --noconfirm on the provided list of package names, with error handling and structured response.
    async def remove_packages_batch( package_names: List[str], remove_dependencies: bool = False ) -> Dict[str, Any]: """ Remove multiple packages in a single transaction. Args: package_names: List of package names to remove remove_dependencies: If True, remove unneeded dependencies Returns: Dict with removal status """ if not IS_ARCH: return create_error_response( "NotSupported", "Package removal is only available on Arch Linux" ) if not check_command_exists("pacman"): return create_error_response( "CommandNotFound", "pacman command not found" ) if not package_names: return create_error_response( "ValidationError", "No packages specified for removal" ) logger.info(f"Batch removing {len(package_names)} packages (deps={remove_dependencies})") # Build command cmd = ["sudo", "pacman"] if remove_dependencies: cmd.extend(["-Rs"]) else: cmd.extend(["-R"]) cmd.extend(["--noconfirm"] + package_names) try: exit_code, stdout, stderr = await run_command( cmd, timeout=120, # Longer timeout for batch removal check=False, skip_sudo_check=True ) if exit_code != 0: logger.error(f"Batch removal failed: {stderr}") return create_error_response( "RemovalError", f"Failed to remove packages: {stderr}", f"Exit code: {exit_code}" ) logger.info(f"Successfully removed {len(package_names)} packages") return { "success": True, "package_count": len(package_names), "packages": package_names, "removed_dependencies": remove_dependencies, "output": stdout } except Exception as e: logger.error(f"Batch removal failed with exception: {e}") return create_error_response( "RemovalError", f"Failed to remove packages: {str(e)}" )
  • MCP tool registration in @server.list_tools(), defining the tool's name, description, input schema (package_names list and remove_dependencies bool), making it discoverable to MCP clients.
    Tool( name="remove_packages_batch", description="[LIFECYCLE] Remove multiple packages in a single transaction. More efficient than removing packages one by one. Only works on Arch Linux. Requires sudo access.", inputSchema={ "type": "object", "properties": { "package_names": { "type": "array", "items": {"type": "string"}, "description": "List of package names to remove" }, "remove_dependencies": { "type": "boolean", "description": "Remove packages and their dependencies. Default: false", "default": False } }, "required": ["package_names"] } ),
  • Tool dispatch handler in @server.call_tool(). Extracts arguments, performs Arch Linux check, invokes the pacman handler, and returns JSON-formatted result as TextContent.
    elif name == "remove_packages_batch": if not IS_ARCH: return [TextContent(type="text", text="Error: remove_packages_batch only available on Arch Linux systems")] package_names = arguments["package_names"] remove_dependencies = arguments.get("remove_dependencies", False) result = await remove_packages_batch(package_names, remove_dependencies) return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Tool metadata schema defining category (lifecycle), platform (arch), permission (write), workflow (removal), and related tools for semantic organization.
    "remove_packages_batch": ToolMetadata( name="remove_packages_batch", category="lifecycle", platform="arch", permission="write", workflow="removal", related_tools=["remove_package", "remove_orphans"], prerequisite_tools=[] ),
  • Re-export of the remove_packages_batch function from pacman.py, making it available for import in server.py.
    remove_packages_batch,

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