buildIgnoreFilter() — mcp Function Reference
Architecture documentation for the buildIgnoreFilter() function in zip-repository.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD 44ecfbe1_2321_f70c_1614_c983eebf0cf5["buildIgnoreFilter()"] b00e0b6e_8e66_44d2_f709_c8c6bbb476c9["zip-repository.ts"] 44ecfbe1_2321_f70c_1614_c983eebf0cf5 -->|defined in| b00e0b6e_8e66_44d2_f709_c8c6bbb476c9 bbbd3356_722d_4bf8_09d2_706412487d25["zipRepository()"] bbbd3356_722d_4bf8_09d2_706412487d25 -->|calls| 44ecfbe1_2321_f70c_1614_c983eebf0cf5 33bb86df_1268_373b_a74a_77412144612c["debug()"] 44ecfbe1_2321_f70c_1614_c983eebf0cf5 -->|calls| 33bb86df_1268_373b_a74a_77412144612c 1ea3c907_ef99_80b1_3a67_c18aff6c6391["findGitignoreFiles()"] 44ecfbe1_2321_f70c_1614_c983eebf0cf5 -->|calls| 1ea3c907_ef99_80b1_3a67_c18aff6c6391 f7302a04_558c_423c_2b1f_3cfced56f273["warn()"] 44ecfbe1_2321_f70c_1614_c983eebf0cf5 -->|calls| f7302a04_558c_423c_2b1f_3cfced56f273 5c90e8cd_7cb8_59e4_cdeb_8ef1addd217e["error()"] 44ecfbe1_2321_f70c_1614_c983eebf0cf5 -->|calls| 5c90e8cd_7cb8_59e4_cdeb_8ef1addd217e style 44ecfbe1_2321_f70c_1614_c983eebf0cf5 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('#'));
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does buildIgnoreFilter() do?
buildIgnoreFilter() is a function in the mcp codebase, defined in src/utils/zip-repository.ts.
Where is buildIgnoreFilter() defined?
buildIgnoreFilter() is defined in src/utils/zip-repository.ts at line 423.
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