Skip to main content
Glama
QuixiAI

AGI MCP Server

by QuixiAI

get_memory_clusters

Retrieve and organize memory clusters by importance and activity to enable AI systems to access structured memory data for continuity across conversations.

Instructions

Retrieve memory clusters ordered by importance/activity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of clusters to return

Implementation Reference

  • Core handler function in MemoryManager class that queries the database for memory clusters, including aggregated member counts and IDs, ordered by recency and importance.
    async getMemoryClusters(limit = 20) {
      try {
        const clusters = await this.db
          .select({
            id: schema.memoryClusters.id,
            name: schema.memoryClusters.name,
            clusterType: schema.memoryClusters.clusterType,
            description: schema.memoryClusters.description,
            keywords: schema.memoryClusters.keywords,
            importanceScore: schema.memoryClusters.importanceScore,
            activationCount: schema.memoryClusters.activationCount,
            lastActivated: schema.memoryClusters.lastActivated,
            createdAt: schema.memoryClusters.createdAt,
            memoryCount: sql`COALESCE(count(${schema.memoryClusterMembers.memoryId}) FILTER (WHERE ${schema.memoryClusterMembers.memoryId} IS NOT NULL), 0)`.as('memory_count'),
            memoryIds: sql`COALESCE(array_agg(${schema.memoryClusterMembers.memoryId}) FILTER (WHERE ${schema.memoryClusterMembers.memoryId} IS NOT NULL), ARRAY[]::uuid[])`.as('memory_ids')
          })
          .from(schema.memoryClusters)
          .leftJoin(
            schema.memoryClusterMembers,
            eq(schema.memoryClusters.id, schema.memoryClusterMembers.clusterId)
          )
          .groupBy(schema.memoryClusters.id)
          .orderBy(
            desc(schema.memoryClusters.createdAt),
            desc(schema.memoryClusters.importanceScore)
          )
          .limit(limit);
    
        return clusters;
      } catch (error) {
        console.error('Error getting memory clusters:', error);
        throw error;
      }
    }
  • Tool schema definition including name, description, and input schema for the get_memory_clusters tool.
    {
      name: "get_memory_clusters",
      description: "Retrieve memory clusters ordered by importance/activity",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "integer",
            description: "Maximum number of clusters to return",
            default: 20
          }
        }
      }
    },
  • mcp.js:120-133 (registration)
    Tool registration in MCP server's ListToolsRequestHandler, exposing the schema.
    {
      name: "get_memory_clusters",
      description: "Retrieve memory clusters ordered by importance/activity",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "integer",
            description: "Maximum number of clusters to return",
            default: 20
          }
        }
      }
    },
  • mcp.js:565-567 (handler)
    MCP CallToolRequestHandler case that dispatches to MemoryManager.getMemoryClusters and formats the response.
    case "get_memory_clusters":
      const clusters = await memoryManager.getMemoryClusters(args.limit || 20);
      return { content: [{ type: "text", text: JSON.stringify(clusters, 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