Home / Function/ cleanupOldZips() — mcp Function Reference

cleanupOldZips() — mcp Function Reference

Architecture documentation for the cleanupOldZips() function in zip-repository.ts from the mcp codebase.

Entity Profile

Dependency Diagram

graph TD
  8b9027cb_22ba_2e2c_2393_3368aa90048f["cleanupOldZips()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a["start()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| 8b9027cb_22ba_2e2c_2393_3368aa90048f
  dfe11f52_4dd3_db89_9717_941d05bae091["warn()"]
  8b9027cb_22ba_2e2c_2393_3368aa90048f -->|calls| dfe11f52_4dd3_db89_9717_941d05bae091
  b8971bfc_ba3c_23a9_1f17_5d613ac67105["debug()"]
  8b9027cb_22ba_2e2c_2393_3368aa90048f -->|calls| b8971bfc_ba3c_23a9_1f17_5d613ac67105
  style 8b9027cb_22ba_2e2c_2393_3368aa90048f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/utils/zip-repository.ts lines 718–756

export async function cleanupOldZips(maxAgeMs: number = ZIP_CLEANUP_AGE_MS): Promise<void> {
  const tempDir = tmpdir();
  const now = Date.now();

  try {
    const entries = await fs.readdir(tempDir);
    let removedCount = 0;

    for (const entry of entries) {
      // Only process our ZIP files
      if (!entry.startsWith('supermodel-') || !entry.endsWith('.zip')) {
        continue;
      }

      const fullPath = join(tempDir, entry);

      try {
        const stats = await fs.stat(fullPath);
        const ageMs = now - stats.mtimeMs;

        if (ageMs > maxAgeMs) {
          await fs.unlink(fullPath);
          removedCount++;
        }
      } catch (error: any) {
        // File might have been deleted already, ignore
        if (error.code !== 'ENOENT') {
          logger.warn('Failed to cleanup:', fullPath, error.message);
        }
      }
    }

    if (removedCount > 0) {
      logger.debug('Cleaned up', removedCount, 'old ZIP files');
    }
  } catch (error: any) {
    logger.warn('Failed to cleanup temp directory:', error.message);
  }
}

Subdomains

Called By

Frequently Asked Questions

What does cleanupOldZips() do?
cleanupOldZips() is a function in the mcp codebase.
What does cleanupOldZips() call?
cleanupOldZips() calls 2 function(s): debug, warn.
What calls cleanupOldZips()?
cleanupOldZips() is called by 1 function(s): start.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free