Skip to main content
Glama

unregister_agent

Remove an A2A agent from the bridge server by providing its URL to disconnect communication between AI assistants and agents.

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. Decorated with @mcp.tool(), it removes the specified agent URL from the registered_agents dictionary, cleans up associated tasks in task_agent_mapping, persists the changes to JSON files, logs the action, and returns a status dictionary.
    @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)}", }

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