loadCacheFromDisk() — mcp Function Reference
Architecture documentation for the loadCacheFromDisk() function in graph-cache.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD 8e2a6102_97e1_76b1_c08e_d7b87f095026["loadCacheFromDisk()"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7["graph-cache.ts"] 8e2a6102_97e1_76b1_c08e_d7b87f095026 -->|defined in| 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 9d72a623_8b26_a485_5797_5f53c18e4294["start()"] 9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 8e2a6102_97e1_76b1_c08e_d7b87f095026 33bb86df_1268_373b_a74a_77412144612c["debug()"] 8e2a6102_97e1_76b1_c08e_d7b87f095026 -->|calls| 33bb86df_1268_373b_a74a_77412144612c f7302a04_558c_423c_2b1f_3cfced56f273["warn()"] 8e2a6102_97e1_76b1_c08e_d7b87f095026 -->|calls| f7302a04_558c_423c_2b1f_3cfced56f273 f20c71b7_2411_d98b_88ba_3ebc36bdd1f5["buildIndexes()"] 8e2a6102_97e1_76b1_c08e_d7b87f095026 -->|calls| f20c71b7_2411_d98b_88ba_3ebc36bdd1f5 4e1e5a38_002c_8f16_1767_0260a7001d5e["set()"] 8e2a6102_97e1_76b1_c08e_d7b87f095026 -->|calls| 4e1e5a38_002c_8f16_1767_0260a7001d5e 5b58088c_d9af_5bc6_19ab_1fff095079b9["has()"] 8e2a6102_97e1_76b1_c08e_d7b87f095026 -->|calls| 5b58088c_d9af_5bc6_19ab_1fff095079b9 style 8e2a6102_97e1_76b1_c08e_d7b87f095026 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/cache/graph-cache.ts lines 398–458
export async function loadCacheFromDisk(
cacheDir: string,
cache: GraphCache
): Promise<Map<string, IndexedGraph>> {
const repoMap = new Map<string, IndexedGraph>();
let entries: string[];
try {
entries = await fs.readdir(cacheDir);
} catch (error: any) {
if (error.code === 'ENOENT') {
logger.debug('Cache directory does not exist:', cacheDir);
return repoMap;
}
throw error;
}
const jsonFiles = entries.filter(e => e.endsWith('.json'));
logger.debug(`Found ${jsonFiles.length} cache files in ${cacheDir}`);
for (const file of jsonFiles) {
try {
const filePath = join(cacheDir, file);
const content = await fs.readFile(filePath, 'utf-8');
const payload = JSON.parse(content);
if (!payload.raw || !payload.repoName) {
logger.warn(`Skipping invalid cache file: ${file}`);
continue;
}
const repoName = payload.repoName as string;
const cacheKey = `precache:${repoName}`;
const graph = buildIndexes(payload.raw, cacheKey);
cache.set(cacheKey, graph);
repoMap.set(repoName.toLowerCase(), graph);
// Index by commit hash for exact matching (e.g. "commit:abc1234")
const commitHash = payload.commitHash as string | null;
if (commitHash) {
repoMap.set(`commit:${commitHash}`, graph);
}
// Also store common variants of the repo name for matching
// e.g. "django" for "django__django", "astropy" for "astropy__astropy"
const parts = repoName.toLowerCase().split(/[_\-\/]/);
for (const part of parts) {
if (part && part.length > 2 && !repoMap.has(part)) {
repoMap.set(part, graph);
}
}
logger.debug(`Loaded pre-computed graph for ${repoName} (commit: ${commitHash || 'unknown'}): ${graph.summary.nodeCount} nodes`);
} catch (error: any) {
logger.warn(`Failed to load cache file ${file}: ${error.message}`);
}
}
return repoMap;
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does loadCacheFromDisk() do?
loadCacheFromDisk() is a function in the mcp codebase, defined in src/cache/graph-cache.ts.
Where is loadCacheFromDisk() defined?
loadCacheFromDisk() is defined in src/cache/graph-cache.ts at line 398.
What does loadCacheFromDisk() call?
loadCacheFromDisk() calls 5 function(s): buildIndexes, debug, has, set, warn.
What calls loadCacheFromDisk()?
loadCacheFromDisk() 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