Skip to main content
Glama

register_agent

Register an A2A agent with the bridge server by providing its URL to enable communication and management through the MCP server.

Instructions

Register an A2A agent with the bridge server.

Args: url: URL of the A2A agent

Returns: Dictionary with registration status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The @mcp.tool() decorated function that implements and registers the register_agent tool. It fetches the agent card, stores agent info in a global dict, saves to disk, and returns success/error status.
    @mcp.tool()
    async def register_agent(url: str, ctx: Context) -> Dict[str, Any]:
        """
        Register an A2A agent with the bridge server.
        
        Args:
            url: URL of the A2A agent
            
        Returns:
            Dictionary with registration status
        """
        try:
            # Fetch the agent card directly
            agent_card = await fetch_agent_card(url)
            
            # Store the agent information
            agent_info = AgentInfo(
                url=url,
                name=agent_card.name,
                description=agent_card.description or "No description provided",
            )
            
            registered_agents[url] = agent_info
            
            # Save to disk immediately
            agents_data = {url: agent.model_dump() for url, agent in registered_agents.items()}
            save_to_json(agents_data, REGISTERED_AGENTS_FILE)
            
            await ctx.info(f"Successfully registered agent: {agent_card.name}")
            return {
                "status": "success",
                "agent": agent_info.model_dump(),
            }
        except Exception as e:
            return {
                "status": "error",
                "message": f"Failed to register agent: {str(e)}",
            }
  • Helper function called by register_agent to fetch and parse the AgentCard from the agent's URL (main or /.well-known/agent.json), falling back to a minimal card if fetch fails.
    async def fetch_agent_card(url: str) -> AgentCard:
        """
        Fetch the agent card from the agent's URL.
        First try the main URL, then the well-known location.
        """
        async with httpx.AsyncClient() as client:
            # First try the main endpoint
            try:
                response = await client.get(url)
                if response.status_code == 200:
                    try:
                        data = response.json()
                        if isinstance(data, dict) and "name" in data and "url" in data:
                            return AgentCard(**data)
                    except json.JSONDecodeError:
                        pass  # Not a valid JSON response, try the well-known URL
            except Exception:
                pass  # Connection error, try the well-known URL
            
            # Try the well-known location
            well_known_url = f"{url.rstrip('/')}/.well-known/agent.json"
            try:
                response = await client.get(well_known_url)
                if response.status_code == 200:
                    try:
                        data = response.json()
                        return AgentCard(**data)
                    except json.JSONDecodeError:
                        raise ValueError(f"Invalid JSON in agent card from {well_known_url}")
            except httpx.RequestError as e:
                raise ValueError(f"Failed to fetch agent card from {well_known_url}: {str(e)}")
        
        # If we can't get the agent card, create a minimal one with default values
        return AgentCard(
            name="Unknown Agent",
            url=url,
            version="0.1.0",
            capabilities=AgentCapabilities(streaming=False),
            skills=[
                AgentSkill(
                    id="unknown",
                    name="Unknown Skill",
                    description="Unknown agent capabilities",
                )
            ],
        )
  • Pydantic BaseModel used to store parsed agent information (url, name, description) in the registered_agents dictionary.
    class AgentInfo(BaseModel):
        """Information about an A2A agent."""
        url: str = Field(description="URL of the A2A agent")
        name: str = Field(description="Name of the A2A agent")
        description: str = Field(description="Description of the A2A agent")
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action and return type. It doesn't disclose behavioral traits such as authentication requirements, potential side effects (e.g., agent becoming active), error conditions, or rate limits, which are critical for a registration tool.

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 appropriately sized with two sentences and uses a structured 'Args' and 'Returns' format, making it easy to parse. However, the second sentence about returns is somewhat redundant given the output schema, slightly reducing efficiency.

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's moderate complexity (registration action with one parameter) and the presence of an output schema, the description covers basic purpose and parameters but lacks context on usage, behavior, and integration with siblings. It's minimally adequate but has clear gaps in completeness.

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

Parameters3/5

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

The schema description coverage is 0%, but the description adds minimal semantics by naming the 'url' parameter and indicating it's for the A2A agent. However, it doesn't explain format constraints (e.g., HTTP/HTTPS), validation rules, or examples, leaving gaps despite the single parameter.

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 action ('Register') and resource ('an A2A agent with the bridge server'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'unregister_agent' or 'list_agents', which would be needed for 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 'unregister_agent' or 'list_agents'. The description lacks context about prerequisites, timing, or exclusions, leaving the agent with minimal usage direction.

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/GongRzhe/A2A-MCP-Server'

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