Skip to main content
Glama

unregister_agent

Remove an A2A agent from the bridge server by specifying its URL. This tool ensures proper deactivation and management of agent connections within the MCP-compatible system.

Instructions

Unregister an A2A agent from the bridge server.

Args: url: URL of the A2A agent to unregister

Returns: Dictionary with unregistration status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • The handler function for the 'unregister_agent' MCP tool. It removes the specified agent URL from the registered_agents dictionary, cleans up associated task mappings, saves changes to persistent storage, and returns a status dictionary. Registered via @mcp.tool() decorator.
    @mcp.tool() async def unregister_agent(url: str, ctx: Context = None) -> Dict[str, Any]: """ Unregister an A2A agent from the bridge server. Args: url: URL of the A2A agent to unregister Returns: Dictionary with unregistration status """ if url not in registered_agents: return { "status": "error", "message": f"Agent not registered: {url}", } try: # Get agent name before removing it agent_name = registered_agents[url].name # Remove from registered agents del registered_agents[url] # Clean up any task mappings related to this agent # Create a list of task_ids to remove to avoid modifying the dictionary during iteration tasks_to_remove = [] for task_id, agent_url in task_agent_mapping.items(): if agent_url == url: tasks_to_remove.append(task_id) # Now remove the task mappings for task_id in tasks_to_remove: del task_agent_mapping[task_id] # Save changes to disk immediately agents_data = {url: agent.model_dump() for url, agent in registered_agents.items()} save_to_json(agents_data, REGISTERED_AGENTS_FILE) save_to_json(task_agent_mapping, TASK_AGENT_MAPPING_FILE) if ctx: await ctx.info(f"Successfully unregistered agent: {agent_name}") return { "status": "success", "message": f"Successfully unregistered agent: {agent_name}", "removed_tasks": len(tasks_to_remove), } except Exception as e: return { "status": "error", "message": f"Error unregistering agent: {str(e)}", }

Other Tools

Related 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