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

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Find') but doesn't describe what 'similar' means, how results are returned, or any operational traits like performance, limitations, or side effects. For a tool with no annotations, this is a significant gap in transparency.

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 front-loaded and easy to parse. However, it's overly concise to the point of under-specification, lacking necessary details for a tool with no annotations. It earns a 4 for brevity but loses a point for missing critical context.

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 of similarity search, no annotations, no output schema, and multiple sibling tools, the description is incomplete. It fails to explain what 'similar' entails, how results are structured, or when to choose this over alternatives. For a tool in this context, it should provide more guidance and behavioral details.

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?

The input schema has 100% description coverage, with clear documentation for 'cluster_id' and 'threshold'. The description adds no additional meaning beyond the schema, such as explaining similarity metrics or usage examples. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 'Find clusters similar to a given cluster' clearly states the verb ('Find') and resource ('clusters'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'search_memories_similarity' or 'find_related_memories', leaving ambiguity about scope or method. It's not tautological but remains vague on what makes this tool distinct.

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', there's no indication of context, prerequisites, or exclusions. This leaves the agent guessing about appropriate use cases without any implied or explicit direction.

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