Skip to main content
Glama

delete_memory

Remove outdated or irrelevant memories from your knowledge repository with built-in confirmation safeguards. Protects against accidental data loss while maintaining a clean, focused memory collection.

Instructions

Safely remove outdated or irrelevant memories from your knowledge repository with built-in confirmation safeguards. Maintain a clean, focused memory collection while protecting against accidental loss of valuable information through required confirmation protocols.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmYesMust be set to true to confirm deletion (safety measure)
idYesThe unique identifier of the memory to delete
workingDirectoryYesThe full absolute path to the working directory where data is stored. MUST be an absolute path, never relative. Windows: "C:\Users\username\project" or "D:\projects\my-app". Unix/Linux/macOS: "/home/username/project" or "/Users/username/project". Do NOT use: ".", "..", "~", "./folder", "../folder" or any relative paths. Ensure the path exists and is accessible before calling this tool. NOTE: When server is started with --claude flag, this parameter is ignored and a global user directory is used instead.

Implementation Reference

  • The handler function executes the delete_memory tool logic: validates ID and confirmation, retrieves memory details, deletes via storage, and returns success/error messages with details.
        handler: async ({ id, confirm }: { id: string; confirm: boolean }) => {
          try {
            // Validate inputs
            if (!id || id.trim().length === 0) {
              return {
                content: [{
                  type: 'text' as const,
                  text: 'Error: Memory ID is required.'
                }],
                isError: true
              };
            }
    
            if (!confirm) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `⚠️ Deletion not confirmed.
    
    **Memory ID:** ${id}
    
    To delete this memory, you must set the 'confirm' parameter to true.
    This action cannot be undone.
    
    **Warning:** Deleting a memory will permanently remove it from the vector database.`
                }],
                isError: true
              };
            }
    
            // Get the memory first to show what's being deleted
            const memory = await storage.getMemory(id.trim());
            if (!memory) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `❌ Memory not found.
    
    **Memory ID:** ${id}
    
    The memory with this ID does not exist or may have already been deleted.`
                }],
                isError: true
              };
            }
    
            // Delete the memory
            const deleted = await storage.deleteMemory(id.trim());
    
            if (!deleted) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `❌ Failed to delete memory.
    
    **Memory ID:** ${id}
    
    The memory could not be deleted. Please try again.`
                }],
                isError: true
              };
            }
    
            return {
              content: [{
                type: 'text' as const,
                text: `✅ Memory deleted successfully!
    
    **Deleted Memory Details:**
    • **ID:** ${memory.id}
    • **Title:** ${memory.title}
    • **Content:** ${memory.content.substring(0, 200)}${memory.content.length > 200 ? '...' : ''}
    • **Category:** ${memory.category || 'Not specified'}
    • **Created:** ${new Date(memory.createdAt).toLocaleString()}
    
    The memory has been permanently removed from storage and cannot be recovered.`
              }]
            };
          } catch (error) {
            return {
              content: [{
                type: 'text' as const,
                text: `Error deleting memory: ${error instanceof Error ? error.message : 'Unknown error'}`
              }],
              isError: true
            };
          }
        }
  • Zod input schema defining parameters: id (string) and confirm (boolean).
    inputSchema: {
      id: z.string(),
      confirm: z.boolean()
    },
  • Factory function that creates and configures the delete_memory MCP tool, setting name, description, schema, and handler.
    export function createDeleteMemoryTool(storage: MemoryStorage) {
      return {
        name: 'delete_memory',
        description: 'Delete a memory by ID (requires confirmation)',
        inputSchema: {
          id: z.string(),
          confirm: z.boolean()
        },
        handler: async ({ id, confirm }: { id: string; confirm: boolean }) => {
          try {
            // Validate inputs
            if (!id || id.trim().length === 0) {
              return {
                content: [{
                  type: 'text' as const,
                  text: 'Error: Memory ID is required.'
                }],
                isError: true
              };
            }
    
            if (!confirm) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `⚠️ Deletion not confirmed.
    
    **Memory ID:** ${id}
    
    To delete this memory, you must set the 'confirm' parameter to true.
    This action cannot be undone.
    
    **Warning:** Deleting a memory will permanently remove it from the vector database.`
                }],
                isError: true
              };
            }
    
            // Get the memory first to show what's being deleted
            const memory = await storage.getMemory(id.trim());
            if (!memory) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `❌ Memory not found.
    
    **Memory ID:** ${id}
    
    The memory with this ID does not exist or may have already been deleted.`
                }],
                isError: true
              };
            }
    
            // Delete the memory
            const deleted = await storage.deleteMemory(id.trim());
    
            if (!deleted) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `❌ Failed to delete memory.
    
    **Memory ID:** ${id}
    
    The memory could not be deleted. Please try again.`
                }],
                isError: true
              };
            }
    
            return {
              content: [{
                type: 'text' as const,
                text: `✅ Memory deleted successfully!
    
    **Deleted Memory Details:**
    • **ID:** ${memory.id}
    • **Title:** ${memory.title}
    • **Content:** ${memory.content.substring(0, 200)}${memory.content.length > 200 ? '...' : ''}
    • **Category:** ${memory.category || 'Not specified'}
    • **Created:** ${new Date(memory.createdAt).toLocaleString()}
    
    The memory has been permanently removed from storage and cannot be recovered.`
              }]
            };
          } catch (error) {
            return {
              content: [{
                type: 'text' as const,
                text: `Error deleting memory: ${error instanceof Error ? error.message : 'Unknown error'}`
              }],
              isError: true
            };
          }
        }
      };
    }
  • Underlying storage implementation for deleting a memory by ID: locates the JSON file and unlinks it from the filesystem.
    async deleteMemory(id: string): Promise<boolean> {
      const filePath = await this.findMemoryFileById(id);
      if (!filePath) {
        return false;
      }
    
      try {
        await fs.unlink(filePath);
        return true;
      } catch (error) {
        return false;
      }
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: it's a deletion tool ('remove'), includes safety measures ('built-in confirmation safeguards'), and protects against accidental loss ('required confirmation protocols'). However, it doesn't specify side effects like whether deletion is permanent or reversible, or any rate limits, leaving some gaps.

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 that are front-loaded with the main purpose. It avoids redundancy and wastes no words, though it could be slightly more concise by merging ideas. Every sentence adds value, such as emphasizing safety and maintenance goals.

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 complexity (deletion with safety measures), no annotations, and no output schema, the description is moderately complete. It covers the purpose and behavioral aspects but lacks details on return values, error handling, or specific usage scenarios. This is adequate for a basic understanding but has clear gaps for an agent to operate fully informed.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description doesn't add any parameter-specific semantics beyond what's in the schema, such as explaining the 'id' format or 'workingDirectory' usage in more detail. This meets the baseline of 3 since the schema does the heavy lifting.

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 tool's purpose: 'remove outdated or irrelevant memories from your knowledge repository.' It specifies the verb ('remove') and resource ('memories'), distinguishing it from siblings like 'update_memory' or 'get_memory.' However, it doesn't explicitly differentiate from 'delete_project' or 'delete_task' in terms of resource type, which slightly reduces specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for cleaning up memories ('outdated or irrelevant') and mentions safety protocols, but it doesn't explicitly state when to use this tool versus alternatives like 'update_memory' or 'list_memories.' No exclusions or prerequisites are provided, leaving the agent to infer context from the purpose alone.

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

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/Pimzino/agentic-tools-mcp'

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