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
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of clusters to return |
Implementation Reference
- src/memory-manager.js:241-274 (handler)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) }] }; - src/tools/memory-tools.js:95-107 (schema)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 } } } },