Skip to main content
Glama

add_memory

Store content in an agent's memory system for future retrieval, using categories, importance levels, and tags to organize information.

Instructions

Add information to the agent memory system

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agentIdYesID of the agent storing the memory
categoryNoCategory for the memory entry (default: general)general
contentYesContent to store in memory
importanceNoImportance level 1-10 (default: 1)
sessionIdYesID of the current session
tagsNoTags for the memory entry

Implementation Reference

  • Input schema and metadata for the 'add_memory' tool, registered in the ListToolsRequestSchema handler.
    {
      name: 'add_memory',
      description: 'Add information to the agent memory system',
      inputSchema: {
        type: 'object',
        properties: {
          content: {
            type: 'string',
            description: 'Content to store in memory',
          },
          agentId: {
            type: 'string',
            description: 'ID of the agent storing the memory',
          },
          sessionId: {
            type: 'string',
            description: 'ID of the current session',
          },
          category: {
            type: 'string',
            description: 'Category for the memory entry (default: general)',
            default: 'general',
          },
          importance: {
            type: 'number',
            description: 'Importance level 1-10 (default: 1)',
            default: 1,
          },
          tags: {
            type: 'array',
            items: { type: 'string' },
            description: 'Tags for the memory entry',
            default: [],
          },
        },
        required: ['content', 'agentId', 'sessionId'],
      },
    },
  • src/index.ts:245-253 (registration)
    Tool dispatch/registration in the CallToolRequestSchema switch statement, routing to handleAddMemory.
    case 'add_memory':
      return await this.handleAddMemory(args as {
        content: string;
        agentId: string;
        sessionId: string;
        category?: string;
        importance?: number;
        tags?: string[];
      });
  • Primary MCP tool handler `handleAddMemory` that executes the tool by calling RAGService.addMemory and returns standardized MCP content response.
    private async handleAddMemory(args: {
      content: string;
      agentId: string;
      sessionId: string;
      category?: string;
      importance?: number;
      tags?: string[];
    }) {
      const result = await this.ragService.addMemory(
        args.content,
        args.agentId,
        args.sessionId,
        args.category,
        args.importance,
        args.tags
      );
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Service layer implementation in RAGService.addMemory that constructs MemoryEntry with metadata and delegates persistence to vectorDatabase.
    async addMemory(
      content: string,
      agentId: string,
      sessionId: string,
      category: string = 'general',
      importance: number = 1,
      tags: string[] = []
    ): Promise<{
      success: boolean;
      memoryId: string;
      message: string;
    }> {
      try {
        const memoryId = uuidv4();
        
        const memoryEntry: MemoryEntry = {
          id: memoryId,
          content,
          metadata: {
            agentId,
            sessionId,
            timestamp: new Date().toISOString(),
            category,
            importance,
            tags
          }
        };
    
        await this.vectorDatabase.addMemory(memoryEntry);
        
        logger.info(`Added memory entry: ${memoryId}`);
        
        return {
          success: true,
          memoryId,
          message: 'Memory added successfully'
        };
      } catch (error) {
        logger.error(`Error adding memory: ${error}`);
        return {
          success: false,
          memoryId: '',
          message: `Failed to add memory: ${error}`
        };
      }
    }
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 this is an 'Add' operation, implying a write/mutation, but doesn't clarify permissions needed, whether this is idempotent, how memory is structured, or what happens on success/failure. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 states the core purpose without unnecessary words. It's appropriately sized for a tool with good schema documentation and gets straight to the point with zero waste.

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 mutation tool with 6 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what 'adding information' means operationally, how memory entries are organized, what the response looks like, or potential side effects. The agent lacks crucial context to use this tool effectively despite the comprehensive schema.

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 all parameters are documented in the schema. The description adds no additional parameter semantics beyond what's already in the schema. This meets the baseline score of 3 when the schema does the heavy lifting, but the description doesn't compensate with any extra context about parameter relationships or usage patterns.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Add information to the agent memory system', which provides a clear verb ('Add') and resource ('agent memory system'). However, it doesn't distinguish this from sibling tools like 'add_file' or 'remove_memory', leaving ambiguity about what specifically makes this tool different from other memory-related operations.

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 like 'add_file' or 'search_memory'. It doesn't mention prerequisites, context for memory addition, or any exclusions. The agent must infer usage from the tool name and parameters 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

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/santis84/mcp-rag'

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