Skip to main content
Glama

preview_cleanup

Preview Claude Code sessions marked for cleanup to identify empty sessions and those with invalid API keys before removal.

Instructions

Preview sessions that would be cleaned (empty and invalid API key sessions)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameNoOptional: filter by project name

Implementation Reference

  • The core handler function implementing the preview_cleanup tool logic. It lists projects (filtered by optional projectName), lists sessions in each, identifies empty sessions (messageCount === 0) and invalid API key sessions (title includes 'Invalid API key' or 'API key'), and returns a structured preview.
    export const previewCleanup = (projectName?: string) => Effect.gen(function* () { const projects = yield* listProjects const targetProjects = projectName ? projects.filter((p) => p.name === projectName) : projects const results = yield* Effect.all( targetProjects.map((project) => Effect.gen(function* () { const sessions = yield* listSessions(project.name) const emptySessions = sessions.filter((s) => s.messageCount === 0) const invalidSessions = sessions.filter( (s) => s.title?.includes('Invalid API key') || s.title?.includes('API key') ) return { project: project.name, emptySessions, invalidSessions, } }) ), { concurrency: 5 } ) return results })
  • MCP server tool registration for 'preview_cleanup'. Defines the tool name, description, input schema (optional project_name), and handler that delegates to session.previewCleanup and formats the JSON response.
    server.tool( 'preview_cleanup', 'Preview sessions that would be cleaned (empty and invalid API key sessions)', { project_name: z.string().optional().describe('Optional: filter by project name'), }, async ({ project_name }) => { const result = await Effect.runPromise(session.previewCleanup(project_name)) return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], } }
  • Zod input schema for the preview_cleanup tool, defining an optional string parameter 'project_name' for filtering by project.
    { project_name: z.string().optional().describe('Optional: filter by project name'), },

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/DrumRobot/claude-sessions-mcp'

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