Skip to main content
Glama

memory_search

Read-only

Retrieve the most relevant stored facts for a query from a namespace, combining vector and full-text search. Use it to recall prior context, preferences, or past decisions before answering.

Instructions

Retrieve the facts most relevant to a query from a namespace's memory.

Read-only with respect to memory content: it never modifies or deletes stored facts (searching a namespace that does not exist yet returns "No facts found.", though the empty store file is created as a side effect). Returns up to k facts as a bulleted list, deduplicated, most relevant first.

Use it before answering anything that may depend on prior context — preferences, past decisions, earlier sessions. Facts only exist here if something wrote them via memory_add; memory_clear deletes a whole namespace. With the [models] extra installed, the first call in a fresh environment downloads model weights (one-time); the call blocks until done.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNoMaximum number of facts to return (top-k after reranking).
queryYesNatural-language search query; matched against stored facts by hybrid vector + full-text retrieval, then reranked.
namespaceYesIsolation key for one memory store. Each namespace is a separate local SQLite file under LM_DATA_ROOT (default ~/.lean_memory); namespaces never see each other's facts. Use one per agent, project, or user whose memory must stay separate. Created on first access.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

Annotations already declare readOnlyHint=true, but the description adds a crucial caveat: searching a non-existent namespace returns 'No facts found.' yet creates an empty store file as a side effect. It also discloses deduplication, relevance ordering, and the potential one-time model weights download that blocks the call, going well beyond the annotations.

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

Conciseness5/5

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

The description is thoughtfully structured into three short paragraphs: what it does, read-only nature and return format, and usage context with caveats. Every sentence adds value, and it remains readable despite covering several subtle points.

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

Completeness5/5

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

With an output schema present and rich annotations, the description still adds essential context: when to use, how results are ordered and deduplicated, side effects, and interaction with sibling tools. Nothing critical is missing for this read-only search tool.

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?

The schema already covers 100% of parameters with rich descriptions (namespace isolation, query matching, k as top-k after reranking). The tool description adds the return format and deduplication behavior, but this is largely complementary to the schema rather than adding new semantic meaning to the parameters themselves.

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

Purpose5/5

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

The description opens with a specific verb+resource pair: 'Retrieve the facts most relevant to a query from a namespace's memory.' This clearly distinguishes it from sibling tools like memory_add and memory_clear, which write or delete facts.

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

Usage Guidelines4/5

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

It explicitly says to use this tool before answering anything that may depend on prior context, and contrasts it with memory_add and memory_clear to clarify how facts enter and leave the store. It does not list explicit exclusions, but the context is clear enough.

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/Wuesteon/lean-memory'

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