unregister-agent
Remove an agent from active status in the MCP Agentic Framework to prevent receiving new messages and deactivate communication capabilities.
Instructions
Unregister an agent from the communication framework. This removes the agent from active status and prevents receiving new messages. Only unregister your own agent ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The unique identifier of the agent to unregister |
Implementation Reference
- src/tools.js:87-115 (handler)Main handler function for 'unregister-agent' tool. Orchestrates the unregistration process: gets agent details, unregisters the agent, checks if minimi agent left and updates write lock state accordingly, and returns a structured response.
export async function unregisterAgent(id) { const startTime = Date.now(); try { // Get agent details before unregistering const agent = await agentRegistry.getAgent(id); const agentName = agent ? agent.name : null; const result = await agentRegistry.unregisterAgent(id); // Check if minimi left and update lock state if (agentName === 'minimi' && result.success) { const minimiStillPresent = await writeLockManager.checkMinimiPresence(); await writeLockManager.updateLockForMinimiPresence(minimiStillPresent); } const metadata = createMetadata(startTime, { tool: 'unregister-agent' }); const message = result.success ? `Agent '${id}' unregistered successfully` : `Agent '${id}' not found`; return structuredResponse(result, message, metadata); } catch (error) { if (error instanceof MCPError) { throw error; } throw Errors.internalError(error.message); } } - src/toolDefinitions.js:58-86 (schema)Schema definition for 'unregister-agent' tool. Defines input schema requiring agent ID parameter, and output schema with success boolean. Includes tool name, title, and description.
name: 'unregister-agent', title: 'Unregister Agent', description: 'Unregister an agent from the communication framework. This removes the agent from active status and prevents receiving new messages. Only unregister your own agent ID.', inputSchema: { $schema: 'http://json-schema.org/draft-07/schema#', type: 'object', properties: { id: { type: 'string', description: 'The unique identifier of the agent to unregister', minLength: 1 } }, required: ['id'], additionalProperties: false }, outputSchema: { $schema: 'http://json-schema.org/draft-07/schema#', type: 'object', properties: { success: { type: 'boolean', description: 'Whether the unregistration was successful' } }, required: ['success'], additionalProperties: false } }, - src/server.js:155-158 (registration)Registration point for 'unregister-agent' tool in the MCP server. Maps tool name to handler function in the CallToolRequestSchema request handler switch statement.
case 'unregister-agent': { const { id } = args; return await unregisterAgent(id); } - src/lib/agentRegistry.js:133-153 (helper)Core helper function that performs the actual agent unregistration. Validates agent ID, acquires lock, deletes agent from storage, emits notification, and returns success status.
const unregisterAgent = async (id) => { validateAgentId(id); return withLock(async () => { const agents = await loadAgents(storagePath); if (!agents[id]) { return { success: false }; } delete agents[id]; await saveAgents(storagePath, agents); // Emit notification if manager is available if (notificationManager) { await notificationManager.notifyAgentUnregistered(id); } return { success: true }; }); };