Skip to main content
Glama

memory_append_session

Append a structured markdown session summary to the sessions directory for durable memory extraction. Call at the end of meaningful exchanges to capture key findings and decisions.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesMarkdown-formatted session summary. Use structured headers and bullets for better extraction; avoid verbose prose.
sourceNoOrigin tag, e.g., "kiro", "claude-desktop"

Implementation Reference

  • Schema/registration for the 'memory_append_session' tool, defining its name, description, and input schema (content string, optional source string).
      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'],
      },
    },
  • Handler function for 'memory_append_session' that extracts the content and optional source args, calls appendSession(), and returns the filename.
    if (name === 'memory_append_session') {
      const content = String(args?.content ?? '');
      if (!content.trim()) throw new Error('content is required');
      const filename = await appendSession(content, args?.source as string | undefined);
      return { content: [{ type: 'text', text: `Wrote session: ${filename}` }] };
    }
  • The appendSession() helper function: ensures the session directory exists, generates a timestamped filename, writes frontmatter (source + timestamp), appends the content, and returns the filename.
    async function appendSession(content: string, source?: string): Promise<string> {
      await ensureDir(SESSION_DIR);
      const ts = new Date().toISOString().replace(/[:.]/g, '-');
      const tag = (source ?? 'mcp').replace(/[^a-zA-Z0-9_-]/g, '');
      const filename = `${ts}-${tag}.md`;
      const path = join(SESSION_DIR, filename);
      const frontmatter = `---\nsource: ${tag}\ntimestamp: ${new Date().toISOString()}\n---\n\n`;
      await appendFile(path, frontmatter + content, 'utf-8');
      return filename;
    }
  • src/index.ts:67-101 (registration)
    The ListToolsRequestSchema handler that registers all three tools (memory_read, memory_append_session, memory_search) on the MCP server.
    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'],
          },
        },
      ],
    }));
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses that the daemon will later extract memories and that longer summaries incur higher cost. This adds useful behavioral context beyond the simple append.

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?

Three compact sentences, each serves a purpose: action, timing, and content guidelines. No redundancy, front-loaded with core function.

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?

For a simple tool with two parameters and no output schema, the description provides complete guidance: what, when, how, and cost implications. No gaps.

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 has 100% description coverage, but description adds significant value by advising on summary focus, token target (300-800), and avoiding verbose prose. This guides the agent beyond schema definitions.

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?

Description clearly states 'Append a session summary to the sessions directory' with a specific verb and resource. It distinguishes from sibling read tools (memory_read, memory_search) by being a write operation.

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?

Explicitly advises 'Call this at the end of meaningful exchanges' and provides guidelines on summary length and content. No exclusion criteria or alternatives mentioned, but context is clear.

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