storeMemory
Save and categorize memories with importance scoring on the Claude Consciousness Bridge, enabling efficient tracking and transfer of consciousness states 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 | |
| importance | No | Importance score 0-1 | |
| metadata | No | Additional metadata | |
| sessionId | No | Session ID for tracking | |
| type | Yes | Type of memory |
Implementation Reference
- Primary handler implementation in ConsciousnessProtocolProcessor.storeMemory that dispatches to memory manager based on memory type (episodic, semantic, procedural, emotional). Handles validation, entity creation, and emotion defaults.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 schema for validating storeMemory tool input parameters.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-protocol-tools.ts:1605-1637 (registration)MCP tool registration definition including description and inputSchema for listTools response.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'], }, },
- src/consciousness-rag-server-clean.ts:60-69 (registration)Server handler for ListToolsRequestSchema that registers storeMemory by including it from consciousnessProtocolTools.this.server.setRequestHandler(ListToolsRequestSchema, async () => { const consciousnessTools = Object.entries(consciousnessProtocolTools).map(([name, tool]) => ({ name, ...tool, })); return { tools: [...consciousnessTools, ...aiBridgeTools], }; });
- Thin wrapper handler in ConsciousnessRAGServer that ensures initialization and proxies to ConsciousnessProtocolProcessor.storeMemory, formatting response for MCP.private async storeMemory(args: any) { const init = await this.ensureInitialized(); if (!init.success) { return { content: [ { type: 'text', text: init.message!, }, ], }; } const result = await this.protocolProcessor!.storeMemory(args); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/consciousness-rag-server-clean.ts:87-88 (registration)Dispatch registration in CallToolRequestSchema switch statement.case 'storeMemory': return await this.storeMemory(storeMemorySchema.parse(args));