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
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Markdown-formatted session summary. Use structured headers and bullets for better extraction; avoid verbose prose. | |
| source | No | Origin tag, e.g., "kiro", "claude-desktop" |
Implementation Reference
- src/index.ts:80-90 (schema)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'], }, }, - src/index.ts:112-117 (handler)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}` }] }; } - src/index.ts:36-45 (helper)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'], }, }, ], }));