create_memory_cluster
Organize AI memories into thematic groups for better retrieval and continuity, using categories like themes, emotions, or temporal patterns.
Instructions
Create a new memory cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the cluster | |
| cluster_type | Yes | Type of cluster | |
| description | No | Description of the cluster | |
| keywords | No | Keywords associated with this cluster |
Implementation Reference
- src/memory-manager.js:217-238 (handler)The core handler implementation that creates a new memory cluster in the database. Accepts name, clusterType, description, and keywords parameters, creates a default centroid embedding, and inserts the cluster into the memoryClusters table.
async createMemoryCluster(name, clusterType, description, keywords = []) { try { const defaultEmbedding = new Array(1536).fill(0.0); const [cluster] = await this.db .insert(schema.memoryClusters) .values({ name, clusterType, description, keywords, centroidEmbedding: defaultEmbedding, importanceScore: 0.0 }) .returning(); return cluster; } catch (error) { console.error('Error creating memory cluster:', error); throw error; } } - src/tools/memory-tools.js:127-155 (schema)Tool schema definition for create_memory_cluster in the memory tools module. Defines input parameters (name, cluster_type, description, keywords) with cluster_type being an enum of valid cluster types.
{ name: "create_memory_cluster", description: "Create a new memory cluster", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the cluster" }, cluster_type: { type: "string", enum: ["theme", "emotion", "temporal", "person", "pattern", "mixed"], description: "Type of cluster" }, description: { type: "string", description: "Description of the cluster" }, keywords: { type: "array", items: { type: "string" }, description: "Keywords associated with this cluster", default: [] } }, required: ["name", "cluster_type"] } }, - mcp.js:576-583 (handler)MCP handler routing that receives tool calls, extracts arguments (name, cluster_type, description, keywords), calls the memoryManager.createMemoryCluster method, and returns the result as JSON.
case "create_memory_cluster": const newCluster = await memoryManager.createMemoryCluster( args.name, args.cluster_type, args.description, args.keywords || [] ); return { content: [{ type: "text", text: JSON.stringify(newCluster, null, 2) }] }; - mcp.js:153-180 (registration)Tool registration in the MCP server's tools list. Defines the tool name, description, and input schema that is exposed to MCP clients.
{ name: "create_memory_cluster", description: "Create a new memory cluster", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the cluster" }, cluster_type: { type: "string", enum: ["theme", "emotion", "temporal", "person", "pattern", "mixed"], description: "Type of cluster" }, description: { type: "string", description: "Description of the cluster" }, keywords: { type: "array", items: { type: "string" }, description: "Keywords associated with this cluster", default: [] } }, required: ["name", "cluster_type"] } - drizzle/schema.ts:37-56 (schema)Database schema definition for the memoryClusters table including fields for id, clusterType, name, description, centroidEmbedding, keywords, importanceScore, and various indexes for performance optimization.
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")), ]);