buildIgnoreFilter() — mcp Function Reference
Architecture documentation for the buildIgnoreFilter() function in zip-repository.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167["buildIgnoreFilter()"] 1fd46af5_c3e2_8998_1eb2_098430ff3629["zipRepository()"] 1fd46af5_c3e2_8998_1eb2_098430ff3629 -->|calls| d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167 69fc7a46_28f6_6b72_2725_66c381e53322["debug()"] d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167 -->|calls| 69fc7a46_28f6_6b72_2725_66c381e53322 8d4cd429_ec54_0fed_e163_4affcc57c61d["findGitignoreFiles()"] d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167 -->|calls| 8d4cd429_ec54_0fed_e163_4affcc57c61d e5352615_c5fb_64a2_cc5c_a248578cbc8a["warn()"] d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167 -->|calls| e5352615_c5fb_64a2_cc5c_a248578cbc8a 9a818de6_4969_c29c_0dd7_dab4f6d4fbdb["error()"] d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167 -->|calls| 9a818de6_4969_c29c_0dd7_dab4f6d4fbdb style d9b9a00b_7ed2_f6c8_1ca7_1e298c76a167 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/utils/zip-repository.ts lines 423–515
async function buildIgnoreFilter(
rootDir: string,
additionalExclusions: string[] = [],
includeGitignore: boolean = true
): Promise<Ignore> {
const ig = ignore();
// Add standard exclusions
ig.add(STANDARD_EXCLUSIONS);
// Add custom exclusions
if (additionalExclusions.length > 0) {
ig.add(additionalExclusions);
}
// Exclude .gitignore files if requested
if (includeGitignore === false) {
ig.add(['.gitignore', '**/.gitignore']);
logger.debug('Excluding .gitignore files from archive');
}
// Recursively find and parse all .gitignore files
const gitignoreFiles = await findGitignoreFiles(rootDir);
for (const gitignorePath of gitignoreFiles) {
try {
const gitignoreContent = await fs.readFile(gitignorePath, 'utf-8');
const patterns = gitignoreContent
.split('\n')
.map(line => line.trim())
.filter(line => line && !line.startsWith('#'));
if (patterns.length > 0) {
// Get the directory containing this .gitignore
const gitignoreDir = gitignorePath.substring(0, gitignorePath.length - '.gitignore'.length);
const relativeDir = relative(rootDir, gitignoreDir);
// Scope patterns to their directory
const scopedPatterns = patterns.map(pattern => {
// If pattern starts with '/', it's relative to the .gitignore location
if (pattern.startsWith('/')) {
const patternWithoutSlash = pattern.substring(1);
return relativeDir ? `${relativeDir}/${patternWithoutSlash}` : patternWithoutSlash;
}
// If pattern starts with '!', handle negation
else if (pattern.startsWith('!')) {
const negatedPattern = pattern.substring(1);
if (negatedPattern.startsWith('/')) {
const patternWithoutSlash = negatedPattern.substring(1);
return relativeDir ? `!${relativeDir}/${patternWithoutSlash}` : `!${patternWithoutSlash}`;
}
// For non-rooted negation patterns, prefix with directory
return relativeDir ? `!${relativeDir}/${negatedPattern}` : `!${negatedPattern}`;
}
// For non-rooted patterns, prefix with the directory path
else {
return relativeDir ? `${relativeDir}/${pattern}` : pattern;
}
});
ig.add(scopedPatterns);
const location = relativeDir ? `in ${relativeDir}/` : 'in root';
logger.debug(`Loaded .gitignore ${location} with ${patterns.length} patterns`);
}
} catch (error: any) {
if (error.code !== 'ENOENT') {
logger.warn('Failed to read .gitignore at', gitignorePath, ':', error.message);
}
}
}
// Parse .dockerignore in root
const dockerignorePath = join(rootDir, '.dockerignore');
try {
const dockerignoreContent = await fs.readFile(dockerignorePath, 'utf-8');
const patterns = dockerignoreContent
.split('\n')
.map(line => line.trim())
.filter(line => line && !line.startsWith('#'));
if (patterns.length > 0) {
ig.add(patterns);
console.error('[DEBUG] Loaded .dockerignore with', patterns.length, 'patterns');
}
} catch (error: any) {
if (error.code !== 'ENOENT') {
console.error('[WARN] Failed to read .dockerignore:', error.message);
}
}
return ig;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does buildIgnoreFilter() do?
buildIgnoreFilter() is a function in the mcp codebase.
What does buildIgnoreFilter() call?
buildIgnoreFilter() calls 4 function(s): debug, error, findGitignoreFiles, warn.
What calls buildIgnoreFilter()?
buildIgnoreFilter() is called by 1 function(s): zipRepository.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free