Skip to main content
Glama

create_memory_relationship

Establish connections between stored memories to build associative networks for AI systems, enabling relationship-based memory organization and retrieval.

Instructions

Create a relationship between two memories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_memory_idYesUUID of the source memory
to_memory_idYesUUID of the target memory
relationship_typeYesType of relationship
propertiesNoAdditional properties for the relationship

Implementation Reference

  • The core implementation of createMemoryRelationship method that inserts a relationship record into the memory_relationships table with from_memory_id, to_memory_id, relationship_type, and optional properties fields.
    async createMemoryRelationship(fromMemoryId, toMemoryId, relationshipType, properties = {}) {
      try {
        const [relationship] = await this.db
          .insert(schema.memoryRelationships)
          .values({
            fromMemoryId,
            toMemoryId,
            relationshipType,
            properties
          })
          .returning();
        
        return relationship;
      } catch (error) {
        console.warn('Memory relationships table not available:', error.message);
        return null;
      }
    }
  • Input schema definition for create_memory_relationship tool, specifying required parameters (from_memory_id, to_memory_id, relationship_type) and optional properties, with relationship_type enum including causal, temporal, semantic, emotional, strategic, and consolidation.
    name: "create_memory_relationship",
    description: "Create a relationship between two memories",
    inputSchema: {
      type: "object",
      properties: {
        from_memory_id: {
          type: "string",
          description: "UUID of the source memory"
        },
        to_memory_id: {
          type: "string", 
          description: "UUID of the target memory"
        },
        relationship_type: {
          type: "string",
          enum: ["causal", "temporal", "semantic", "emotional", "strategic", "consolidation"],
          description: "Type of relationship"
        },
        properties: {
          type: "object",
          description: "Additional properties for the relationship",
          default: {}
        }
      },
      required: ["from_memory_id", "to_memory_id", "relationship_type"]
    }
  • mcp.js:221-247 (registration)
    MCP server tool registration for create_memory_relationship in the ListToolsRequestSchema handler, exposing the tool with its description and input schema.
      name: "create_memory_relationship",
      description: "Create a relationship between two memories",
      inputSchema: {
        type: "object",
        properties: {
          from_memory_id: {
            type: "string",
            description: "UUID of the source memory"
          },
          to_memory_id: {
            type: "string", 
            description: "UUID of the target memory"
          },
          relationship_type: {
            type: "string",
            enum: ["causal", "temporal", "semantic", "emotional", "strategic", "consolidation"],
            description: "Type of relationship"
          },
          properties: {
            type: "object",
            description: "Additional properties for the relationship",
            default: {}
          }
        },
        required: ["from_memory_id", "to_memory_id", "relationship_type"]
      }
    },
  • mcp.js:601-608 (registration)
    Handler dispatch in CallToolRequestSchema that routes create_memory_relationship calls to memoryManager.createMemoryRelationship method, passing arguments and returning JSON response.
    case "create_memory_relationship":
      const relationship = await memoryManager.createMemoryRelationship(
        args.from_memory_id,
        args.to_memory_id,
        args.relationship_type,
        args.properties || {}
      );
      return { content: [{ type: "text", text: JSON.stringify(relationship, 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/randyandrade/agi-mcp-server'

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