Skip to main content
Glama

search_memento_relationships_by_context

Search memento relationships using structured context filters like scope, conditions, evidence, and components to find relevant knowledge connections.

Instructions

Search memento relationships by their structured context fields (scope, conditions, evidence, components)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeNoFilter by scope (partial, full, or conditional implementation)
conditionsNoFilter by conditions (e.g., ['production', 'Redis enabled']). Matches any.
evidenceNoFilter by specific evidence types (e.g., ['integration tests', 'unit tests']). Matches any.
componentsNoFilter by components mentioned (e.g., ['auth', 'Redis']). Matches any.
has_evidenceNoFilter by presence/absence of evidence (verified by tests, etc.)
temporalNoFilter by temporal information (e.g., 'v2.1.0', 'since 2024')
limitNoMaximum number of results (default: 20)

Implementation Reference

  • Handler implementation for search_memento_relationships_by_context. It takes database arguments and formats results into TextContent.
    async def handle_search_memento_relationships_by_context(
        memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any]
    ) -> CallToolResult:
        """Handle search_relationships_by_context tool call.
    
        Args:
            memory_db: Database instance for memory operations
            arguments: Tool arguments from MCP call containing:
                - scope: Filter by scope (partial/full/conditional, optional)
                - conditions: Filter by conditions (optional)
                - has_evidence: Filter by presence/absence of evidence (optional)
                - evidence: Filter by specific evidence types (optional)
                - components: Filter by components mentioned (optional)
                - temporal: Filter by temporal information (optional)
                - limit: Maximum results (default: 20)
    
        Returns:
            CallToolResult with formatted relationship results or error message
        """
        # Check if database supports search_relationships_by_context method
        if not hasattr(memory_db, "search_relationships_by_context"):
            return CallToolResult(
                content=[
                    TextContent(
                        type="text",
                        text="Context-based relationship search is not supported by this backend",
                    )
                ],
                isError=True,
            )
    
        relationships = await memory_db.search_relationships_by_context(
            scope=arguments.get("scope"),
            conditions=arguments.get("conditions"),
            has_evidence=arguments.get("has_evidence"),
            evidence=arguments.get("evidence"),
            components=arguments.get("components"),
            temporal=arguments.get("temporal"),
            limit=arguments.get("limit", 20),
        )
    
        if not relationships:
            return CallToolResult(
                content=[
                    TextContent(
                        type="text",
                        text="No relationships found matching the specified context criteria",
                    )
                ]
            )
    
        # Format results
        result_text = (
            f"**Found {len(relationships)} relationships matching context criteria**\n\n"
        )
    
        # Show applied filters
        filters_applied = []
        if arguments.get("scope"):
            filters_applied.append(f"Scope: {arguments['scope']}")
        if arguments.get("conditions"):
            filters_applied.append(f"Conditions: {', '.join(arguments['conditions'])}")
        if arguments.get("has_evidence") is not None:
            filters_applied.append(f"Has Evidence: {arguments['has_evidence']}")
        if arguments.get("evidence"):
            filters_applied.append(f"Evidence: {', '.join(arguments['evidence'])}")
        if arguments.get("components"):
            filters_applied.append(f"Components: {', '.join(arguments['components'])}")
        if arguments.get("temporal"):
            filters_applied.append(f"Temporal: {arguments['temporal']}")
    
        if filters_applied:
            result_text += "**Filters Applied:**\n"
            for f in filters_applied:
                result_text += f"- {f}\n"
            result_text += "\n"
    
        # List relationships
        for i, rel in enumerate(relationships, 1):
            result_text += f"{i}. **{rel.type.value}**\n"
            result_text += f"   - ID: {rel.id}\n"
            result_text += f"   - From: {rel.from_memory_id}\n"
            result_text += f"   - To: {rel.to_memory_id}\n"
            result_text += f"   - Strength: {rel.properties.strength:.2f}\n"
            if rel.properties.context:
                result_text += f"   - Context: {rel.properties.context}\n"
            result_text += "\n"
    
        return CallToolResult(content=[TextContent(type="text", text=result_text)])

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