Skip to main content
Glama

list_agents

Retrieve available agents and their capabilities to enable Claude Desktop to access extended functionality through the A2A protocol.

Instructions

List available agents with their agent cards. Returns: Dict with agents and their cards

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'list_agents' tool. It iterates over registered A2A servers, fetches agent cards using fetch_agent_card, and returns a dictionary with agent names and their card data.
    async def list_agents() -> Dict[str, Any]: """ List available agents with their agent cards. Returns: Dict with agents and their cards """ try: logger.debug("list_agents called") logger.debug(f"Current registry: {state.registry}") # Use the A2ACardResolver to fetch agent cards agents = {} for name, url in state.registry.items(): try: logger.debug(f"Fetching card for {name} from {url}") card = await fetch_agent_card(url) if card: # Store the card data in a format suitable for JSON response agents[name] = card.model_dump() # Update the cache with the fetched card state.cache[name] = card else: logger.error(f"Failed to fetch agent card for {name}") except Exception as e: logger.exception(f"Error fetching card for {name}: {e}") logger.info(f"Listing {len(agents)} agents") return { "agent_count": len(agents), "agents": agents } except Exception as e: logger.exception(f"Error in list_agents: {str(e)}") return {"status": "error", "message": f"Error: {str(e)}"}
  • The @mcp.tool() decorator registers the list_agents function as an MCP tool.
    async def list_agents() -> Dict[str, Any]:
  • The function signature (no input parameters) and docstring define the tool's input/output schema.
    async def list_agents() -> Dict[str, Any]: """ List available agents with their agent cards. Returns: Dict with agents and their cards """
  • Helper function used by list_agents to fetch an AgentCard from a given A2A server URL.
    async def fetch_agent_card(url: str) -> Optional[AgentCard]: """Fetch agent card from an A2A server using A2ACardResolver.""" try: logger.debug(f"Fetching agent card from {url}") # Use the A2ACardResolver from a2a_min to get the agent card card_resolver = A2ACardResolver(url) try: card = card_resolver.get_agent_card() logger.debug(f"Received agent card: {card}") return card except Exception as e: logger.error(f"Failed to fetch agent card: {str(e)}") return None except Exception as e: logger.exception(f"Error fetching agent card from {url}: {e}") return None
  • Tool description in the module docstring.
    - list_agents: List available agents with their agent cards
Install Server

Other Tools

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/regismesquita/MCP_A2A'

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