manage_groups
List all groups or view packages in a specific group using unified group management actions.
Instructions
[ORGANIZATION] Unified group management tool. Actions: list_groups (all groups), list_packages_in_group (packages in specific group). Examples: manage_groups(action='list_groups'), manage_groups(action='list_packages_in_group', group_name='base-devel')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Operation to perform | |
| group_name | No | Group name (required for list_packages_in_group) |
Implementation Reference
- src/arch_ops_server/groups.py:8-23 (handler)Main handler function for the manage_groups tool. Dispatches to _list_groups() or _list_packages_in_group() based on the action argument.
async def manage_groups( action: Literal["list_groups", "list_packages_in_group"], group_name: Optional[str] = None ) -> dict: """Unified group management tool.""" if not IS_ARCH: return create_error_response("Requires Arch Linux", error_type="platform_error") if action == "list_groups": return await _list_groups() elif action == "list_packages_in_group": if not group_name: return create_error_response("group_name required", error_type="validation_error") return await _list_packages_in_group(group_name) else: return create_error_response(f"Unknown action: {action}") - MCP Tool registration with input schema defining 'action' (enum: list_groups, list_packages_in_group) and optional 'group_name'.
# Package Groups Tool( name="manage_groups", description="[ORGANIZATION] Unified group management tool. Actions: list_groups (all groups), list_packages_in_group (packages in specific group). Examples: manage_groups(action='list_groups'), manage_groups(action='list_packages_in_group', group_name='base-devel')", inputSchema={ "type": "object", "properties": { "action": { "type": "string", "enum": ["list_groups", "list_packages_in_group"], "description": "Operation to perform" }, "group_name": { "type": "string", "description": "Group name (required for list_packages_in_group)" } }, "required": ["action"] }, annotations=ToolAnnotations(readOnlyHint=True) ), - src/arch_ops_server/server.py:1187-1194 (registration)Tool call dispatcher in the MCP server that routes 'manage_groups' requests to the handler function.
elif name == "manage_groups": if not IS_ARCH: return [TextContent(type="text", text=create_platform_error_message("manage_groups"))] action = arguments["action"] group_name = arguments.get("group_name", None) result = await manage_groups(action, group_name) return [TextContent(type="text", text=json.dumps(result, indent=2))] - src/arch_ops_server/groups.py:34-44 (helper)Helper that runs 'pacman -Sg <group_name>' and parses output to return a list of packages in a specific group.
async def _list_packages_in_group(group_name: str) -> dict: exit_code, stdout, stderr = await run_command(["pacman", "-Sg", group_name], timeout=10) if exit_code != 0: return create_error_response(f"Failed: {stderr}") packages = [] for line in stdout.strip().split("\n"): if line.strip(): parts = line.split() if len(parts) >= 2: packages.append(parts[1]) return {"action": "list_packages_in_group", "group": group_name, "total_packages": len(packages), "packages": packages} - src/arch_ops_server/groups.py:26-31 (helper)Helper that runs 'pacman -Sg' and parses output to return a sorted list of all Arch Linux package groups.
async def _list_groups() -> dict: exit_code, stdout, stderr = await run_command(["pacman", "-Sg"], timeout=10) if exit_code != 0: return create_error_response(f"Failed to list groups: {stderr}") groups = [line.strip() for line in stdout.strip().split("\n") if line.strip()] return {"action": "list_groups", "total_groups": len(groups), "groups": sorted(groups)}