Skip to main content
Glama

read_memory

Retrieve stored data from persistent memory using a specific key to access previously saved information.

Instructions

Read a value from persistent memory by key.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to retrieve

Implementation Reference

  • The handler function that implements the core logic of the 'read_memory' tool. It reads the persistent memory JSON file, retrieves the value by key, and returns it formatted as JSON or a 'not found' message.
    export async function readMemoryHandler(args: any) {
        await ensureMemoryFile();
        const data = JSON.parse(await fs.readFile(MEMORY_FILE, "utf-8"));
        const item = data[args.key];
        if (!item) return { content: [{ type: "text", text: "Key not found." }] };
        return { content: [{ type: "text", text: JSON.stringify(item, null, 2) }] };
    }
  • The Zod schema definition for the 'read_memory' tool, specifying the input parameters (key) and metadata.
    export const readMemorySchema = {
        name: "read_memory",
        description: "Read a value from persistent memory by key.",
        inputSchema: z.object({
            key: z.string().describe("Key to retrieve")
        })
    };
  • src/index.ts:90-90 (registration)
    Registration of the 'read_memory' tool in the main stdio server's tool registry map, associating the schema and handler.
    ["read_memory", { schema: readMemorySchema, handler: readMemoryHandler }],
  • src/server.ts:99-99 (registration)
    Registration of the 'read_memory' tool in the HTTP server's tool registry map, associating the schema and handler.
    ["read_memory", { schema: readMemorySchema, handler: readMemoryHandler }],
  • Helper function used by readMemoryHandler to ensure the memory file exists before reading.
    async function ensureMemoryFile() {
        try {
            await fs.access(MEMORY_FILE);
        } catch {
            await fs.writeFile(MEMORY_FILE, JSON.stringify({}, null, 2));
        }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral information. It doesn't specify what happens if the key doesn't exist (returns null, throws error), whether this operation has side effects, performance characteristics, or authentication requirements. The phrase 'persistent memory' is somewhat informative but vague about implementation details.

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 a single, efficient sentence that communicates the core functionality without unnecessary words. It's appropriately sized for a simple read operation and front-loads the essential information.

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

Completeness2/5

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

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what format the returned value will be in, whether there are size limitations, how persistence works across sessions, or error handling. Given the context of sibling tools like 'save_memory' and 'list_memories', more integration guidance would be helpful.

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?

Schema description coverage is 100% with the single parameter 'key' well-documented in the schema. The description adds no additional parameter information beyond what's already in the schema, so it meets the baseline for high schema coverage but doesn't provide extra value like examples of valid key formats or constraints.

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

Purpose4/5

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

The description clearly states the action ('Read') and resource ('value from persistent memory by key'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'list_memories' or explain the relationship between reading individual keys and listing all stored memories.

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

Usage Guidelines2/5

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

The description provides no guidance about when to use this tool versus alternatives like 'list_memories' or 'save_memory'. There's no mention of prerequisites (e.g., keys must exist), error conditions, or typical use cases for reading from persistent memory versus other storage mechanisms.

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/millsydotdev/Code-MCP'

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