Skip to main content
Glama

superdesign_cleanup

Remove outdated design files by age and quantity limits to maintain organized workspaces and optimize storage space.

Instructions

Clean up old design files based on age and count limits

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspace_pathNoWorkspace path (defaults to current directory)
max_age_daysNoDelete designs older than X days (default: 30)
max_countNoKeep only the latest X designs (default: 50)
dry_runNoShow what would be deleted without actually deleting

Implementation Reference

  • MCP tool handler for 'superdesign_cleanup' that parses input arguments using CleanupSchema, calls performCleanup, formats and returns the results including deleted/kept files and settings.
    case "superdesign_cleanup": {
        const { workspace_path, max_age_days, max_count, dry_run } = CleanupSchema.parse(args);
        try {
            const superdesignDir = getSuperdeignDirectory(workspace_path);
            const result = performCleanup(superdesignDir, max_age_days, max_count, dry_run || false);
            let response = `CLEANUP RESULTS:\n\n`;
            if (dry_run) {
                response += `DRY RUN - No files were actually deleted\n\n`;
            }
            if (result.deleted.length > 0) {
                response += `Files ${dry_run ? 'to be deleted' : 'deleted'} (${result.deleted.length}):\n`;
                result.deleted.forEach(file => {
                    response += `  - ${file}\n`;
                });
                response += `\n`;
            }
            if (result.kept.length > 0) {
                response += `Files kept (${result.kept.length}):\n`;
                result.kept.forEach(file => {
                    response += `  - ${file}\n`;
                });
                response += `\n`;
            }
            if (result.errors.length > 0) {
                response += `Errors (${result.errors.length}):\n`;
                result.errors.forEach(error => {
                    response += `  - ${error}\n`;
                });
                response += `\n`;
            }
            if (result.deleted.length === 0 && result.errors.length === 0) {
                response += `No files needed cleanup.\n`;
            }
            const settings = getCleanupSettings(superdesignDir);
            response += `\nCleanup settings:\n`;
            response += `  - Max age: ${max_age_days || settings.maxAgeDays} days\n`;
            response += `  - Max count: ${max_count || settings.maxCount} files\n`;
            response += `  - Enabled: ${settings.enabled}\n`;
            return {
                content: [{ type: "text", text: response }],
            };
        }
        catch (error) {
            return {
                content: [{ type: "text", text: `Error during cleanup: ${error.message}` }],
            };
        }
  • Core helper function that performs the cleanup logic: sorts designs by age, determines which to delete based on max_count and max_age_days, deletes files and updates metadata (or simulates in dry_run mode).
    function performCleanup(superdesignDir, maxAgeDays, maxCount, dryRun = false) {
        const settings = getCleanupSettings(superdesignDir);
        const actualMaxAge = maxAgeDays ?? settings.maxAgeDays;
        const actualMaxCount = maxCount ?? settings.maxCount;
        const metadata = getDesignMetadata(superdesignDir);
        const now = new Date();
        const cutoffDate = new Date(now.getTime() - (actualMaxAge * 24 * 60 * 60 * 1000));
        // Sort by creation date (newest first)
        const sortedMetadata = metadata.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
        const deleted = [];
        const kept = [];
        const errors = [];
        for (let i = 0; i < sortedMetadata.length; i++) {
            const design = sortedMetadata[i];
            const createdAt = new Date(design.createdAt);
            const shouldDelete = i >= actualMaxCount || createdAt < cutoffDate;
            if (shouldDelete) {
                if (!dryRun) {
                    try {
                        const designIterationsDir = path.join(superdesignDir, 'design_iterations');
                        const filePath = path.join(designIterationsDir, design.fileName);
                        if (existsSync(filePath)) {
                            unlinkSync(filePath);
                            // Remove from metadata
                            const allMetadata = loadMetadata(superdesignDir);
                            const filteredMetadata = allMetadata.filter(m => m.fileName !== design.fileName);
                            saveMetadata(superdesignDir, filteredMetadata);
                        }
                        deleted.push(design.fileName);
                    }
                    catch (error) {
                        errors.push(`Failed to delete ${design.fileName}: ${error.message}`);
                    }
                }
                else {
                    deleted.push(design.fileName);
                }
            }
            else {
                kept.push(design.fileName);
            }
        }
        return { deleted, kept, errors };
    }
  • Zod schema defining the input parameters for the superdesign_cleanup tool.
    const CleanupSchema = z.object({
        workspace_path: z.string().optional().describe("Workspace path (defaults to current directory)"),
        max_age_days: z.number().optional().describe("Delete designs older than X days (default: 30)"),
        max_count: z.number().optional().describe("Keep only the latest X designs (default: 50)"),
        dry_run: z.boolean().optional().describe("Show what would be deleted without actually deleting")
    });
  • Registration of the superdesign_cleanup tool in the listTools response, including name, description, and inputSchema.
    {
        name: "superdesign_cleanup",
        description: "Clean up old design files based on age and count limits",
        inputSchema: {
            type: "object",
            properties: {
                workspace_path: { type: "string", description: "Workspace path (defaults to current directory)" },
                max_age_days: { type: "number", description: "Delete designs older than X days (default: 30)" },
                max_count: { type: "number", description: "Keep only the latest X designs (default: 50)" },
                dry_run: { type: "boolean", description: "Show what would be deleted without actually deleting" }
            },
        },
    },
  • Helper function to load or create cleanup settings from JSON file, providing defaults for maxAgeDays and maxCount.
    function getCleanupSettings(superdesignDir) {
        const settingsPath = path.join(superdesignDir, 'cleanup-settings.json');
        const defaultSettings = {
            maxAgeDays: 30,
            maxCount: 50,
            enabled: true
        };
        if (!existsSync(settingsPath)) {
            writeFileSync(settingsPath, JSON.stringify(defaultSettings, null, 2), 'utf8');
            return defaultSettings;
        }
        try {
            const data = readFileSync(settingsPath, 'utf8');
            return { ...defaultSettings, ...JSON.parse(data) };
        }
        catch (error) {
            console.error('Error loading cleanup settings:', error);
            return defaultSettings;
        }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the cleanup action without detailing behavioral traits. It doesn't disclose whether this is destructive (likely yes, but not confirmed), permission requirements, error handling, rate limits, or what 'clean up' entails (e.g., deletion, archiving). The 'dry_run' parameter hints at safety, but the description itself lacks explicit warnings or operational context.

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 without fluff. Every word earns its place by specifying action, target, and criteria concisely, making it easy to parse quickly.

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 no annotations and no output schema, this is a potentially destructive tool with 4 parameters. The description is too minimal—it doesn't cover safety aspects (beyond the implied 'dry_run'), expected outcomes, error conditions, or how it interacts with sibling tools. For a cleanup operation, more context on behavior and risks is needed to be complete.

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?

Schema description coverage is 100%, so parameters are well-documented in the schema. The description adds minimal value beyond implying age and count are key criteria, but doesn't explain interactions between parameters (e.g., if both max_age_days and max_count apply) or provide usage examples. Baseline 3 is appropriate as the schema handles most semantics.

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 action ('clean up') and target resource ('old design files'), specifying criteria ('based on age and count limits'). It distinguishes from siblings like 'superdesign_list' or 'superdesign_delete' by focusing on automated cleanup with specific thresholds. However, it doesn't explicitly contrast with 'superdesign_delete' which might handle individual deletions.

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

Usage Guidelines3/5

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

The description implies usage when needing to remove old files automatically, but provides no explicit guidance on when to use this vs. alternatives like 'superdesign_delete' for manual deletion or 'superdesign_list' for inspection. It mentions criteria (age/count) but lacks context about prerequisites, dependencies, 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/jonthebeef/superdesign-mcp-claude-code'

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