Skip to main content
Glama

search_mementos

Search stored memories using precise filters for tags, types, and importance to retrieve specific technical information, acronyms, or known terms.

Instructions

Advanced search with fine-grained filters for precise retrieval of mementos.

USE THIS TOOL FIRST (not recall) when searching for:

  • Acronyms: DCAD, JWT, MCR2, API, etc.

  • Proper nouns: Company names, service names, project names

  • Known tags: When you know the tag from previous memories

  • Technical terms: Exact matches needed

PARAMETERS:

  • tags: Filter by exact tag match (most reliable for acronyms)

  • memory_types: Filter by type (solution, problem, etc.)

  • min_importance: Filter by importance threshold

  • search_tolerance: strict/normal/fuzzy

  • match_mode: any/all for multiple terms

NOTE: Tags are automatically normalized to lowercase for case-insensitive matching.

EXAMPLES:

  • search_mementos(tags=["jwt", "auth"]) - find JWT-related memories

  • search_mementos(tags=["dcad"]) - find DCAD memories by tag

  • search_mementos(query="timeout", memory_types=["solution"]) - timeout solutions

  • search_mementos(tags=["redis"], min_importance=0.7) - important Redis memories

For conceptual/natural language queries, use recall_mementos instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoText to search for in memory content
termsNoMultiple search terms for complex queries (alternative to query)
match_modeNoMatch mode for terms: 'any' returns results matching ANY term (OR), 'all' requires ALL terms (AND)
tagsNoFilter by tags
memory_typesNoFilter by memory types
relationship_filterNoFilter results to only include memories with these relationship types
project_pathNoFilter by project path
min_importanceNoMinimum importance score
limitNoMaximum number of results per page (default: 50)
offsetNoNumber of results to skip for pagination (default: 0)
search_toleranceNoSearch tolerance mode: 'strict' for exact matches, 'normal' for stemming (default), 'fuzzy' for typo tolerance

Implementation Reference

  • Implementation of the handle_search_mementos function which serves as the handler for the search_mementos MCP tool.
    @handle_tool_errors("search memories")
    async def handle_search_mementos(
        memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any]
    ) -> CallToolResult:
        """Handle search_memories tool call.
    
        Args:
            memory_db: Database instance for memory operations
            arguments: Tool arguments from MCP call containing:
                - query: Text search query (optional)
                - terms: Multiple search terms (optional)
                - memory_types: Filter by memory types (optional)
                - tags: Filter by tags (optional)
                - project_path: Filter by project path (optional)
                - min_importance: Minimum importance threshold (optional)
                - limit: Maximum results per page (default: 50)
                - offset: Number of results to skip for pagination (default: 0)
                - search_tolerance: Search mode (strict/normal/fuzzy, default: normal)
                - match_mode: Match mode for terms (any/all, default: any)
                - relationship_filter: Filter by relationship types (optional)
    
        Returns:
            CallToolResult with formatted search results or error message
        """
        # Validate input arguments
        validate_search_input(arguments)
    
        # Build search query
        search_query: SearchQuery = SearchQuery(
            query=arguments.get("query"),
            terms=arguments.get("terms", []),
            memory_types=[MemoryType(t) for t in arguments.get("memory_types", [])],
            tags=arguments.get("tags", []),
            project_path=arguments.get("project_path"),
            min_importance=arguments.get("min_importance"),
            limit=arguments.get("limit", 50),
            offset=arguments.get("offset", 0),
            search_tolerance=arguments.get("search_tolerance", "normal"),
            match_mode=arguments.get("match_mode", "any"),
            relationship_filter=arguments.get("relationship_filter"),
        )
    
        paginated_result = await memory_db.search_memories(search_query)
    
        if not paginated_result.results:
            return CallToolResult(
                content=[
                    TextContent(
                        type="text", text="No memories found matching the search criteria."
                    )
                ]
            )
    
        # Format results
        results_text: str = f"Found {len(paginated_result.results)} memories (total: {paginated_result.total_count}):\n\n"
        for i, memory in enumerate(paginated_result.results, 1):
            results_text += f"**{i}. {memory.title}** (ID: {memory.id})\n"
            results_text += f"Type: {memory.type.value} | Importance: {memory.importance}\n"
            results_text += f"Tags: {', '.join(memory.tags) if memory.tags else 'None'}\n"
            if memory.summary:
                results_text += f"Summary: {memory.summary}\n"
            results_text += "\n"
    
        return CallToolResult(content=[TextContent(type="text", text=results_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