Skip to main content
Glama

memory_recent

Retrieve memories saved within a configurable number of past days. Use the project filter to narrow down by specific work context.

Instructions

List recently saved memories. Use for a quick overview of what's been recorded.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoHow many days back (default: 7)
projectNoFilter by project name

Implementation Reference

  • The handleMemoryRecent function that queries the SQLite database for memories newer than a cutoff date (default 7 days), optionally filtered by project, returning up to 20 results in a formatted string.
    export async function handleMemoryRecent(
      days?: number,
      project?: string,
    ): Promise<string> {
      const db = getDb();
      const cutoff = Date.now() - (days ?? 7) * 24 * 60 * 60 * 1000;
    
      let sql = `SELECT id, content, category, project, created_at FROM memories
                 WHERE created_at >= ? AND archived = 0`;
      const params: unknown[] = [cutoff];
    
      if (project) {
        sql += ` AND project = ?`;
        params.push(project);
      }
    
      sql += ` ORDER BY created_at DESC LIMIT 20`;
    
      const memories = db.prepare(sql).all(...params) as Array<{
        id: string;
        content: string;
        category: string;
        project: string | null;
        created_at: number;
      }>;
    
      if (memories.length === 0) {
        const projectStr = project ? ` for project "${project}"` : "";
        return `No memories in the last ${days ?? 7} day(s)${projectStr}.`;
      }
    
      const lines = memories.map((m) => {
        const date = new Date(m.created_at).toISOString().slice(0, 16).replace("T", " ");
        const projectTag = m.project ? ` [${m.project}]` : "";
        return `- **${date}** (${m.category})${projectTag}: ${m.content.slice(0, 150)}`;
      });
    
      return `${memories.length} recent memory(s):\n\n${lines.join("\n")}`;
    }
  • Zod schema definitions for the memory_recent tool: optional 'days' (number) and 'project' (string) parameters.
    {
      days: z.number().optional().describe("How many days back (default: 7)"),
      project: z.string().optional().describe("Filter by project name"),
    },
  • Registration of the 'memory_recent' tool via server.tool(), including the handler that calls handleMemoryRecent and wraps the result in a text content response.
    server.tool(
      "memory_recent",
      "List recently saved memories. Use for a quick overview of what's been recorded.",
      {
        days: z.number().optional().describe("How many days back (default: 7)"),
        project: z.string().optional().describe("Filter by project name"),
      },
      async ({ days, project }) => {
        try {
          const result = await handleMemoryRecent(days, project);
          return { content: [{ type: "text", text: result }] };
        } catch (err) {
          return {
            content: [{ type: "text", text: `Error listing memories: ${err}` }],
            isError: true,
          };
        }
      },
    );
  • Import statement for handleMemoryRecent from the tools module.
    import { handleMemoryRecent } from "./tools/memory-recent.js";
  • The getDb() helper function that returns a better-sqlite3 database connection, used by the handler to query memories.
    export function getDb(): any {
      if (_db) return _db;
      if (_unavailable || !Database) {
        _unavailable = true;
        throw new Error(
          "Memory database unavailable — better-sqlite3 failed to load. " +
          "This is usually a native compilation issue. Memory features are disabled but everything else works. " +
          "Try: npm rebuild better-sqlite3"
        );
      }
    
      try {
        fs.mkdirSync(DB_DIR, { recursive: true });
        _db = new Database(DB_PATH);
    
        _db.pragma("journal_mode = WAL");
    
        _db.exec(`
          CREATE TABLE IF NOT EXISTS memories (
            id TEXT PRIMARY KEY,
            content TEXT NOT NULL,
            category TEXT NOT NULL DEFAULT 'general',
            project TEXT,
            source_file TEXT,
            created_at INTEGER NOT NULL,
            updated_at INTEGER NOT NULL,
            accessed_at INTEGER NOT NULL,
            access_count INTEGER NOT NULL DEFAULT 0,
            archived INTEGER NOT NULL DEFAULT 0,
            embedding BLOB
Behavior2/5

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

No annotations provided, and the description lacks behavioral details (e.g., sorting, pagination, what 'recently' means in terms of timeline).

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

Conciseness4/5

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

Two sentences, efficient and to the point, though it could be more structured without losing brevity.

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?

Despite simple schema, the description omits useful context like default behavior, sorting order, or any limits, leaving the agent with gaps.

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 descriptions already cover both parameters fully (100% coverage), and the description adds no extra semantic value beyond stating 'quick overview'.

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?

Clearly states 'List recently saved memories' with a specific verb and resource, distinguishing from siblings like memory_search and memory_save.

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

Usage Guidelines3/5

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

Provides general context ('quick overview') but does not specify when to avoid or compare to alternative tools like memory_search.

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/DomDemetz/claude-soul'

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