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

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

Input Schema (JSON Schema)

{ "properties": { "agentId": { "description": "ID of the agent storing the memory", "type": "string" }, "category": { "default": "general", "description": "Category for the memory entry (default: general)", "type": "string" }, "content": { "description": "Content to store in memory", "type": "string" }, "importance": { "default": 1, "description": "Importance level 1-10 (default: 1)", "type": "number" }, "sessionId": { "description": "ID of the current session", "type": "string" }, "tags": { "default": [], "description": "Tags for the memory entry", "items": { "type": "string" }, "type": "array" } }, "required": [ "content", "agentId", "sessionId" ], "type": "object" }

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}` }; } }

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