Skip to main content
Glama

memory_search

Search through stored memory files by substring to retrieve specific facts without loading entire memory. Quickly recall relevant information from agent memory.

Instructions

Search memory files for a substring. Use this to recall specific facts without loading everything.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The searchMemory function that executes the tool logic: reads all .md files from the memory directory, searches for the query substring case-insensitively, and returns matching lines as markdown snippets.
    async function searchMemory(query: string): Promise<string> {
      if (!existsSync(MEMORY_DIR)) return '(memory directory does not exist)';
      const q = query.toLowerCase();
      const files = (await readdir(MEMORY_DIR)).filter((f) => f.endsWith('.md'));
      const hits: string[] = [];
      for (const file of files) {
        const content = await readFile(join(MEMORY_DIR, file), 'utf-8');
        if (content.toLowerCase().includes(q)) {
          const snippet = content.split('\n').filter((l) => l.toLowerCase().includes(q)).slice(0, 3).join('\n');
          hits.push(`## ${file}\n${snippet}`);
        }
      }
      return hits.join('\n\n') || `(no matches for "${query}")`;
    }
  • The CallTool request handler that dispatches 'memory_search' to the searchMemory function with the query argument.
    if (name === 'memory_search') {
      const query = String(args?.query ?? '');
      if (!query.trim()) throw new Error('query is required');
      return { content: [{ type: 'text', text: await searchMemory(query) }] };
    }
  • Tool registration with inputSchema definition for memory_search: requires a single string property 'query'.
    {
      name: 'memory_search',
      description: 'Search memory files for a substring. Use this to recall specific facts without loading everything.',
      inputSchema: {
        type: 'object',
        properties: { query: { type: 'string' } },
        required: ['query'],
      },
    },
  • src/index.ts:67-100 (registration)
    ListTools handler that registers memory_search among the available tools (name, description, inputSchema).
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'memory_read',
          description: 'Read the agent memory index (MEMORY.md) and optionally specific topic files. Call with no arguments to load only the lightweight index (cheap). Pass `topics` only when you need the full content of a specific topic file.',
          inputSchema: {
            type: 'object',
            properties: {
              topics: { type: 'array', items: { type: 'string' }, description: 'Optional topic file names to load in full (e.g., ["preferences", "projects"]). Omit to return the index only.' },
            },
          },
        },
        {
          name: 'memory_append_session',
          description: 'Append a session summary to the sessions directory. The daemon will later extract durable memories from it. Call this at the end of meaningful exchanges. Keep summaries focused on durable findings and decisions (target 300-800 tokens), not play-by-play — longer summaries cost more during consolidation.',
          inputSchema: {
            type: 'object',
            properties: {
              content: { type: 'string', description: 'Markdown-formatted session summary. Use structured headers and bullets for better extraction; avoid verbose prose.' },
              source: { type: 'string', description: 'Origin tag, e.g., "kiro", "claude-desktop"' },
            },
            required: ['content'],
          },
        },
        {
          name: 'memory_search',
          description: 'Search memory files for a substring. Use this to recall specific facts without loading everything.',
          inputSchema: {
            type: 'object',
            properties: { query: { type: 'string' } },
            required: ['query'],
          },
        },
      ],
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It only mentions substring search, omitting details like case sensitivity, scope, return format, or whether it is a blocking operation.

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?

Two concise, front-loaded sentences with no fluff. Every word adds value.

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

Completeness3/5

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

For a simple tool with one parameter and no output schema, the description covers basic purpose but misses behavioral nuances that would aid correct invocation without annotations.

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 0% schema description coverage, the description should clarify the parameter. 'query' is named and described as a 'substring', which is minimally informative but lacking details on format or constraints.

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 clearly states the action ('search memory files for a substring') and the purpose ('recall specific facts without loading everything'), effectively distinguishing it from sibling tools like memory_read.

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?

The description implies when to use ('to recall specific facts without loading everything') but does not explicitly state when not to use or name alternatives, though sibling names provide context.

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/tverney/mcp-agent-memory'

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