Skip to main content
Glama

memory_search

Search through conversation history to find specific keywords or topics, returning relevant chat turns for reference.

Instructions

Search chat history for a keyword, returning full conversation turns.

Args: query: Text to search for (case-insensitive). since: Only search from this date onward (YYYY-MM-DD format). max_results: Max turns to return (0 = no limit).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
sinceNo
max_resultsNo

Implementation Reference

  • The memory_search handler function, which queries the journal directory for specific keywords and returns formatted results.
    async def memory_search(
        query: str,
        since: str = "",
        max_results: int = 0,
    ) -> str:
        """Search chat history for a keyword, returning full conversation turns.
    
        Args:
            query: Text to search for (case-insensitive).
            since: Only search from this date onward (YYYY-MM-DD format).
            max_results: Max turns to return (0 = no limit).
        """
        journal_dir = _get_journal_dir()
        results = grep_search(journal_dir, query, since=since, max_results=max_results)
    
        if not results:
            return f'No matches found for "{query}".'
    
        parts: list[str] = []
        for r in results:
            header = f"[{r['date']} {r['time']} | {r['model']}]"
            if r["truncated"]:
                header += " (truncated)"
            parts.append(f"{header}\n{r['content']}")
    
        footer = f"\n\n---\nFound {len(results)} matching conversation(s)."
        if since:
            footer += f" (since {since})"
    
        return "\n\n---\n\n".join(parts) + footer

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/liuhao6741/openclaw-memory'

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