m9k_save
Save memory notes for important decisions, patterns, or context using the Melchizedek MCP server's persistent memory system. Organize with tags for future recall.
Instructions
Manually save a memory note for future recall. Use for important decisions, patterns, or context.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The memory content to save | |
| tags | No | Optional tags for categorization |
Implementation Reference
- src/tools/memory.ts:68-122 (handler)The handler logic for the 'm9k_save' tool, which saves memory notes to a SQLite database.
async ({ content, tags }) => { const MANUAL_SESSION_ID = '__manual_memories__'; // Ensure the manual memories session exists const existingSession = ctx.db .prepare('SELECT id FROM conv_sessions WHERE id = ?') .get(MANUAL_SESSION_ID) as { id: string } | undefined; if (!existingSession) { ctx.db .prepare( `INSERT INTO conv_sessions (id, project, jsonl_path, file_hash, file_size, started_at, message_count, chunk_count) VALUES (?, ?, ?, ?, ?, datetime('now'), 0, 0)`, ) .run(MANUAL_SESSION_ID, '__global__', '__manual__', '', 0); } const hash = crypto.createHash('sha256').update(content).digest('hex'); const chunkId = `mem:${hash.slice(0, 12)}`; const tagsJson = tags && tags.length > 0 ? JSON.stringify(tags) : null; // INSERT OR IGNORE for dedup by hash const result = ctx.db .prepare( `INSERT OR IGNORE INTO conv_chunks (id, session_id, idx, kind, user_content, assistant_content, hash, timestamp, token_count, tags, metadata_json) VALUES (?, ?, 0, ?, ?, '', ?, datetime('now'), ?, ?, '{}')`, ) .run( chunkId, MANUAL_SESSION_ID, CONV_KIND_MEMORY, content, hash, Math.ceil(content.length / 4), tagsJson, ); // Update session chunk count ctx.db .prepare( `UPDATE conv_sessions SET chunk_count = (SELECT COUNT(*) FROM conv_chunks WHERE session_id = ?) WHERE id = ?`, ) .run(MANUAL_SESSION_ID, MANUAL_SESSION_ID); const saved = result.changes > 0; return { content: [ { type: 'text' as const, text: JSON.stringify({ saved, chunkId, duplicate: !saved }), }, ], }; }, ); - src/tools/memory.ts:52-67 (registration)Registration of the 'm9k_save' tool including its input schema and annotations.
server.registerTool( 'm9k_save', { description: 'Manually save a memory note for future recall. Use for important decisions, patterns, or context.', inputSchema: { content: z.string().describe('The memory content to save'), tags: z.array(z.string()).optional().describe('Optional tags for categorization'), }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, },