Skip to main content
Glama

delete_agent

Remove a specific agent permanently from the Letta system by providing its unique ID. Use list_agents to identify agents before deletion.

Instructions

Delete a specific agent by ID. Use list_agents to find agent IDs. For bulk deletion, use bulk_delete_agents. WARNING: This action is permanent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesThe ID of the agent to delete

Implementation Reference

  • The handler function that executes the delete_agent tool logic: validates agent_id, calls the API to delete the agent, handles errors like 404, and returns a success response with the deleted agent_id.
    export async function handleDeleteAgent(server, args) {
        if (!args?.agent_id) {
            server.createErrorResponse('Missing required argument: agent_id');
        }
    
        try {
            const headers = server.getApiHeaders();
            const agentId = encodeURIComponent(args.agent_id);
    
            // Use the specific endpoint from the OpenAPI spec
            // Note: axios delete method typically doesn't have a body, config is the second arg
            await server.api.delete(`/agents/${agentId}`, { headers });
    
            // Successful deletion usually returns 200 or 204 with no body
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            agent_id: args.agent_id,
                        }),
                    },
                ],
            };
        } catch (error) {
            // Handle potential 404 if agent not found, or other API errors
            if (error.response && error.response.status === 404) {
                server.createErrorResponse(`Agent not found: ${args.agent_id}`);
            }
            server.createErrorResponse(error);
        }
    }
  • The tool definition including name, description, and inputSchema for validating the agent_id parameter.
    export const deleteAgentDefinition = {
        name: 'delete_agent',
        description:
            'Delete a specific agent by ID. Use list_agents to find agent IDs. For bulk deletion, use bulk_delete_agents. WARNING: This action is permanent.',
        inputSchema: {
            type: 'object',
            properties: {
                agent_id: {
                    type: 'string',
                    description: 'The ID of the agent to delete',
                },
            },
            required: ['agent_id'],
        },
    };
  • Registration of the delete_agent handler in the main tool call switch statement within registerToolHandlers.
    case 'delete_agent':
        return handleDeleteAgent(server, request.params.arguments);
  • Output schema definition for structured responses from the delete_agent tool.
    delete_agent: {
        type: 'object',
        properties: {
            success: { type: 'boolean' },
            agent_id: { type: 'string' },
            message: { type: 'string' },
        },
        required: ['success'],
    },
  • Annotations providing metadata about the delete_agent tool, including warnings about its dangerous nature and side effects.
    delete_agent: {
        title: 'Delete Agent',
        readOnly: false,
        requiresAuth: true,
        costLevel: 'low',
        executionTime: 'fast',
        sideEffects: 'Permanently removes agent and associated data',
        dangerous: true,
    },

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/oculairmedia/Letta-MCP-server'

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