Skip to main content
Glama
QuixiAI

AGI MCP Server

by QuixiAI

find_related_memories

Discover connected memories by traversing relationship graphs from a starting memory, with configurable depth and strength thresholds.

Instructions

Find memories related through graph traversal

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesUUID of the starting memory
max_depthNoMaximum depth to traverse
min_strengthNoMinimum relationship strength

Implementation Reference

  • Core handler function implementing graph traversal to find related memories using recursive SQL CTE, filtering by maximum depth and minimum relationship strength.
    async findRelatedMemories(memoryId, maxDepth = 2, minStrength = 0.3) {
      try {
        // Use recursive CTE to find related memories up to maxDepth
        const results = await this.db.execute(sql`
          WITH RECURSIVE memory_graph AS (
            -- Base case: direct relationships
            SELECT 
              mr.to_memory_id as memory_id,
              mr.relationship_type,
              mr.strength,
              1 as depth,
              ARRAY[mr.from_memory_id] as path
            FROM memory_relationships mr
            WHERE mr.from_memory_id = ${memoryId} AND mr.strength >= ${minStrength}
            
            UNION ALL
            
            -- Recursive case: follow relationships
            SELECT 
              mr.to_memory_id as memory_id,
              mr.relationship_type,
              mr.strength * mg.strength as strength,
              mg.depth + 1,
              mg.path || mr.from_memory_id
            FROM memory_relationships mr
            JOIN memory_graph mg ON mr.from_memory_id = mg.memory_id
            WHERE mg.depth < ${maxDepth}
              AND mr.strength >= ${minStrength}
              AND NOT (mr.to_memory_id = ANY(mg.path))
          )
          SELECT 
            mg.*,
            m.content,
            m.type,
            m.importance
          FROM memory_graph mg
          JOIN memories m ON mg.memory_id = m.id
          WHERE m.status = 'active'
          ORDER BY mg.strength DESC, mg.depth ASC
        `);
        
        return results.rows || [];
      } catch (error) {
        console.warn('Related memories query failed:', error.message);
        return [];
      }
    }
  • mcp.js:272-295 (registration)
    Registration of the 'find_related_memories' tool in the MCP server's ListTools response, including full input schema definition.
    {
      name: "find_related_memories",
      description: "Find memories related through graph traversal",
      inputSchema: {
        type: "object",
        properties: {
          memory_id: {
            type: "string",
            description: "UUID of the starting memory"
          },
          max_depth: {
            type: "integer",
            description: "Maximum depth to traverse",
            default: 2
          },
          min_strength: {
            type: "number",
            description: "Minimum relationship strength",
            default: 0.3
          }
        },
        required: ["memory_id"]
      }
    },
  • mcp.js:618-624 (handler)
    Dispatch handler in MCP CallToolRequestSchema that parses arguments and calls the core findRelatedMemories implementation on MemoryManager.
    case "find_related_memories":
      const relatedMemories = await memoryManager.findRelatedMemories(
        args.memory_id,
        args.max_depth || 2,
        args.min_strength || 0.3
      );
      return { content: [{ type: "text", text: JSON.stringify(relatedMemories, null, 2) }] };
  • Standalone schema definition for the find_related_memories tool (potentially imported or duplicated).
    name: "find_related_memories",
    description: "Find memories related through graph traversal",
    inputSchema: {
      type: "object",
      properties: {
        memory_id: {
          type: "string",
          description: "UUID of the starting memory"
        },
        max_depth: {
          type: "integer",
          description: "Maximum depth to traverse",
          default: 2
        },
        min_strength: {
          type: "number",
          description: "Minimum relationship strength",
          default: 0.3
        }
      },
      required: ["memory_id"]
    }
Behavior2/5

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

With no annotations, the description carries full burden but provides minimal behavioral insight. It mentions 'graph traversal' but doesn't disclose key traits: whether it's read-only or mutative, performance implications (e.g., depth limits), error handling, or output format. For a tool with graph operations and no annotations, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words. It's front-loaded and directly states the tool's function. Every part earns its place, making it highly concise and well-structured for its 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 of graph traversal, no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like safety, performance, or return values, leaving the agent with insufficient context to use the tool effectively. The high schema coverage helps but doesn't compensate for missing output 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?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description adds no additional meaning beyond the schema's details for 'memory_id', 'max_depth', or 'min_strength'. It doesn't explain how these parameters interact (e.g., how strength affects traversal) or provide usage examples, meeting the baseline for high schema 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 finds memories through graph traversal, which gives a general purpose but lacks specificity. It doesn't clarify what 'related' means (e.g., by relationship type, similarity, or temporal proximity) or distinguish it from sibling tools like 'find_similar_clusters' or 'search_memories_similarity'. The verb 'find' is generic, and 'graph traversal' is technical but vague without context.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing memory ID), exclusions, or compare to siblings like 'get_memory_relationships' or 'search_memories_advanced'. The description implies a graph-based approach but offers no practical usage context.

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

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