Skip to main content
Glama

get_memory_stats

Retrieve statistical data about short-term memories to monitor usage patterns and analyze memory performance within conversations.

Instructions

Get statistical information about short-term memories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversation_idNoOptional conversation ID for context

Implementation Reference

  • The MCP tool handler for get_memory_stats. Calls ShortTermMemoryManager.getStats() and formats date fields for output.
    handler: async (args) => {
      try {
        const stats = memoryManager.getStats();
    
        return {
          ...stats,
          oldestMemory: stats.oldestMemory ? new Date(stats.oldestMemory).toISOString() : null,
          newestMemory: stats.newestMemory ? new Date(stats.newestMemory).toISOString() : null,
          lastCleanup: new Date(stats.lastCleanup).toISOString()
        };
      } catch (error) {
        return {
          error: error.message
        };
      }
  • Zod input schema for the tool, accepting an optional conversation_id.
    inputSchema: z.object({
      conversation_id: z.string().optional().describe('Optional conversation ID for context')
    }),
  • src/index.js:152-154 (registration)
    Registers all short-term tools, including get_memory_stats, to the global toolRegistry using default managers for list_tools.
    // 注册所有短期记忆工具
    const shortTermTools = createShortTermTools(defaultShortTermManager, defaultStorageManager);
    shortTermTools.forEach(tool => registerTool(tool, 'short-term'));
  • Core statistics computation in ShortTermMemoryManager.getStats(), aggregating memory counts, scores, timestamps, and conversation stats.
    getStats() {
      const now = Date.now();
      const conversationCounts = {};
      let totalScore = 0;
      let maxScore = -Infinity;
      let minScore = Infinity;
    
      for (const mem of this.memories) {
        conversationCounts[mem.conversation_id] = (conversationCounts[mem.conversation_id] || 0) + 1;
        totalScore += mem.score;
        maxScore = Math.max(maxScore, mem.score);
        minScore = Math.min(minScore, mem.score);
      }
    
      return {
        total: this.memories.length,
        conversationCounts,
        avgScore: this.memories.length > 0 ? totalScore / this.memories.length : 0,
        maxScore: this.memories.length > 0 ? maxScore : 0,
        minScore: this.memories.length > 0 ? minScore : 0,
        oldestMemory: this.memories.length > 0 
          ? Math.min(...this.memories.map(m => m.time_stamp.getTime()))
          : null,
        newestMemory: this.memories.length > 0 
          ? Math.max(...this.memories.map(m => m.time_stamp.getTime()))
          : null,
        lastCleanup: this.lastCleanupTime
      };
    }
  • src/index.js:284-289 (registration)
    Dynamic recreation and execution of short-term tools (including get_memory_stats) with conversation-specific managers during tool call handling.
    if (toolScope === 'short-term' || toolName.includes('short_term')) {
      manager = await getShortTermManager(conversationId);
      storage = getStorageManager(conversationId);
      const tools = createShortTermTools(manager, storage, queryCache);
      const tool = tools.find(t => t.name === toolName);
      result = await withTimeout(tool.handler(validatedArgs), timeout, `Tool ${toolName} timeout`);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves statistical information, implying a read-only operation, but doesn't specify what statistics are included, format of return data, performance characteristics, or any side effects. For a stats tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part earns its place by clearly stating the action and target, making it easy to parse quickly. There is no redundancy or structural issues.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that likely returns complex statistical data. It doesn't explain what statistics are provided, their format, or how the optional parameter affects results. For a stats tool in a memory management context with many siblings, more detail is needed to ensure proper use without confusion.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'conversation_id' documented as optional for context. The description adds no additional parameter information beyond what the schema provides, such as examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('statistical information about short-term memories'), making the purpose immediately understandable. It distinguishes from siblings like 'get_cache_stats' or 'get_metrics' by specifying the memory type. However, it doesn't explicitly differentiate from 'analyze_memory_patterns' which might also involve statistics, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_cache_stats', 'get_metrics', and 'analyze_memory_patterns' that might overlap in statistical reporting, there is no indication of context, prerequisites, or exclusions. The optional 'conversation_id' parameter hints at filtering but offers no usage rules.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/win10ogod/memory-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server