memory_link
Establish typed relationships between memories to build a knowledge graph, enabling structured connections like references, implementations, contradictions, and updates.
Instructions
Create an explicit typed link between two memories.
Args: from_id: Source memory ID to_id: Target memory ID edge_type: Type of relationship. Options: - "references" (default): General reference - "implements": Source implements/realizes target - "supersedes": Source replaces/updates target - "extends": Source builds upon target - "contradicts": Source conflicts with target - "related_to": Generic relationship bidirectional: If True, also create reverse link (default: True)
Returns: Dict with created links and their types
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_id | Yes | ||
| to_id | Yes | ||
| edge_type | No | references | |
| bidirectional | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- memora/server.py:1094-1122 (handler)The tool handler for "memory_link" registered as an MCP tool. It calls the internal _add_link helper.
async def memory_link( from_id: int, to_id: int, edge_type: str = "references", bidirectional: bool = True, ) -> Dict[str, Any]: """Create an explicit typed link between two memories. Args: from_id: Source memory ID to_id: Target memory ID edge_type: Type of relationship. Options: - "references" (default): General reference - "implements": Source implements/realizes target - "supersedes": Source replaces/updates target - "extends": Source builds upon target - "contradicts": Source conflicts with target - "related_to": Generic relationship bidirectional: If True, also create reverse link (default: True) Returns: Dict with created links and their types """ try: result = _add_link(from_id, to_id, edge_type, bidirectional) _schedule_cloud_graph_sync() return result except ValueError as e: return {"error": "invalid_input", "message": str(e)} - memora/server.py:1078-1080 (helper)Helper function that wraps the database call for adding a link.
@_with_connection(writes=True) def _add_link(conn, from_id: int, to_id: int, edge_type: str, bidirectional: bool): return add_link(conn, from_id, to_id, edge_type, bidirectional)