Skip to main content
Glama

get_memory_clusters

Retrieve memory clusters organized by importance and activity to analyze persistent AI memory patterns and thematic data groupings.

Instructions

Retrieve memory clusters ordered by importance/activity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of clusters to return

Implementation Reference

  • The main implementation of getMemoryClusters method that retrieves memory clusters from the database with counts and associated memory IDs, ordered by creation date and importance score.
    async getMemoryClusters(limit = 20) {
      try {
        const clusters = await this.db
          .select({
            id: schema.memoryClusters.id,
            name: schema.memoryClusters.name,
            clusterType: schema.memoryClusters.clusterType,
            description: schema.memoryClusters.description,
            keywords: schema.memoryClusters.keywords,
            importanceScore: schema.memoryClusters.importanceScore,
            activationCount: schema.memoryClusters.activationCount,
            lastActivated: schema.memoryClusters.lastActivated,
            createdAt: schema.memoryClusters.createdAt,
            memoryCount: sql`COALESCE(count(${schema.memoryClusterMembers.memoryId}) FILTER (WHERE ${schema.memoryClusterMembers.memoryId} IS NOT NULL), 0)`.as('memory_count'),
            memoryIds: sql`COALESCE(array_agg(${schema.memoryClusterMembers.memoryId}) FILTER (WHERE ${schema.memoryClusterMembers.memoryId} IS NOT NULL), ARRAY[]::uuid[])`.as('memory_ids')
          })
          .from(schema.memoryClusters)
          .leftJoin(
            schema.memoryClusterMembers,
            eq(schema.memoryClusters.id, schema.memoryClusterMembers.clusterId)
          )
          .groupBy(schema.memoryClusters.id)
          .orderBy(
            desc(schema.memoryClusters.createdAt),
            desc(schema.memoryClusters.importanceScore)
          )
          .limit(limit);
    
        return clusters;
      } catch (error) {
        console.error('Error getting memory clusters:', error);
        throw error;
      }
    }
  • mcp.js:121-132 (registration)
    MCP tool registration in the ListToolsRequestSchema handler that defines the get_memory_clusters tool with its name, description, and input schema.
    name: "get_memory_clusters",
    description: "Retrieve memory clusters ordered by importance/activity",
    inputSchema: {
      type: "object",
      properties: {
        limit: {
          type: "integer",
          description: "Maximum number of clusters to return",
          default: 20
        }
      }
    }
  • mcp.js:565-567 (handler)
    The tool routing handler in CallToolRequestSchema that maps the get_memory_clusters tool to the MemoryManager.getMemoryClusters method.
    case "get_memory_clusters":
      const clusters = await memoryManager.getMemoryClusters(args.limit || 20);
      return { content: [{ type: "text", text: JSON.stringify(clusters, null, 2) }] };
  • Schema definition for the get_memory_clusters tool in the memory-tools module, defining the input structure with an optional limit parameter.
      name: "get_memory_clusters",
      description: "Retrieve memory clusters ordered by importance/activity",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "integer",
            description: "Maximum number of clusters to return",
            default: 20
          }
        }
      }
    },
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. It mentions ordering by 'importance/activity', which adds some behavioral context, but fails to disclose critical details like whether this is a read-only operation, if it requires authentication, rate limits, pagination behavior, or what 'importance/activity' means operationally. For a retrieval tool with zero annotation coverage, this is insufficient.

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 ('retrieve memory clusters') and adds qualifying details ('ordered by importance/activity') without waste. Every word earns its place, making it highly concise and well-structured.

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 complexity implied by sibling tools and the lack of annotations and output schema, the description is incomplete. It doesn't explain what a 'memory cluster' is, how 'importance/activity' is determined, what the return format looks like, or any error conditions. For a tool in a rich ecosystem with no structured support, more context is needed.

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 'limit' fully documented in the schema. The description adds no additional parameter information beyond what the schema provides, such as typical values for 'limit' or how it interacts with ordering. This meets the baseline of 3 when the schema does the heavy lifting.

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 ('retrieve') and resource ('memory clusters'), and specifies ordering ('by importance/activity'), which helps distinguish it from siblings like 'get_memory' or 'get_working_memories'. However, it doesn't explicitly differentiate from similar retrieval tools like 'find_similar_clusters' or 'get_cluster_insights', keeping it from 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 many sibling tools like 'find_similar_clusters', 'get_cluster_insights', and 'search_memories_advanced', there's no indication of context, prerequisites, or exclusions, leaving usage ambiguous.

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/randyandrade/agi-mcp-server'

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