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)])
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden of behavioral disclosure, but offers none. Does not confirm read-only safety despite 'search' implying it, describe return format/pagination, explain result sorting, or mention any limits beyond the parameter constraint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence efficiently front-loaded with action and resource. Lists key filter fields concisely. No wasted words, though brevity may be excessive given the lack of annotations and output schema—slightly too terse for the complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Incomplete for a 7-parameter search tool with no annotations and no output schema. Description omits what distinguishes a 'relationship' from a 'memento', what fields are returned, result ordering, and how results relate to the 'temporal' filter. Lacks critical context for confident invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the schema already documents all parameter semantics (e.g., 'Filter by scope', 'Matches any'). Description lists the fields parenthetically but adds no additional meaning, examples, or syntax guidance beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear verb (search) and resource (memento relationships) with specific enumeration of filterable fields (scope, conditions, evidence, components). Distinguishes from sibling 'search_mementos' by targeting relationships rather than mementos themselves, though could explicitly clarify the distinction from 'contextual_memento_search'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides no guidance on when to use this tool versus siblings like 'search_mementos', 'contextual_memento_search', or 'get_related_mementos'. Does not mention that all parameters are optional or suggest combinations for common queries.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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