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")),
    ]);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'create' implying a write operation, but doesn't mention permissions needed, whether it's idempotent, rate limits, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

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 with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly.

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 mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what a 'memory cluster' is in this context, what happens after creation, or how it interacts with other tools. More context is needed given the complexity implied by sibling tools.

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 fully documents all parameters. The description adds no additional meaning beyond the schema, such as explaining cluster_type choices or keyword usage. Baseline 3 is appropriate when schema does the heavy lifting.

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 understandable. However, it doesn't differentiate from sibling tools like 'create_memory' or 'create_working_memory' that also create memory-related entities, missing explicit distinction.

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 like 'create_memory' or 'create_working_memory', nor does it mention prerequisites or context for creating a cluster. It lacks explicit when-to-use or when-not-to-use instructions.

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