Skip to main content
Glama

get_memory_summary

Retrieve a high-level summary of a memory document to quickly understand its key content and context for informed decision-making.

Instructions

Get a high-level summary of a memory document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesThe ID of the memory document to summarize

Implementation Reference

  • Main handler function for the get_memory_summary tool. Reads the memory document, parses sections, computes statistics (sections, words, list items, active sections, age), generates formatted summary text using helpers, and returns it as MCP content.
    export async function getMemorySummaryTool(
      storageManager: StorageManager,
      args: any
    ): Promise<any> {
      const params = args as GetMemorySummaryParams;
      
      if (!params.memory_id) {
        throw new Error('memory_id is required');
      }
    
      // Read the memory document
      const memory = await storageManager.readMemory(params.memory_id);
      if (!memory) {
        throw new Error(`Memory document '${params.memory_id}' not found`);
      }
    
      // Parse sections for analysis
      const sections = storageManager.parseSections(memory.content);
      
      // Generate summary statistics
      const totalSections = sections.length;
      const nonEmptySections = sections.filter(s => s.content.trim().length > 0).length;
      
      // Count different types of content
      let totalItems = 0;
      let listSections = 0;
      
      sections.forEach(section => {
        const content = section.content.trim();
        if (content) {
          const analysis = analyzeContent(content);
          if (analysis.totalItems > 0) {
            totalItems += analysis.totalItems;
            listSections++;
          }
        }
      });
    
      // Calculate content metrics
      const totalWords = memory.content.split(/\s+/).filter(word => word.length > 0).length;
      const totalChars = memory.content.length;
      
      // Identify the most active sections (by content length)
      const activeSections = findActiveSections(sections);
    
      // Format creation and update dates
      const created = new Date(memory.metadata.created);
      const updated = new Date(memory.metadata.updated);
      const daysSinceCreated = calculateDaysSince(created.getTime());
      const daysSinceUpdated = calculateDaysSince(updated.getTime());
    
      // Build summary using helper function
      const summaryData: SummaryData = {
        memory,
        totalSections,
        nonEmptySections,
        listSections,
        totalItems,
        totalWords,
        totalChars,
        activeSections,
        daysSinceCreated,
        daysSinceUpdated,
        sections
      };
      
      const summary = generateSummaryText(summaryData);
    
      return {
        content: [{
          type: 'text',
          text: summary
        }]
      };
    }
  • TypeScript interface defining the input parameters for the get_memory_summary tool (requires memory_id).
    export interface GetMemorySummaryParams {
      memory_id: string;
    }
  • src/index.ts:109-122 (registration)
    Tool registration in the ListTools handler, specifying name, description, and input schema for MCP protocol compliance.
    {
      name: "get_memory_summary",
      description: "Get a high-level summary of a memory document",
      inputSchema: {
        type: "object",
        properties: {
          memory_id: {
            type: "string",
            description: "The ID of the memory document to summarize",
          },
        },
        required: ["memory_id"],
      },
    },
  • src/index.ts:271-272 (registration)
    Dispatch in the CallTool handler switch statement, invoking the tool implementation.
    case "get_memory_summary":
      return await getMemorySummaryTool(storageManager, args);
  • Helper functions used by the handler: analyzeContent for list/heading detection, calculateDaysSince for age computation, findActiveSections for top sections by length.
    export function analyzeContent(content: string): { bulletCount: number; numberedCount: number; headingCount: number; totalItems: number } {
      const bulletMatches = content.match(/^[\s]*[-*+]\s/gm) || [];
      const numberedMatches = content.match(/^[\s]*\d+\.\s/gm) || [];
      const headingMatches = content.match(/^[\s]*#{3,}\s/gm) || [];
      
      return {
        bulletCount: bulletMatches.length,
        numberedCount: numberedMatches.length,
        headingCount: headingMatches.length,
        totalItems: bulletMatches.length + numberedMatches.length + headingMatches.length
      };
    }
    
    export function calculateDaysSince(timestamp: number): number {
      return Math.floor((Date.now() - timestamp) / (1000 * 60 * 60 * 24));
    }
    
    export function findActiveSections(sections: Array<{ name: string; content: string }>): string[] {
      return sections
        .filter(s => s.content.trim().length > 0)
        .sort((a, b) => b.content.length - a.content.length)
        .slice(0, 3)
        .map(s => s.name);
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool retrieves a 'high-level summary' but doesn't disclose behavioral traits such as what format the summary is in, if it's read-only (implied but not explicit), any rate limits, or error conditions. This leaves significant gaps for an agent to understand how the tool behaves.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 no annotations and no output schema, the description is incomplete. It doesn't explain what the summary includes (e.g., key points, metadata), how it's structured, or any limitations. For a tool with one parameter but unknown output behavior, more context is needed to guide effective use.

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?

Schema description coverage is 100%, with the single parameter 'memory_id' clearly documented in the schema. The description doesn't add any meaning beyond this, such as explaining what constitutes a valid memory ID or how to obtain one. Baseline 3 is appropriate since the schema handles parameter documentation adequately.

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 action ('Get') and resource ('a high-level summary of a memory document'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_full_memory' or 'get_section', which also retrieve memory-related information but with different scope or detail.

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?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'get_full_memory' (likely retrieves complete content) and 'get_section' (likely retrieves specific parts), the description lacks context on choosing this tool for a summary over other retrieval options.

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/nmeierpolys/mcp-structured-memory'

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