Skip to main content
Glama

add_short_term_memory

Store recent conversation messages as indexed short-term memory with keyword-based relevance scoring that decays over time.

Instructions

Add a new short-term memory entry from recent conversation messages. The memory will be indexed by keywords and scored based on relevance over time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messagesYesArray of recent messages to create memory from
conversation_idYesUnique identifier for the conversation
roleWeightsNoOptional weights for different roles when extracting keywords (default: user=2.7, assistant=2.0, system=1.0)

Implementation Reference

  • The core handler function for the 'add_short_term_memory' tool. It processes input arguments, adds the memory entry using ShortTermMemoryManager.addMemory(), persists the memories to storage, and returns success status with total count.
    handler: async (args) => {
      try {
        const success = await memoryManager.addMemory(
          args.messages,
          args.conversation_id,
          { roleWeights: args.roleWeights }
        );
    
        if (success) {
          await storageManager.saveShortTermMemories(memoryManager.getMemories());
          return {
            success: true,
            message: 'Memory added successfully',
            totalMemories: memoryManager.getMemories().length
          };
        } else {
          return {
            success: false,
            message: 'Failed to add memory (possibly empty content)'
          };
        }
      } catch (error) {
        return {
          success: false,
          error: error.message
        };
      }
    }
  • Zod schema defining the input structure for the tool, including messages array, conversation_id, and optional roleWeights.
    inputSchema: z.object({
      messages: z.array(z.object({
        role: z.enum(['user', 'assistant', 'system']).describe('Message role'),
        content: z.string().describe('Message content'),
        timestamp: z.number().optional().describe('Unix timestamp in milliseconds')
      })).describe('Array of recent messages to create memory from'),
      conversation_id: z.string().describe('Unique identifier for the conversation'),
      roleWeights: z.object({
        user: z.number().optional(),
        assistant: z.number().optional(),
        system: z.number().optional()
      }).optional().describe('Optional weights for different roles when extracting keywords (default: user=2.7, assistant=2.0, system=1.0)')
    }),
  • src/index.js:284-289 (registration)
    Dynamic registration and execution of short-term tools (including add_short_term_memory) during tool calls, creating conversation-specific tool instances with appropriate managers.
    if (toolScope === 'short-term' || toolName.includes('short_term')) {
      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`);
  • src/index.js:153-155 (registration)
    Initial registration of default short-term tools for list_tools response using default managers.
    const shortTermTools = createShortTermTools(defaultShortTermManager, defaultStorageManager);
    shortTermTools.forEach(tool => registerTool(tool, 'short-term'));
Behavior2/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 mentions that memories are 'indexed by keywords and scored based on relevance over time,' which adds some context about processing behavior. However, it fails to address critical aspects such as whether this is a read-only or mutative operation, potential side effects, error conditions, or how the memory is stored and accessed. For a tool that likely involves data creation with no annotation coverage, this is insufficient.

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 concise and well-structured in two sentences. The first sentence clearly states the purpose, and the second adds useful behavioral context without redundancy. Every sentence earns its place, making it efficient and front-loaded with essential information.

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 (involving memory creation with multiple parameters and no output schema), the description is moderately complete. It covers the basic purpose and some processing behavior but lacks details on usage guidelines, error handling, and output expectations. Without annotations or an output schema, the description should do more to compensate, but it provides a minimal viable explanation.

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?

The input schema has 100% description coverage, providing clear documentation for all parameters. The description adds minimal value beyond the schema, as it only implies that 'messages' are used to 'create memory' without detailing how parameters interact or their semantic roles. Given the high schema coverage, a baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

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: 'Add a new short-term memory entry from recent conversation messages.' It specifies the verb ('Add') and resource ('short-term memory entry'), and distinguishes it from siblings like 'add_long_term_memory' by specifying 'short-term.' However, it doesn't explicitly differentiate from other memory-related tools like 'search_short_term_memories' or 'delete_short_term_memories,' which prevents a perfect score.

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 to choose 'add_short_term_memory' over 'add_long_term_memory' or other sibling tools, nor does it specify prerequisites or exclusions. This lack of contextual usage advice limits its effectiveness for an AI agent.

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