m9k_sessions
List and filter indexed sessions by project, source type, or limit results for persistent memory management in Claude Code.
Instructions
List all indexed sessions, optionally filtered by project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | Filter by project path | |
| limit | No | Max sessions | |
| source | No | Filter by source type. Default: all sources. |
Implementation Reference
- src/tools/memory.ts:124-157 (handler)The 'm9k_sessions' tool handler implementation, which queries the 'conv_sessions' table.
server.registerTool( 'm9k_sessions', { description: 'List all indexed sessions, optionally filtered by project.', inputSchema: { project: z.string().optional().describe('Filter by project path'), limit: z.number().int().min(1).max(100).default(20).describe('Max sessions'), source: z .enum(['conversations', 'git', 'files']) .optional() .describe('Filter by source type. Default: all sources.'), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async ({ project, limit }) => { let sql = 'SELECT * FROM conv_sessions WHERE deleted_at IS NULL'; const params: unknown[] = []; if (project) { sql += ' AND project = ?'; params.push(project); } sql += ' ORDER BY started_at DESC LIMIT ?'; params.push(limit); const rows = ctx.db.prepare(sql).all(...params); return { content: [{ type: 'text' as const, text: JSON.stringify(rows) }], }; }, );