Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameYesName of the cluster
cluster_typeYesType of cluster
descriptionNoDescription of the cluster
keywordsNoKeywords associated with this cluster

Implementation Reference

  • 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;
      }
    }
  • 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"]
      }
  • 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")),
    ]);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. 'Create' implies a write/mutation operation, but the description doesn't address important behavioral aspects: whether this requires specific permissions, what happens on success/failure, whether clusters are immediately usable, or any side effects. For a creation tool with zero annotation coverage, this represents a significant transparency gap.

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 maximally concise - a single clear sentence that states the core purpose without any unnecessary words. It's front-loaded with the essential information and contains zero waste or redundancy.

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?

For a creation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what a memory cluster is, how it differs from regular memories, what happens after creation, or what the tool returns. Given the complexity implied by the parameter schema (including cluster_type enum with 6 options) and the absence of structured behavioral information, 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%, so the schema already documents all parameters thoroughly. The description adds no parameter information beyond what's in the schema - it doesn't explain the significance of cluster_type choices, how names are validated, or how keywords affect cluster behavior. With complete schema coverage, 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 ('create') and resource ('new memory cluster'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'create_memory' or 'create_memory_relationship', which would require more specific context about what distinguishes a memory cluster from other memory-related entities.

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 multiple sibling tools for creating memory-related entities (create_memory, create_memory_relationship, create_working_memory), there's no indication of when a memory cluster is appropriate versus other memory creation tools, nor any mention of prerequisites or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.