Skip to main content
Glama

list_memories

List all stored memories in a project with stats on namespace, type, key, and priority. Use this to review and understand what knowledge is stored.

Instructions

List all stored memories for the current project with stats. Shows namespace, type, key, priority. Useful for understanding what knowledge is stored.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNoFilter by namespace
projectIdNoProject ID (defaults to current project)

Implementation Reference

  • The tool handler for 'list_memories' — registers with server.tool(), receives optional namespace and projectId params, calls memoryService.list() and memoryService.getStats(), returns JSON with stats and memories (mapped to namespace, type, key, priority, confidence, updatedAt, expires).
    // ─── list_memories ──────────────────────────────────────────────
    server.tool(
      'list_memories',
      'List all stored memories for the current project with stats. Shows namespace, type, key, priority. Useful for understanding what knowledge is stored.',
      {
        namespace: z.string().optional().describe('Filter by namespace'),
        projectId: z.string().optional().describe('Project ID (defaults to current project)'),
      },
      async ({ namespace, projectId }) => {
        try {
          const { memoryService, currentProjectId } = await getServices()
          const targetProjectId = projectId || currentProjectId
    
          const [memories, stats] = await Promise.all([
            memoryService.list({ projectId: targetProjectId, namespace }),
            memoryService.getStats(targetProjectId),
          ])
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                projectId: targetProjectId,
                stats,
                memories: memories.map(m => ({
                  namespace: m.namespace,
                  type: m.memory_type,
                  key: m.key,
                  priority: m.priority,
                  confidence: m.confidence,
                  updatedAt: m.updated_at,
                  expires: m.expires_at,
                })),
              }, null, 2),
            }],
          }
        } catch (error) {
          return {
            content: [{ type: 'text', text: `Error listing memories: ${error.message}` }],
            isError: true,
          }
        }
      }
  • Input schema for list_memories using Zod: namespace (optional string) and projectId (optional string).
    {
      namespace: z.string().optional().describe('Filter by namespace'),
      projectId: z.string().optional().describe('Project ID (defaults to current project)'),
    },
  • The MemoryService.list() method — queries the project_memories table filtering by projectId and optional namespace, only returns non-expired rows, ordered by namespace, priority DESC, updated_at DESC.
    async list({ projectId, namespace }) {
      let sql = `
        SELECT namespace, memory_type, key, priority, confidence, updated_at, expires_at
        FROM project_memories
        WHERE project_id = ?
          AND (expires_at IS NULL OR expires_at > datetime('now'))
      `
      const params = [projectId]
    
      if (namespace) {
        sql += ' AND namespace = ?'
        params.push(namespace)
      }
    
      sql += ' ORDER BY namespace, priority DESC, updated_at DESC'
    
      return this.searchDb.db.all(sql, params)
    }
  • The MemoryService.getStats() method — returns total count and count by namespace for a given projectId (excluding expired memories).
    async getStats(projectId) {
      const total = await this.searchDb.db.get(
        'SELECT COUNT(*) as count FROM project_memories WHERE project_id = ?',
        [projectId]
      )
      const byNamespace = await this.searchDb.db.all(`
        SELECT namespace, COUNT(*) as count
        FROM project_memories
        WHERE project_id = ? AND (expires_at IS NULL OR expires_at > datetime('now'))
        GROUP BY namespace
      `, [projectId])
    
      return {
        total: total?.count || 0,
        byNamespace: Object.fromEntries(byNamespace.map(r => [r.namespace, r.count])),
      }
    }
  • Registration call: registerTools(server, getServices) connects the tools module to the MCP server, executed at server startup.
    registerTools(server, getServices)
    registerResources(server, getServices)
    registerPrompts(server)
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for behavioral disclosure. It only says 'List,' implying a read operation, but does not explicitly state that the tool is non-destructive, does not modify state, or require any permissions. No information about rate limits or side effects.

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 two sentences long, with the action verb 'List' upfront. Every word adds value; no fluff or repetition.

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

Completeness4/5

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

There is no output schema, so the description partially explains return values (namespace, type, key, priority, stats). For a simple list tool with two optional parameters, this is sufficient, though explicit format could be helpful.

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

Parameters4/5

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

Schema coverage is 100%, so parameters are well-documented. The description adds value by mentioning that the output shows stats and priority, which are not in the parameter descriptions. This helps the agent understand what the result contains.

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

Purpose5/5

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

The description clearly states the tool lists all stored memories for the current project, which distinguishes it from siblings like store_memory, delete_memory, and recall_memory. It also specifies what information is shown (namespace, type, key, priority).

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

Usage Guidelines3/5

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

The description says 'Useful for understanding what knowledge is stored,' which implies usage context but does not explicitly compare to alternatives like search_conversations or recall_memory. No when-not or exclusion criteria are provided.

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/kunwar-shah/claudex'

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