Skip to main content
Glama
regismesquita

A2A MCP Server

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the return type ('Dict with agents and their cards'), which adds some value, but lacks details on permissions, rate limits, or other behavioral traits like pagination or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief and front-loaded with the main action, using only two sentences. However, the second sentence about returns could be integrated more smoothly, and there's minor room for improvement in flow.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no parameters, an output schema exists, and no annotations, the description is minimally adequate. It explains the purpose and return value, but lacks context on usage guidelines and behavioral details, leaving gaps for an agent to understand when and how to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are 0 parameters, and the schema description coverage is 100%, so no parameter information is needed. The description doesn't add param semantics, but this is acceptable given the lack of parameters, warranting a baseline score of 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('available agents with their agent cards'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'a2a_server_registry' or 'call_agent', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'a2a_server_registry' or 'call_agent'. The description only states what it does, not the context or prerequisites for its use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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