Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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
          );
        }
      }
    }
  • Zod schema for listSessions tool input arguments.
    export const ListSessionsToolSchema = z.object({});
  • Registration of the listSessions handler in the tools registry.
    [TOOLS.LIST_SESSIONS]: new ListSessionsToolHandler(sessionStorage),
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tom-wahl/codex-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server