Skip to main content
Glama
sgx-labs

Stateless Agent Memory Engine (SAME)

search_across_vaults

Search across multiple registered vaults simultaneously to find information from different projects. Use this tool to get a cross-project view by querying all your knowledge bases at once.

Instructions

Search across multiple registered vaults at once. Use this instead of search_notes when you need context from other projects or want a cross-project view. Vaults must be registered first via the CLI (same vault add <name> <path>).

Args: query: Natural language search query top_k: Number of results (default 10, max 100) vaults: Comma-separated vault aliases to search. Omit to search all registered vaults. Unknown aliases are silently skipped.

Returns ranked results with titles, paths, snippets, and source vault name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesNatural language search query
top_kYesNumber of results (default 10, max 100)
vaultsNoComma-separated vault aliases (default: all)

Implementation Reference

  • The `same_search` function is the handler that executes the tool logic for searching within the SAME vault. Note that in this codebase, the tool is referred to as 'same search' and implemented by invoking a CLI binary.
    def same_search(vault_dir: str, query: str, top_k: int = SEARCH_TOP_K) -> list[str]:
        """
        Run `same search` and return the top-k result texts.
        Returns a list of result strings.
        """
        try:
            result = subprocess.run(
                [SAME_BIN, "search", "--json", "--top-k", str(top_k), query],
                cwd=vault_dir,
                capture_output=True,
                text=True,
                timeout=QUESTION_TIMEOUT,
            )
        except subprocess.TimeoutExpired:
            log(f"    TIMEOUT: same search for '{query[:50]}...'")
            return []
    
        if result.returncode != 0:
            return []
    
        # Parse JSON output
        try:
            data = json.loads(result.stdout)
        except json.JSONDecodeError:
            # Fallback: return raw stdout lines
            return [line.strip() for line in result.stdout.strip().split("\n") if line.strip()]
    
        # Extract text from results — adapt to SAME's JSON format
        texts = []
        if isinstance(data, list):
            for item in data:
                if isinstance(item, dict):
                    # SAME uses "snippet" for retrieved text
                    text = item.get("snippet") or item.get("content") or item.get("text") or item.get("body") or ""
                    if text:
                        texts.append(text)
                elif isinstance(item, str):
                    texts.append(item)
        elif isinstance(data, dict):
            # Might be wrapped in a results key
            results = data.get("results") or data.get("matches") or data.get("notes") or []
            for item in results:
                if isinstance(item, dict):
                    text = item.get("snippet") or item.get("content") or item.get("text") or item.get("body") or ""
                    if text:
                        texts.append(text)
                elif isinstance(item, str):
                    texts.append(item)
    
        return texts[:top_k]

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/sgx-labs/statelessagent'

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