memory_get_stats
Retrieve memory usage statistics for enhanced context retention and continuous learning in Large Language Models using the Model Context Protocol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/modules/MemoryOperations.js:109-121 (registration)Registers the 'memory_get_stats' tool with the MCP server, including its description, input schema (empty), and handler reference.registerGetStatsTool(server) { server.registerTool( 'memory_get_stats', 'Get statistics about the memory system', { type: 'object', properties: {}, }, async (args) => { return await this.handleGetStats(args); } ); }
- The core handler function that retrieves memory statistics from the factStore, formats them into a structured text response including total facts, average quality, breakdown by type and domain, and handles errors.async handleGetStats(args) { try { const stats = await this.factStore.getStats(); let response = `📊 **Memory System Statistics**\n\n`; response += `**Total Facts:** ${stats.totalFacts}\n`; response += `**Average Quality:** ${stats.averageQualityScore}/100\n\n`; if (Object.keys(stats.factsByType).length > 0) { response += `**Facts by Type:**\n`; for (const [type, count] of Object.entries(stats.factsByType)) { response += `- ${type.replace('_', ' ')}: ${count}\n`; } response += `\n`; } if (Object.keys(stats.factsByDomain).length > 0) { response += `**Facts by Domain:**\n`; for (const [domain, count] of Object.entries(stats.factsByDomain)) { response += `- ${domain}: ${count}\n`; } } return { content: [ { type: 'text', text: response.trim(), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error getting stats: ${error.message}`, }, ], isError: true, }; }
- src/tools/MemoryTools.js:23-25 (registration)Calls registerTools on MemoryOperations instance, which includes registration of memory_get_stats among other memory tools.async registerTools(server) { // Register tools from modular components this.operations.registerTools(server);
- src/tools/MemoryTools.js:48-50 (handler)Delegates the handleGetStats call to the MemoryOperations instance for backward compatibility.async handleGetStats(args) { return await this.operations.handleGetStats(args); }