get_cluster_insights
Retrieve detailed analytics for a memory cluster using its UUID to analyze performance and usage within the AGI MCP Server environment.
Instructions
Get detailed analytics for a memory cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster_id | Yes | UUID of the cluster |
Implementation Reference
- src/memory-manager.js:868-905 (handler)Core handler function that executes the database query to retrieve comprehensive insights for a specific memory cluster, including stats like total memories, average importance, recent activity, 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; } }
- src/tools/memory-tools.js:347-360 (schema)Tool schema definition specifying the input schema requiring 'cluster_id' parameter.{ 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)MCP tool dispatcher/registration in the CallToolRequestSchema handler switch statement, which calls the memoryManager handler with cluster_id argument.case "get_cluster_insights": const clusterInsights = await memoryManager.getClusterInsights(args.cluster_id); return { content: [{ type: "text", text: JSON.stringify(clusterInsights, null, 2) }] };
- mcp.js:373-386 (schema)Tool schema as registered in the MCP ListToolsRequestSchema response.{ 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"] } },