Skip to main content
Glama

memory_read

Retrieve the agent memory index for a lightweight overview, or load full content of specific topic files for detailed information.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicsNoOptional topic file names to load in full (e.g., ["preferences", "projects"]). Omit to return the index only.

Implementation Reference

  • Handler for the memory_read tool. Reads the memory index (MEMORY.md) and optionally specified topic files, returning their content as text.
    if (name === 'memory_read') {
      const topics = (args?.topics as string[] | undefined) ?? [];
      const index = await readIndex();
      const topicContent = topics.length > 0 ? `\n\n---\n\n${await readTopics(topics)}` : '';
      return { content: [{ type: 'text', text: index + topicContent }] };
    }
  • Helper that reads the MEMORY.md index file from the memory directory.
    async function readIndex(): Promise<string> {
      const indexPath = join(MEMORY_DIR, 'MEMORY.md');
      if (!existsSync(indexPath)) return '(no memories yet)';
      return readFile(indexPath, 'utf-8');
    }
  • Helper that reads one or more topic .md files from the memory directory, sanitizing file names for security.
    async function readTopics(topics: string[]): Promise<string> {
      const parts: string[] = [];
      for (const topic of topics) {
        const safe = topic.replace(/[^a-zA-Z0-9_.-]/g, '');
        if (!safe) continue;
        const path = join(MEMORY_DIR, safe.endsWith('.md') ? safe : `${safe}.md`);
        if (existsSync(path)) {
          parts.push(`# ${safe}\n\n${await readFile(path, 'utf-8')}`);
        }
      }
      return parts.join('\n\n---\n\n') || '(no matching topic files)';
    }
  • src/index.ts:70-78 (registration)
    Registration of the memory_read tool in the ListTools handler, including its name, description, and input schema.
      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.' },
        },
      },
    },
Behavior4/5

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

No annotations are provided, so the description must disclose behavior. It reveals that calling without arguments is 'cheap' (lightweight), implying topic file retrieval is more expensive. This adds useful context beyond the schema, though it could further clarify error handling or return format.

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 sentences, front-loaded with the core purpose, then a follow-up sentence with usage details. No filler or redundancy.

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

Completeness4/5

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

For a simple read tool with one optional parameter, the description covers the main usage. However, without an output schema, it lacks details on the return format (e.g., structure of the index or topic file content). This is a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but the description adds meaning: it explains that the topics parameter triggers full content retrieval, while omitting it returns the index. This informs the agent of the parameter's purpose beyond data typing.

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 'Read the agent memory index (MEMORY.md) and optionally specific topic files.' It identifies the action (read) and resource (memory index/topic files), and distinguishes from siblings by specifying the no-arguments vs. topics usage.

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

Usage Guidelines5/5

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

Explicit guidance: '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.' This tells the agent when to use each mode, effectively differentiating between lightweight and full retrieval.

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