listSessions
View active conversation sessions with metadata to manage coding assistance workflows and maintain context continuity in the Codex MCP Server.
Instructions
List all active conversation sessions with metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/handlers.ts:214-251 (handler)Handler implementation for listSessions tool.
export class ListSessionsToolHandler { constructor(private sessionStorage: SessionStorage) {} async execute(args: unknown): Promise<ToolResult> { try { ListSessionsToolSchema.parse(args); const sessions = this.sessionStorage.listSessions(); const sessionInfo = sessions.map((session) => ({ id: session.id, createdAt: session.createdAt.toISOString(), lastAccessedAt: session.lastAccessedAt.toISOString(), turnCount: session.turns.length, })); return { content: [ { type: 'text', text: sessionInfo.length > 0 ? JSON.stringify(sessionInfo, null, 2) : 'No active sessions', }, ], }; } catch (error) { if (error instanceof ZodError) { throw new ValidationError(TOOLS.LIST_SESSIONS, error.message); } throw new ToolExecutionError( TOOLS.LIST_SESSIONS, 'Failed to list sessions', error ); } } } - src/types.ts:55-55 (schema)Zod schema for listSessions tool input arguments.
export const ListSessionsToolSchema = z.object({}); - src/tools/handlers.ts:260-260 (registration)Registration of the listSessions handler in the tools registry.
[TOOLS.LIST_SESSIONS]: new ListSessionsToolHandler(sessionStorage),