Skip to main content
Glama
es6kr
by es6kr

preview_cleanup

Preview empty and invalid API key sessions for cleanup in Claude Code conversations. Filter by project name to identify sessions requiring 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 for the preview_cleanup tool. It lists projects (optionally filtered), scans sessions for empty ones (messageCount === 0) and invalid API key sessions, and returns per-project results with lists of such sessions.
    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
      })
  • Registers the 'preview_cleanup' tool in the MCP server, including input schema (optional project_name string) and delegates execution to session.previewCleanup.
    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: optional project_name string.
      project_name: z.string().optional().describe('Optional: filter by project name'),
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'previews' sessions, implying a read-only operation, but doesn't clarify if this requires specific permissions, what the output format is, or any side effects (e.g., if it logs or caches data). For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It uses parentheses to add clarifying detail without unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a preview tool for session cleanup), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'preview' entails (e.g., returns a list, count, or summary), how 'empty' and 'invalid API key sessions' are defined, or any error conditions. This leaves the agent with insufficient context to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter with 100% description coverage, so the schema already documents 'project_name' as an optional filter. The description doesn't add any meaning beyond this—it doesn't explain how 'project_name' relates to the cleanup criteria or provide examples. With high schema coverage, the baseline is 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Preview sessions that would be cleaned (empty and invalid API key sessions)'. It specifies the verb 'preview' and the resource 'sessions', with additional context about the cleanup criteria. However, it doesn't explicitly distinguish this from sibling tools like 'clear_sessions' or 'list_sessions', which would require a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'clear_sessions' (which might perform the actual cleanup) or 'list_sessions' (which might list all sessions without filtering). There's no context about prerequisites, timing, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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