zipRepository() — mcp Function Reference
Architecture documentation for the zipRepository() function in zip-repository.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD bbbd3356_722d_4bf8_09d2_706412487d25["zipRepository()"] b00e0b6e_8e66_44d2_f709_c8c6bbb476c9["zip-repository.ts"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|defined in| b00e0b6e_8e66_44d2_f709_c8c6bbb476c9 0c2dbb97_347e_7226_4d31_fbdcb85ac22b["resolveOrFetchGraph()"] 0c2dbb97_347e_7226_4d31_fbdcb85ac22b -->|calls| bbbd3356_722d_4bf8_09d2_706412487d25 5f051fd3_b5fd_05fe_3e0b_f20364a0b064["precacheForDirectory()"] 5f051fd3_b5fd_05fe_3e0b_f20364a0b064 -->|calls| bbbd3356_722d_4bf8_09d2_706412487d25 5c90e8cd_7cb8_59e4_cdeb_8ef1addd217e["error()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| 5c90e8cd_7cb8_59e4_cdeb_8ef1addd217e 44ecfbe1_2321_f70c_1614_c983eebf0cf5["buildIgnoreFilter()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| 44ecfbe1_2321_f70c_1614_c983eebf0cf5 33bb86df_1268_373b_a74a_77412144612c["debug()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| 33bb86df_1268_373b_a74a_77412144612c 2551d272_a873_fd1f_63c5_810cf113a32c["estimateDirectorySize()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| 2551d272_a873_fd1f_63c5_810cf113a32c c7ef4400_cc66_9f8c_3fec_50f4c76e3cdf["formatBytes()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| c7ef4400_cc66_9f8c_3fec_50f4c76e3cdf f7302a04_558c_423c_2b1f_3cfced56f273["warn()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| f7302a04_558c_423c_2b1f_3cfced56f273 bb858fdb_9a3b_a551_d94a_ce5beeb5b86f["addFilesRecursively()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| bb858fdb_9a3b_a551_d94a_ce5beeb5b86f style bbbd3356_722d_4bf8_09d2_706412487d25 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/utils/zip-repository.ts lines 176–340
export async function zipRepository(
directoryPath: string,
options: ZipOptions = {}
): Promise<ZipResult> {
const maxSizeBytes = options.maxSizeBytes || MAX_ZIP_SIZE_BYTES;
// Validate directory exists
try {
const stats = await fs.stat(directoryPath);
if (!stats.isDirectory()) {
const errorMsg = `Path is not a directory: ${directoryPath}`;
logger.error(errorMsg);
throw new Error(errorMsg);
}
} catch (error: any) {
if (error.code === 'ENOENT') {
const errorMsg = `Directory does not exist: ${directoryPath}`;
logger.error(errorMsg);
throw new Error(errorMsg);
}
if (error.code === 'EACCES') {
const errorMsg = `Permission denied accessing directory: ${directoryPath}`;
logger.error(errorMsg);
throw new Error(errorMsg);
}
// Re-throw unknown errors with logging
logger.error('Failed to validate directory:', directoryPath);
logger.error('Error:', error.message);
throw error;
}
// Parse gitignore files
const ignoreFilter = await buildIgnoreFilter(
directoryPath,
options.additionalExclusions,
options.includeGitignore
);
// Estimate directory size before starting ZIP creation
logger.debug('Estimating directory size...');
const estimatedSize = await estimateDirectorySize(directoryPath, ignoreFilter);
logger.debug('Estimated size:', formatBytes(estimatedSize));
// Check if estimated size exceeds limit
if (estimatedSize > maxSizeBytes) {
throw new Error(
`Directory size (${formatBytes(estimatedSize)}) exceeds maximum allowed size (${formatBytes(maxSizeBytes)}). ` +
`Consider excluding more directories or analyzing a subdirectory.`
);
}
// Create temp file path
const tempDir = tmpdir();
const zipFileName = `supermodel-${randomBytes(8).toString('hex')}.zip`;
const zipPath = join(tempDir, zipFileName);
logger.debug('Creating ZIP:', zipPath);
logger.debug('Source directory:', directoryPath);
// Create ZIP archive
let fileCount = 0;
let totalSize = 0;
const output = createWriteStream(zipPath);
const archive = archiver('zip', {
zlib: { level: 6 } // Balanced compression
});
// Track errors
let archiveError: Error | null = null;
archive.on('error', (err) => {
logger.error('Archive error:', err.message);
archiveError = err;
});
archive.on('warning', (err) => {
if (err.code === 'ENOENT') {
logger.warn('File not found (skipping):', err.message);
} else {
logger.warn('Archive warning:', err.message);
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does zipRepository() do?
zipRepository() is a function in the mcp codebase, defined in src/utils/zip-repository.ts.
Where is zipRepository() defined?
zipRepository() is defined in src/utils/zip-repository.ts at line 176.
What does zipRepository() call?
zipRepository() calls 7 function(s): addFilesRecursively, buildIgnoreFilter, debug, error, estimateDirectorySize, formatBytes, warn.
What calls zipRepository()?
zipRepository() is called by 2 function(s): precacheForDirectory, resolveOrFetchGraph.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free