mavis_session_list
List Mavis sessions to retrieve session IDs, titles, and last-updated timestamps. Filter by agent, limit results, or include archived sessions.
Instructions
List Mavis sessions. Returns session IDs, titles, and last-updated timestamps.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agentId | No | Agent name (default: all agents) | |
| limit | No | Max sessions to return (default: 20) | |
| includeArchived | No | Include compressed/archived sessions |
Implementation Reference
- src/index.js:102-117 (registration)The tool 'mavis_session_list' is defined as an entry in the tools array. It has name, description, inputSchema (Zod), and buildArgs (which constructs CLI args). It uses the default JSON execution path (no execFn, so execMavisJSON is used).
{ name: 'mavis_session_list', description: 'List Mavis sessions. Returns session IDs, titles, and last-updated timestamps.', inputSchema: z.object({ agentId: z.string().optional().describe('Agent name (default: all agents)'), limit: z.number().optional().describe('Max sessions to return (default: 20)'), includeArchived: z.boolean().optional().describe('Include compressed/archived sessions') }), buildArgs: ({ agentId, limit, includeArchived }) => { const args = ['session', 'list']; if (agentId) args.push(agentId); if (limit) args.push('--limit', String(limit)); if (includeArchived) args.push('--include-compressed'); return args; } }, - src/index.js:105-109 (schema)Input schema for mavis_session_list: accepts optional agentId (string), limit (number), and includeArchived (boolean).
inputSchema: z.object({ agentId: z.string().optional().describe('Agent name (default: all agents)'), limit: z.number().optional().describe('Max sessions to return (default: 20)'), includeArchived: z.boolean().optional().describe('Include compressed/archived sessions') }), - src/index.js:77-92 (handler)The runTool function is the generic handler invoked for all tools. For mavis_session_list (no execFn), it calls execMavisJSON (line 84) to execute 'mavis session list ...' and returns JSON-stringified text content.
function runTool(spec, parsedArgs) { const { execFn, outputMode, stdin, buildArgs } = spec; const args = buildArgs(parsedArgs); const input = typeof stdin === 'function' ? stdin(parsedArgs) : stdin; const execPromise = execFn ? execMavis(args, input || '') : execMavisJSON(args); return execPromise.then(result => { const text = outputMode === OUTPUT_RAW ? (result || '') : JSON.stringify(result, null, 2); return [{ type: 'text', text }]; }); } - src/index.js:55-63 (helper)execMavisJSON wraps execMavis and parses the stdout as JSON. Used as default execution for mavis_session_list since it has no execFn.
function execMavisJSON(args) { return execMavis(args).then(raw => { try { return JSON.parse(raw); } catch { const jsonStart = raw.indexOf('{'); return JSON.parse(jsonStart >= 0 ? raw.slice(jsonStart) : raw); } }); - src/index.js:32-53 (helper)execMavis spawns the mavis CLI binary with args and returns stdout. Used by execMavisJSON which handles mavis_session_list execution.
function execMavis(args, input = '') { return new Promise((resolve, reject) => { const SESSION_COMMANDS = new Set(['communication', 'session', 'spawn']); const sessionId = process.env.__MAVIS_PARENT_SESSION_ID; const subcmd = args[0]; const needsSession = SESSION_COMMANDS.has(subcmd) && sessionId; const finalArgs = needsSession ? [...args, '--session', sessionId] : args; const proc = spawn(MAVIS_BIN, finalArgs, { stdio: ['pipe', 'pipe', 'pipe'] }); let stdout = ''; let stderr = ''; proc.stdout.on('data', d => stdout += d.toString()); proc.stderr.on('data', d => stderr += d.toString()); proc.on('close', code => { if (code === 0) resolve(stdout.trim()); else reject(new Error(stderr.split('\n')[0] || `exit code ${code}`)); }); proc.on('error', reject); if (input) proc.stdin.write(input), proc.stdin.end(); }); }