Skip to main content
Glama
agent_selector.py5.44 kB
"""Interactive agent selection UI for installation. This module provides an interactive interface for users to select which agents they want to enable for delegation. """ import logging from pathlib import Path from rich.console import Console from rich.prompt import Confirm, Prompt from rich.table import Table from ..agent_discovery import AgentMetadata logger = logging.getLogger(__name__) console = Console() class AgentSelector: """Manages interactive agent selection during installation.""" def __init__(self): """Initialize the agent selector.""" self.selected_agents: list[str] = [] def display_agents(self, discovered_agents: dict[str, AgentMetadata]) -> None: """ Display discovered agents in a formatted table. Args: discovered_agents: Dictionary of agent name to metadata """ if not discovered_agents: console.print("\n[yellow]No agents discovered.[/yellow]") return table = Table(title="Discovered Agents", show_header=True, header_style="bold magenta") table.add_column("Agent", style="cyan", no_wrap=True) table.add_column("Version", style="green") table.add_column("Path", style="blue") table.add_column("Attributes", style="yellow") for name, metadata in discovered_agents.items(): # Get brief capabilities summary attributes = self._get_attributes_summary(name) version = metadata.version or "unknown" path = str(metadata.path) if metadata.path else "system PATH" table.add_row(name, version, path, attributes) console.print("\n") console.print(table) console.print("\n") def _get_attributes_summary(self, agent_name: str) -> str: """ Get a brief summary of agent attributes. Args: agent_name: Name of the agent Returns: Brief attributes description """ from .agent_profiles import get_agent_profile profile = get_agent_profile(agent_name) parts = [] parts.append(profile["primary_strength"]) if profile["has_git_integration"]: parts.append("git") if profile["has_browser_tools"]: parts.append("browser") return ", ".join(parts) def prompt_selection(self, discovered_agents: dict[str, AgentMetadata]) -> list[str]: """ Interactive prompt for agent selection. Args: discovered_agents: Dictionary of agent name to metadata Returns: List of selected agent names """ if not discovered_agents: return [] self.display_agents(discovered_agents) console.print("[bold]Agent Selection[/bold]") console.print("You can enable/disable individual agents or use all discovered agents.\n") # Ask if user wants to customize selection use_all = Confirm.ask( "Enable all discovered agents?", default=True ) if use_all: self.selected_agents = list(discovered_agents.keys()) console.print(f"\n[green]✓[/green] Selected all {len(self.selected_agents)} agents\n") return self.selected_agents # Custom selection console.print("\nSelect agents to enable (you'll be prompted for each agent):\n") self.selected_agents = [] for name, metadata in discovered_agents.items(): from .agent_profiles import get_agent_profile profile = get_agent_profile(name) description = profile["description"] console.print(f"\n[cyan]{name}[/cyan]: {description}") # Auto-enable Claude if name.lower() == "claude": self.selected_agents.append(name) console.print(f" [green]✓[/green] Enabled (Required for orchestration)") continue enable = Confirm.ask(f" Enable {name}?", default=True) if enable: self.selected_agents.append(name) console.print(f" [green]✓[/green] Enabled") else: console.print(f" [dim]✗[/dim] Disabled") console.print(f"\n[green]✓[/green] Selected {len(self.selected_agents)} agents: {', '.join(self.selected_agents)}\n") return self.selected_agents def get_selected_agents(self) -> list[str]: """ Get the list of selected agents. Returns: List of selected agent names """ return self.selected_agents def validate_selection(self, selected_agents: list[str]) -> tuple[bool, str]: """ Validate that the selection meets requirements. Args: selected_agents: List of selected agent names Returns: Tuple of (is_valid, error_message) """ if len(selected_agents) < 2: return False, ( f"At least 2 agents are required for delegation, but only " f"{len(selected_agents)} {'is' if len(selected_agents) == 1 else 'are'} selected. " f"Please enable more agents." ) return True, ""

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/carlosduplar/multi-agent-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server