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
| Name | Required | Description | Default |
|---|---|---|---|
| from_memory_id | Yes | UUID of the source memory | |
| to_memory_id | Yes | UUID of the target memory | |
| relationship_type | Yes | Type of relationship | |
| properties | No | Additional properties for the relationship |
Implementation Reference
- src/memory-manager.js:609-626 (handler)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; } } - src/tools/memory-tools.js:195-220 (schema)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) }] };