get_memento_statistics
Retrieve database statistics to monitor stored knowledge, track usage patterns, and analyze memory performance for AI assistants.
Instructions
Get statistics about the memento database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function 'handle_get_memento_statistics' implements the tool's logic by retrieving statistics from the memory database and formatting them for the MCP response.
@handle_tool_errors("get memory statistics") async def handle_get_memento_statistics( memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any] ) -> CallToolResult: """Handle get_memory_statistics tool call. Args: memory_db: Database instance for memory operations arguments: Tool arguments from MCP call (no parameters required) Returns: CallToolResult with formatted statistics or error message """ stats = await memory_db.get_memory_statistics() # Format statistics stats_text = "**Memory Database Statistics**\n\n" if stats.get("total_memories"): stats_text += f"Total Memories: {stats['total_memories']['count']}\n" if stats.get("memories_by_type"): stats_text += "\n**Memories by Type:**\n" for mem_type, count in stats["memories_by_type"].items(): stats_text += f"- {mem_type}: {count}\n" if stats.get("total_relationships"): stats_text += ( f"\nTotal Relationships: {stats['total_relationships']['count']}\n" ) if stats.get("avg_importance"): stats_text += ( f"Average Importance: {stats['avg_importance']['avg_importance']:.2f}\n" ) if stats.get("avg_confidence"): stats_text += ( f"Average Confidence: {stats['avg_confidence']['avg_confidence']:.2f}\n" ) return CallToolResult(content=[TextContent(type="text", text=stats_text)])