get_memory_stats
Retrieve statistics about stored conversation memory to monitor usage and analyze data patterns in architectural decision records.
Instructions
Phase 3: Get statistics about stored conversation memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Main handler function for the get_memory_stats tool. Calls memoryManager.getStats() and formats statistics about conversation memory storage including sessions, turns, and size.* Get Conversation Memory Statistics Tool * * Provides statistics about stored conversation memory. */ export async function getMemoryStats( memoryManager: ConversationMemoryManager ): Promise<CallToolResult> { try { const stats = await memoryManager.getStats(); let output = `# Conversation Memory Statistics\n\n`; output += `## Storage Overview\n\n`; output += `- **Total Sessions**: ${stats.totalSessions}\n`; output += `- **Active Sessions**: ${stats.activeSessions}\n`; output += `- **Archived Sessions**: ${stats.archivedSessions}\n`; output += `- **Total Turns**: ${stats.totalTurns}\n`; output += `- **Expandable Content Items**: ${stats.totalExpandableContent}\n`; output += `- **Average Turns per Session**: ${stats.avgTurnsPerSession.toFixed(2)}\n`; output += `- **Total Storage Size**: ${(stats.totalStorageBytes / 1024).toFixed(2)} KB\n`; return { content: [ { type: 'text', text: output, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `❌ Failed to get memory stats: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/tools/tool-catalog.ts:960-977 (schema)Tool metadata and input schema definition in the central TOOL_CATALOG registry, including description, category, complexity, and inputSchema.TOOL_CATALOG.set('get_memory_stats', { name: 'get_memory_stats', shortDescription: 'Get memory statistics', fullDescription: 'Gets statistics about memory usage and storage.', category: 'memory', complexity: 'simple', tokenCost: { min: 200, max: 400 }, hasCEMCPDirective: true, // Phase 4.3: Simple tool - stats retrieval relatedTools: ['memory_loading', 'expand_memory'], keywords: ['memory', 'stats', 'statistics', 'usage'], requiresAI: false, inputSchema: { type: 'object', properties: { detailed: { type: 'boolean', default: false }, }, }, });
- src/tools/tool-catalog.ts:960-977 (registration)Registration of the get_memory_stats tool in the dynamic tool catalog used for MCP tool discovery and ListTools responses.TOOL_CATALOG.set('get_memory_stats', { name: 'get_memory_stats', shortDescription: 'Get memory statistics', fullDescription: 'Gets statistics about memory usage and storage.', category: 'memory', complexity: 'simple', tokenCost: { min: 200, max: 400 }, hasCEMCPDirective: true, // Phase 4.3: Simple tool - stats retrieval relatedTools: ['memory_loading', 'expand_memory'], keywords: ['memory', 'stats', 'statistics', 'usage'], requiresAI: false, inputSchema: { type: 'object', properties: { detailed: { type: 'boolean', default: false }, }, }, });