Skip to main content
Glama

delete_short_term_memories

Remove short-term memories by keyword or regex pattern to manage conversation data and optimize memory usage in the Memory MCP Server.

Instructions

Delete short-term memories matching a keyword or regex pattern.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesString keyword or regex pattern to match (e.g., "keyword" or "/pattern/i")
conversation_idYesConversation ID for storage

Implementation Reference

  • The primary handler function for the 'delete_short_term_memories' tool. Parses the pattern (supports regex format /pattern/i), delegates deletion to ShortTermMemoryManager.deleteMemories(), persists changes via storage, and returns deletion stats.
    handler: async (args) => {
      try {
        // Parse regex if pattern is in /.../ format
        let searchPattern = args.pattern;
        const regexMatch = args.pattern.match(/^\/(.+)\/([gimsuy]*)$/);
        
        if (regexMatch) {
          searchPattern = new RegExp(regexMatch[1], regexMatch[2]);
        }
    
        const deletedCount = memoryManager.deleteMemories(searchPattern);
        await storageManager.saveShortTermMemories(memoryManager.getMemories());
    
        return {
          success: true,
          deletedCount,
          remainingCount: memoryManager.getMemories().length,
          message: `Deleted ${deletedCount} memor${deletedCount === 1 ? 'y' : 'ies'}`
        };
      } catch (error) {
        return {
          success: false,
          error: error.message
        };
      }
    }
  • Zod input schema defining the tool parameters: pattern (string for keyword or regex) and conversation_id.
    inputSchema: z.object({
      pattern: z.string().describe('String keyword or regex pattern to match (e.g., "keyword" or "/pattern/i")'),
      conversation_id: z.string().describe('Conversation ID for storage')
    }),
  • Core deletion logic in ShortTermMemoryManager: filters memories array by matching pattern against mem.text (regex test or string includes), returns count of deleted items.
    deleteMemories(pattern) {
      const oldLength = this.memories.length;
      
      if (pattern instanceof RegExp) {
        this.memories = this.memories.filter(mem => !pattern.test(mem.text));
      } else {
        this.memories = this.memories.filter(mem => !mem.text.includes(pattern));
      }
    
      return oldLength - this.memories.length;
    }
  • src/index.js:152-154 (registration)
    Static registration of short-term tools (including delete_short_term_memories) for default conversation_id into the toolRegistry for list_tools.
    // 注册所有短期记忆工具
    const shortTermTools = createShortTermTools(defaultShortTermManager, defaultStorageManager);
    shortTermTools.forEach(tool => registerTool(tool, 'short-term'));
  • src/index.js:285-290 (registration)
    Dynamic recreation of short-term tools with conversation-specific managers and invocation of the matching tool handler during actual tool call execution.
      manager = await getShortTermManager(conversationId);
      storage = getStorageManager(conversationId);
      const tools = createShortTermTools(manager, storage, queryCache);
      const tool = tools.find(t => t.name === toolName);
      result = await withTimeout(tool.handler(validatedArgs), timeout, `Tool ${toolName} timeout`);
    } else if (toolScope === 'long-term' || toolName.includes('long_term')) {
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the deletion action but doesn't cover important aspects like whether deletion is permanent/reversible, what permissions are required, rate limits, or what happens to matched memories. The description is minimal and lacks behavioral context beyond the basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core functionality without any wasted words. It's appropriately sized for a simple deletion operation and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive deletion tool with no annotations and no output schema, the description is inadequate. It doesn't explain what 'short-term memories' are in this context, what the deletion consequences are, or what the tool returns. The description leaves too many open questions about this potentially destructive operation.

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 fully documents both parameters. The description mentions 'keyword or regex pattern' which aligns with the schema's pattern parameter description, but adds no additional semantic context beyond what's already in the structured schema fields.

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 action (delete) and resource (short-term memories) with the specific matching mechanism (keyword or regex pattern). It distinguishes from siblings like 'delete_long_term_memory' by specifying the memory type, though it doesn't explicitly contrast with other deletion tools like 'cleanup_memories' or 'delete_backup'.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when deletion is appropriate, what happens after deletion, or how it differs from similar tools like 'cleanup_memories' or 'delete_long_term_memory' in the sibling list.

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

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/win10ogod/memory-mcp-server'

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