Skip to main content
Glama

list_memories

Organize and explore stored knowledge by filtering memories by category and retrieving insights. Ideal for reviewing accumulated information, identifying patterns, and maintaining decision awareness.

Instructions

Browse and explore your knowledge repository with organized memory listings and flexible category filtering. Perfect for reviewing stored information, discovering patterns in your knowledge base, and maintaining awareness of your accumulated insights and decisions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter to memories in this specific category
limitNoMaximum number of memories to return (default: 50)
workingDirectoryYesThe full absolute path to the working directory where data is stored. MUST be an absolute path, never relative. Windows: "C:\Users\username\project" or "D:\projects\my-app". Unix/Linux/macOS: "/home/username/project" or "/Users/username/project". Do NOT use: ".", "..", "~", "./folder", "../folder" or any relative paths. Ensure the path exists and is accessible before calling this tool. NOTE: When server is started with --claude flag, this parameter is ignored and a global user directory is used instead.

Implementation Reference

  • src/server.ts:813-840 (registration)
    MCP server.tool() registration for 'list_memories'. Creates MemoryStorage instance and invokes createListMemoriesTool(storage).handler with parameters.
    server.tool(
      'list_memories',
      'Browse and explore your knowledge repository with organized memory listings and flexible category filtering. Perfect for reviewing stored information, discovering patterns in your knowledge base, and maintaining awareness of your accumulated insights and decisions.',
      {
        workingDirectory: z.string().describe(getWorkingDirectoryDescription(config)),
        category: z.string().optional().describe('Filter to memories in this specific category'),
        limit: z.number().min(1).max(1000).optional().describe('Maximum number of memories to return (default: 50)')
      },
      async ({ workingDirectory, category, limit }: {
        workingDirectory: string;
        category?: string;
        limit?: number;
      }) => {
        try {
          const storage = await createMemoryStorage(workingDirectory, config);
          const tool = createListMemoriesTool(storage);
          return await tool.handler({ category, limit });
        } catch (error) {
          return {
            content: [{
              type: 'text' as const,
              text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`
            }],
            isError: true
          };
        }
      }
    );
  • Core handler function for list_memories tool. Validates inputs, fetches memories from storage with optional category/limit filters, sorts by newest first, formats list with previews and stats, handles empty results and errors.
        handler: async ({
          category,
          limit = 50
        }: {
          category?: string;
          limit?: number;
        }) => {
          try {
            // Validate inputs
            if (limit < 1 || limit > 1000) {
              return {
                content: [{
                  type: 'text' as const,
                  text: 'Error: Limit must be between 1 and 1000.'
                }],
                isError: true
              };
            }
    
            if (category && category.trim().length > 100) {
              return {
                content: [{
                  type: 'text' as const,
                  text: 'Error: Category must be 100 characters or less.'
                }],
                isError: true
              };
            }
    
            const memories = await storage.getMemories(
              undefined, // agentId removed
              category?.trim(),
              limit
            );
    
            if (memories.length === 0) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `πŸ“ No memories found.
    
    **Filters:** ${[
                    category && `Category: ${category}`
                  ].filter(Boolean).join(', ') || 'None'}
    
    Create some memories using the create_memory tool to get started!`
                }]
              };
            }
    
            // Sort memories by creation date (newest first)
            const sortedMemories = memories.sort((a, b) =>
              new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
            );
    
            const memoryList = sortedMemories.map((memory, index) => {
              return `**${index + 1}. ${memory.title}**
    Content: ${memory.content.substring(0, 150)}${memory.content.length > 150 ? '...' : ''}
    Category: ${memory.category || 'Not specified'}
    Created: ${new Date(memory.createdAt).toLocaleString()}`;
            }).join('\n\n');
    
            // Get statistics
            const stats = await storage.getStatistics();
    
            return {
              content: [{
                type: 'text' as const,
                text: `πŸ“ Found ${memories.length} memory(ies):
    
    **Filters:** ${[
                  category && `Category: ${category}`
                ].filter(Boolean).join(', ') || 'None'}
    **Limit:** ${limit}
    
    ${memoryList}
    
    ---
    
    **πŸ“Š Overall Statistics:**
    β€’ Total memories: ${stats.totalMemories}
    β€’ Categories: ${Object.keys(stats.memoriesByCategory).length}
    β€’ Oldest memory: ${stats.oldestMemory ? new Date(stats.oldestMemory).toLocaleString() : 'None'}
    β€’ Newest memory: ${stats.newestMemory ? new Date(stats.newestMemory).toLocaleString() : 'None'}
    
    Use get_memory with a specific ID to see full details, or search_memories for text-based search.`
              }]
            };
          } catch (error) {
            return {
              content: [{
                type: 'text' as const,
                text: `Error listing memories: ${error instanceof Error ? error.message : 'Unknown error'}`
              }],
              isError: true
            };
          }
        }
  • Zod input schema definition for the list_memories tool: optional category (string), optional limit (number 1-1000).
    inputSchema: {
      category: z.string().optional(),
      limit: z.number().min(1).max(1000).optional()
    },
  • Factory function createListMemoriesTool that returns the complete tool object specification including name, description, inputSchema, and handler for registration.
    export function createListMemoriesTool(storage: MemoryStorage) {
      return {
        name: 'list_memories',
        description: 'List memories with optional filtering by category and limit',
        inputSchema: {
          category: z.string().optional(),
          limit: z.number().min(1).max(1000).optional()
        },
        handler: async ({
          category,
          limit = 50
        }: {
          category?: string;
          limit?: number;
        }) => {
          try {
            // Validate inputs
            if (limit < 1 || limit > 1000) {
              return {
                content: [{
                  type: 'text' as const,
                  text: 'Error: Limit must be between 1 and 1000.'
                }],
                isError: true
              };
            }
    
            if (category && category.trim().length > 100) {
              return {
                content: [{
                  type: 'text' as const,
                  text: 'Error: Category must be 100 characters or less.'
                }],
                isError: true
              };
            }
    
            const memories = await storage.getMemories(
              undefined, // agentId removed
              category?.trim(),
              limit
            );
    
            if (memories.length === 0) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `πŸ“ No memories found.
    
    **Filters:** ${[
                    category && `Category: ${category}`
                  ].filter(Boolean).join(', ') || 'None'}
    
    Create some memories using the create_memory tool to get started!`
                }]
              };
            }
    
            // Sort memories by creation date (newest first)
            const sortedMemories = memories.sort((a, b) =>
              new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
            );
    
            const memoryList = sortedMemories.map((memory, index) => {
              return `**${index + 1}. ${memory.title}**
    Content: ${memory.content.substring(0, 150)}${memory.content.length > 150 ? '...' : ''}
    Category: ${memory.category || 'Not specified'}
    Created: ${new Date(memory.createdAt).toLocaleString()}`;
            }).join('\n\n');
    
            // Get statistics
            const stats = await storage.getStatistics();
    
            return {
              content: [{
                type: 'text' as const,
                text: `πŸ“ Found ${memories.length} memory(ies):
    
    **Filters:** ${[
                  category && `Category: ${category}`
                ].filter(Boolean).join(', ') || 'None'}
    **Limit:** ${limit}
    
    ${memoryList}
    
    ---
    
    **πŸ“Š Overall Statistics:**
    β€’ Total memories: ${stats.totalMemories}
    β€’ Categories: ${Object.keys(stats.memoriesByCategory).length}
    β€’ Oldest memory: ${stats.oldestMemory ? new Date(stats.oldestMemory).toLocaleString() : 'None'}
    β€’ Newest memory: ${stats.newestMemory ? new Date(stats.newestMemory).toLocaleString() : 'None'}
    
    Use get_memory with a specific ID to see full details, or search_memories for text-based search.`
              }]
            };
          } catch (error) {
            return {
              content: [{
                type: 'text' as const,
                text: `Error listing memories: ${error instanceof Error ? error.message : 'Unknown error'}`
              }],
              isError: true
            };
          }
        }
      };
    }
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 describes the tool as for 'browsing and exploring' with 'flexible category filtering,' which implies a read-only, non-destructive operation, but it doesn't explicitly state this. It also doesn't mention any rate limits, authentication needs, or what the output looks like (e.g., pagination, format). For a tool with no annotations, 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.

Conciseness3/5

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

The description is two sentences long and front-loaded with the core purpose, but it includes vague marketing language like 'Perfect for reviewing stored information, discovering patterns in your knowledge base, and maintaining awareness of your accumulated insights and decisions,' which doesn't add operational value. This reduces efficiency, though the structure is generally clear.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no annotations, no output schema), the description is partially complete. It covers the basic purpose and hints at filtering, but it lacks details on output format, error handling, or behavioral constraints. Without annotations or output schema, more context would be helpful for an agent to use it effectively, but it's not entirely inadequate.

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%, so the schema already fully documents all three parameters (category, limit, workingDirectory). The description adds no additional meaning beyond what's in the schemaβ€”it mentions 'flexible category filtering' which aligns with the 'category' parameter but provides no extra details. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't detract either.

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 tool's purpose as 'browse and explore your knowledge repository with organized memory listings and flexible category filtering.' It specifies the verb (browse/explore) and resource (knowledge repository/memories). However, it doesn't explicitly differentiate from sibling tools like 'search_memories' or 'get_memory,' which is why it doesn't achieve 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. It mentions it's 'perfect for reviewing stored information, discovering patterns, and maintaining awareness,' but this is generic and doesn't help an agent choose between 'list_memories,' 'search_memories,' or 'get_memory.' There are no explicit when/when-not instructions or named alternatives.

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

Related 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/Pimzino/agentic-tools-mcp'

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