Skip to main content
Glama
QuixiAI

AGI MCP Server

by QuixiAI

find_similar_clusters

Identify clusters with similar characteristics to a specified cluster using similarity thresholds to support memory continuity in AI 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

  • Core handler function that executes the tool logic: queries the database for memory clusters similar to the given clusterId using vector embedding cosine similarity (pgvector <=> operator).
    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 [];
      }
  • mcp.js:387-404 (registration)
    Registration of the tool in the MCP server's tools array, defining name, description, and input schema.
    {
      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 (handler)
    MCP server request handler that dispatches to memoryManager.findSimilarClusters and returns JSON-formatted response.
    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) }] };

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/QuixiAI/agi-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server