Skip to main content
Glama

get_memory_clusters

Retrieve and prioritize memory clusters by importance or activity for AI systems, enabling continuity of consciousness across conversations. Specify a limit to control the number of clusters returned.

Instructions

Retrieve memory clusters ordered by importance/activity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of clusters to return

Implementation Reference

  • Core handler function that retrieves memory clusters from the database, including aggregated memory counts and IDs, ordered by recency and importance score.
    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; } }
  • Input schema definition for the get_memory_clusters tool used in MCP tool listing.
    { 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 (registration)
    Tool dispatch/execution handler in the MCP CallToolRequestSchema that invokes the memory manager's getMemoryClusters method 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) }] };
  • Additional schema definition for get_memory_clusters in the memoryTools export (possibly for internal use or duplication).
    { 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 } } }

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