Skip to main content
Glama

find_similar_clusters

Identify clusters with similar characteristics to a reference cluster using similarity search in a vector-enhanced database for AI memory systems.

Instructions

Find clusters similar to a given cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cluster_idYesUUID of the reference cluster
thresholdNoMinimum similarity threshold

Implementation Reference

  • Main handler implementation that executes SQL query to find clusters similar to a given cluster using vector cosine similarity (pgvector <=> operator). Takes clusterId and threshold parameters, returns array of similar clusters with similarity scores.
    async findSimilarClusters(clusterId, threshold = 0.7) {
      try {
        const embeddingVector = `[${Array(1536).fill(0).join(',')}]`;
        
        const results = await this.db.execute(sql`
          SELECT 
            mc2.*,
            1 - (mc1.centroid_embedding <=> mc2.centroid_embedding) as similarity
          FROM memory_clusters mc1
          CROSS JOIN memory_clusters mc2
          WHERE mc1.id = ${clusterId}
            AND mc2.id != ${clusterId}
            AND 1 - (mc1.centroid_embedding <=> mc2.centroid_embedding) >= ${threshold}
          ORDER BY similarity DESC
        `);
        
        return results.rows || [];
      } catch (error) {
        console.warn('Similar clusters query failed:', error.message);
        return [];
      }
    }
  • Tool schema definition in the tools registry. Defines input parameters: cluster_id (required string) and threshold (optional number with default 0.7). Describes the tool as finding clusters similar to a given cluster.
      name: "find_similar_clusters",
      description: "Find clusters similar to a given cluster",
      inputSchema: {
        type: "object",
        properties: {
          cluster_id: {
            type: "string",
            description: "UUID of the reference cluster"
          },
          threshold: {
            type: "number",
            description: "Minimum similarity threshold",
            default: 0.7
          }
        },
        required: ["cluster_id"]
      }
    },
  • mcp.js:387-405 (registration)
    Tool registration in the MCP server's tools list. Contains the tool name, description, and input schema definition with cluster_id and threshold parameters.
    {
      name: "find_similar_clusters",
      description: "Find clusters similar to a given cluster",
      inputSchema: {
        type: "object",
        properties: {
          cluster_id: {
            type: "string",
            description: "UUID of the reference cluster"
          },
          threshold: {
            type: "number",
            description: "Minimum similarity threshold",
            default: 0.7
          }
        },
        required: ["cluster_id"]
      }
    },
  • mcp.js:649-654 (registration)
    Switch case handler that routes tool invocations to the memoryManager.findSimilarClusters method, passing cluster_id and threshold (defaulting to 0.7), and returns results as formatted JSON text.
    case "find_similar_clusters":
      const similarClusters = await memoryManager.findSimilarClusters(
        args.cluster_id,
        args.threshold || 0.7
      );
      return { content: [{ type: "text", text: JSON.stringify(similarClusters, null, 2) }] };

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.6/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It only states the action without detailing traits like read/write nature, permissions, rate limits, or output format. This is inadequate for a tool that likely involves data retrieval or analysis.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words, making it easy to parse. However, it lacks front-loaded critical information (e.g., distinguishing from siblings), which slightly reduces its effectiveness despite the brevity.

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?

Given the complexity implied by sibling tools (e.g., memory and cluster management), no annotations, and no output schema, the description is incomplete. It doesn't explain what 'clusters' are, how similarity is measured, or what the output entails, leaving significant gaps for agent understanding.

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%, with clear documentation for both parameters ('cluster_id' as UUID, 'threshold' as number with default 0.7). The description adds no additional meaning beyond the schema, such as explaining what 'similar' means or how the threshold is applied, so it meets the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as 'Find clusters similar to a given cluster', which is clear but vague. It specifies the verb ('Find') and resource ('clusters'), but doesn't distinguish it from sibling tools like 'search_memories_similarity' or 'find_related_memories', leaving ambiguity about what makes this tool unique.

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 siblings like 'search_memories_similarity' and 'find_related_memories', it fails to specify contexts, prerequisites, or exclusions, leaving the agent to guess based on tool names alone.

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