Skip to main content
Glama

create_memento_relationship

Link two mementos with typed relationships like SOLVES, CAUSES, or ADDRESSES to map connections between problems, solutions, causes, and effects in a knowledge base.

Instructions

Link two mementos with a typed relationship.

Common types: SOLVES (solution→problem), CAUSES (cause→effect), ADDRESSES (fix→error), REQUIRES (dependent→dependency), RELATED_TO (general)

EXAMPLES:

  • create_memento_relationship(from_memory_id="sol-1", to_memory_id="prob-1", relationship_type="SOLVES")

  • create_memento_relationship(from_memory_id="err-1", to_memory_id="fix-1", relationship_type="CAUSES", context="Config error caused timeout")

Optional: strength (0-1), confidence (0-1), context (description)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_memory_idYesID of the source memory
to_memory_idYesID of the target memory
relationship_typeYesType of relationship to create
strengthNoStrength of the relationship (0.0-1.0)
confidenceNoConfidence in the relationship (0.0-1.0)
contextNoContext or description of the relationship

Implementation Reference

  • The handler function `handle_create_memento_relationship` that executes the logic for the "create_memento_relationship" MCP tool. It validates inputs, extracts context, and calls the database to create the relationship.
    async def handle_create_memento_relationship(
        memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any]
    ) -> CallToolResult:
        """Handle create_relationship tool call.
    
        Args:
            memory_db: Database instance for memory operations
            arguments: Tool arguments from MCP call containing:
                - from_memory_id: ID of source memory
                - to_memory_id: ID of target memory
                - relationship_type: Type of relationship (SOLVES, CAUSES, etc.)
                - strength: Optional relationship strength (0.0-1.0, default: 0.5)
                - confidence: Optional confidence score (0.0-1.0, default: 0.8)
                - context: Optional natural language description
    
        Returns:
            CallToolResult with relationship ID on success or error message on failure
        """
        # Validate input arguments
        validate_relationship_input(arguments)
    
        # Get user-provided context (natural language)
        user_context = arguments.get("context")
    
        # Auto-extract structure if context provided
        structured_context = None
        if user_context:
            from ..utils.context_extractor import extract_context_structure
    
            structure = extract_context_structure(user_context)
            structured_context = json.dumps(structure)  # Serialize to JSON string
    
        properties = RelationshipProperties(
            strength=arguments.get("strength", 0.5),
            confidence=arguments.get("confidence", 0.8),
            context=structured_context,  # Store JSON string
        )
    
        relationship_id = await memory_db.create_relationship(
            from_memory_id=arguments["from_memory_id"],
            to_memory_id=arguments["to_memory_id"],
            relationship_type=RelationshipType(arguments["relationship_type"]),
            properties=properties,
        )
    
        return CallToolResult(
            content=[
                TextContent(
                    type="text",
                    text=f"Relationship created successfully: {relationship_id}",
                )
            ]
        )

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/annibale-x/mcp-memento'

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