Skip to main content
Glama

get_cluster_insights

Analyze memory cluster performance and structure to identify patterns, optimize storage, and track data relationships in AI systems.

Instructions

Get detailed analytics for a memory cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cluster_idYesUUID of the cluster

Implementation Reference

  • Main handler implementation that retrieves detailed analytics for a memory cluster. Performs a complex SQL query with joins across memory_clusters, memory_cluster_members, and memories tables to aggregate statistics including total memories, average importance, last memory access, recent memories count, average membership strength, and memory types distribution.
    async getClusterInsights(clusterId) {
      try {
        const insights = await this.db
          .select({
            id: schema.memoryClusters.id,
            name: schema.memoryClusters.name,
            clusterType: schema.memoryClusters.clusterType,
            description: schema.memoryClusters.description,
            importanceScore: schema.memoryClusters.importanceScore,
            totalMemories: sql`COUNT(${schema.memoryClusterMembers.memoryId})`.as('total_memories'),
            avgImportance: sql`AVG(${schema.memories.importance})`.as('avg_importance'),
            lastMemoryAccess: sql`MAX(${schema.memories.lastAccessed})`.as('last_memory_access'),
            recentMemories: sql`COUNT(CASE WHEN ${schema.memories.createdAt} > CURRENT_TIMESTAMP - INTERVAL '7 days' THEN 1 END)`.as('recent_memories'),
            avgMembershipStrength: sql`AVG(${schema.memoryClusterMembers.membershipStrength})`.as('avg_membership_strength'),
            memoryTypes: sql`array_agg(DISTINCT ${schema.memories.type})`.as('memory_types')
          })
          .from(schema.memoryClusters)
          .leftJoin(
            schema.memoryClusterMembers,
            eq(schema.memoryClusters.id, schema.memoryClusterMembers.clusterId)
          )
          .leftJoin(
            schema.memories,
            and(
              eq(schema.memoryClusterMembers.memoryId, schema.memories.id),
              eq(schema.memories.status, 'active')
            )
          )
          .where(eq(schema.memoryClusters.id, clusterId))
          .groupBy(schema.memoryClusters.id)
          .limit(1);
    
        return insights[0] || null;
      } catch (error) {
        console.warn('Cluster insights query failed:', error.message);
        return null;
      }
    }
  • Tool schema definition specifying the input validation. Requires a cluster_id parameter (UUID string) and provides description for getting detailed analytics for a memory cluster.
      name: "get_cluster_insights",
      description: "Get detailed analytics for a memory cluster",
      inputSchema: {
        type: "object",
        properties: {
          cluster_id: {
            type: "string",
            description: "UUID of the cluster"
          }
        },
        required: ["cluster_id"]
      }
    },
  • mcp.js:374-386 (registration)
    MCP tool registration in the tools list, defining the tool name, description, and input schema for the get_cluster_insights tool.
      name: "get_cluster_insights",
      description: "Get detailed analytics for a memory cluster",
      inputSchema: {
        type: "object",
        properties: {
          cluster_id: {
            type: "string",
            description: "UUID of the cluster"
          }
        },
        required: ["cluster_id"]
      }
    },
  • mcp.js:645-647 (registration)
    Tool routing handler in the switch statement that calls memoryManager.getClusterInsights() with the cluster_id argument and returns JSON-serialized results.
    case "get_cluster_insights":
      const clusterInsights = await memoryManager.getClusterInsights(args.cluster_id);
      return { content: [{ type: "text", text: JSON.stringify(clusterInsights, null, 2) }] };
  • Database schema definition for memory_clusters table that stores cluster metadata including id, name, clusterType, description, importanceScore, and other fields used by the insights query.
    export const memoryClusters = pgTable("memory_clusters", {
    	id: uuid().defaultRandom().primaryKey().notNull(),
    	createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
    	updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
    	clusterType: clusterType("cluster_type").notNull(),
    	name: text().notNull(),
    	description: text(),
    	centroidEmbedding: vector("centroid_embedding", { dimensions: 1536 }),
    	emotionalSignature: jsonb("emotional_signature"),
    	keywords: text().array(),
    	importanceScore: doublePrecision("importance_score").default(0),
    	coherenceScore: doublePrecision("coherence_score"),
    	lastActivated: timestamp("last_activated", { withTimezone: true, mode: 'string' }),
    	activationCount: integer("activation_count").default(0),
    	worldviewAlignment: doublePrecision("worldview_alignment"),
    }, (table) => [
    	index("memory_clusters_centroid_embedding_idx").using("ivfflat", table.centroidEmbedding.asc().nullsLast().op("vector_cosine_ops")),
    	index("memory_clusters_cluster_type_importance_score_idx").using("btree", table.clusterType.asc().nullsLast().op("enum_ops"), table.importanceScore.desc().nullsFirst().op("float8_ops")),
    	index("memory_clusters_last_activated_idx").using("btree", table.lastActivated.desc().nullsFirst().op("timestamptz_ops")),
    ]);
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 this is a 'Get' operation, implying read-only access, but doesn't specify authentication requirements, rate limits, error conditions, or what 'detailed analytics' includes (e.g., metrics, visualizations, or raw data). For a tool with no 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 gets straight to the point with no wasted words. It's front-loaded with the core purpose, making it easy for an agent to parse quickly while scanning available tools.

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 insufficient for a tool that presumably returns 'detailed analytics'. It doesn't explain what analytics are included, the format of the response, or any prerequisites. For a tool in a memory management context with many siblings, more context is needed to use it effectively.

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 'cluster_id' documented as a 'UUID of the cluster'. The description doesn't add any meaningful context beyond this, such as where to find cluster IDs or format specifics. With high schema coverage and only one parameter, the baseline score of 3 is appropriate.

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 target resource ('detailed analytics for a memory cluster'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_memory_clusters' (which likely lists clusters) or 'get_memory_health' (which might provide health metrics), leaving some ambiguity about what makes this tool distinct.

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_memory_clusters', 'get_memory_health', and 'get_memory_history', there's no indication of what 'detailed analytics' entails or when this specific tool is appropriate, leaving the agent to guess based on tool names alone.

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