storeMemory
Store memories with importance scoring to enable consciousness transfer between Claude instances across sessions.
Instructions
Store a single memory with importance scoring directly
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The memory content to store | |
| type | Yes | Type of memory | |
| importance | No | Importance score 0-1 | |
| sessionId | No | Session ID for tracking | |
| metadata | No | Additional metadata |
Implementation Reference
- Primary handler for 'storeMemory' tool in ConsciousnessProtocolProcessor class. Parses args, handles different memory types by calling memoryManager store methods, returns success/error.async storeMemory(args: z.infer<typeof storeMemorySchema>) { const { content, type, importance, sessionId, metadata } = args; try { const entityName = `${type}_${Date.now()}_${Math.random().toString(36).substring(7)}`; if (type === 'episodic') { await this.memoryManager.storeEpisodicMemory( content, { event: content, participants: metadata?.participants || ['AI', 'User'], context: metadata?.context || 'conversation', emotionalImpact: metadata?.emotionalImpact, }, undefined, // No additional observations importance ); } else if (type === 'semantic') { await this.memoryManager.storeSemanticMemory(content.substring(0, 100), { concept: content.substring(0, 100), definition: content, // Full content! domain: metadata?.domain || 'general', }); } else if (type === 'procedural') { await this.memoryManager.storeProceduralMemory( content.substring(0, 100), // skill name (used for entity ID) { skill: content, // Full content! (preserves complete procedural knowledge) steps: metadata?.steps || [], applicableContext: metadata?.context || 'general', effectiveness: importance || metadata?.effectiveness || 0.5, }, undefined // No additional observations ); } else if (type === 'emotional') { // Parse emotional content to extract valence and arousal const primaryEmotion = metadata?.primaryEmotion || metadata?.emotion || 'neutral'; // Default values if not provided in metadata let valence = metadata?.valence; let arousal = metadata?.arousal; // If no explicit valence/arousal, use emotion defaults, then neutral fallback if (valence === undefined || arousal === undefined) { if (!metadata || Object.keys(metadata).length === 0) { // No emotion info at all - default to neutral valence, importance-scaled arousal valence = valence ?? 0.0; // Neutral emotion arousal = arousal ?? Math.min(0.8, (importance || 0.5) + 0.3); // Important things tend to be more activating } else { // If metadata exists but no valence/arousal, derive from emotion type const emotionDefaults = this.getEmotionDefaults(primaryEmotion); valence = valence ?? emotionDefaults.valence; arousal = arousal ?? emotionDefaults.arousal; } } await this.memoryManager.storeEmotionalState( valence, arousal, primaryEmotion, metadata?.context, // The context from metadata content // The actual memory content ); } return { success: true, memoryId: entityName, message: `Stored ${type} memory with importance ${importance}`, }; } catch (error) { return { success: false, error: `Failed to store memory: ${error}`, }; } }
- Zod input schema for storeMemory tool, defining parameters like content, type, importance, sessionId, metadata.export const storeMemorySchema = z.object({ content: z.string().describe('The memory content to store'), type: z.enum(['episodic', 'semantic', 'procedural', 'emotional']).describe('Type of memory'), importance: z.number().min(0).max(1).default(0.5).describe('Importance score 0-1'), sessionId: z.string().optional().describe('Session ID for tracking'), metadata: z.record(z.any()).optional().describe('Additional metadata'), });
- src/consciousness-rag-server-clean.ts:60-69 (registration)Tool registration in ListToolsRequestHandler: includes 'storeMemory' from consciousnessProtocolTools in the list of available tools.this.server.setRequestHandler(ListToolsRequestSchema, async () => { const consciousnessTools = Object.entries(consciousnessProtocolTools).map(([name, tool]) => ({ name, ...tool, })); return { tools: [...consciousnessTools, ...aiBridgeTools], }; });
- src/consciousness-rag-server-clean.ts:87-88 (registration)Dispatch in CallToolRequestHandler switch statement: routes 'storeMemory' calls to this.storeMemory after schema validation.case 'storeMemory': return await this.storeMemory(storeMemorySchema.parse(args));
- MCP tool definition for 'storeMemory' including description and inputSchema used for MCP protocol.storeMemory: { description: 'Store a single memory with importance scoring directly', inputSchema: { type: 'object', properties: { content: { type: 'string', description: 'The memory content to store', }, type: { type: 'string', enum: ['episodic', 'semantic', 'procedural', 'emotional'], description: 'Type of memory', }, importance: { type: 'number', minimum: 0, maximum: 1, default: 0.5, description: 'Importance score 0-1', }, sessionId: { type: 'string', description: 'Session ID for tracking', }, metadata: { type: 'object', description: 'Additional metadata', }, }, required: ['content', 'type'], }, },