resolveOrFetchGraph() — mcp Function Reference
Architecture documentation for the resolveOrFetchGraph() function in graph-cache.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD 1721f7fd_bb7b_c8c3_9b4b_5677293ae256["resolveOrFetchGraph()"] 1767161e_720a_f6c8_bf00_3dc68740b823["handler()"] 1767161e_720a_f6c8_bf00_3dc68740b823 -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 37989e20_855d_701d_ca13_a196d7d4a37e["handler()"] 37989e20_855d_701d_ca13_a196d7d4a37e -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 7623ea08_e684_62f6_f74f_3b1d646a26f5["handler()"] 7623ea08_e684_62f6_f74f_3b1d646a26f5 -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 e5737e93_21e3_4389_2f31_c2c4b7b9ef6c["handler()"] e5737e93_21e3_4389_2f31_c2c4b7b9ef6c -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 0c9ec015_a9a0_5ced_2032_d9aa5a5efa81["searchSymbolHandler()"] 0c9ec015_a9a0_5ced_2032_d9aa5a5efa81 -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 211e0c66_321b_c05c_6d2c_3b3009df3949["findDefinitionHandler()"] 211e0c66_321b_c05c_6d2c_3b3009df3949 -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 21066345_5e12_0bc2_9825_2a3d68bcb1b7["traceCallsHandler()"] 21066345_5e12_0bc2_9825_2a3d68bcb1b7 -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 0dc81adb_6983_30fe_6ae1_4620d20c0ff0["annotateHandler()"] 0dc81adb_6983_30fe_6ae1_4620d20c0ff0 -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 ec84daee_4b9f_c373_088b_c46d9bf9913e["detectRepo()"] 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 -->|calls| ec84daee_4b9f_c373_088b_c46d9bf9913e 2bb2b0ae_2fea_7264_08ce_133bb9b7810c["generateIdempotencyKey()"] 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 -->|calls| 2bb2b0ae_2fea_7264_08ce_133bb9b7810c d6ed9355_f977_306b_b0ef_d7220fdefe68["get()"] 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 -->|calls| d6ed9355_f977_306b_b0ef_d7220fdefe68 9a818de6_4969_c29c_0dd7_dab4f6d4fbdb["error()"] 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 -->|calls| 9a818de6_4969_c29c_0dd7_dab4f6d4fbdb 1fd46af5_c3e2_8998_1eb2_098430ff3629["zipRepository()"] 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 -->|calls| 1fd46af5_c3e2_8998_1eb2_098430ff3629 11d5249b_82de_e1fb_e621_e95ae1a093c5["buildIndexes()"] 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 -->|calls| 11d5249b_82de_e1fb_e621_e95ae1a093c5 style 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/cache/graph-cache.ts lines 582–633
export async function resolveOrFetchGraph(
client: ClientContext,
directory: string
): Promise<IndexedGraph> {
// 1. Pre-computed cache
const precomputed = detectRepo(directory, _repoMap);
if (precomputed) return precomputed;
// 2. LRU cache
const idempotencyKey = generateIdempotencyKey(directory);
const cached = graphCache.get(idempotencyKey);
if (cached) return cached;
// 3. Fast-fail when API fallback is disabled (e.g. SWE-bench)
if (_noApiFallback) {
throw {
response: null,
request: null,
message: 'No pre-computed graph available for this repository. Use grep, find, and file reading to explore the codebase instead.',
code: 'NO_CACHE',
};
}
// 4. API fallback
console.error('[Supermodel] Generating codebase graph (this may take a few minutes)...');
const zipResult = await zipRepository(directory);
let progressInterval: NodeJS.Timeout | null = null;
let elapsed = 0;
progressInterval = setInterval(() => {
elapsed += 15;
console.error(`[Supermodel] Analysis in progress... (${elapsed}s elapsed)`);
}, 15000);
try {
const fileBuffer = await fs.readFile(zipResult.path);
const fileBlob = new Blob([fileBuffer], { type: 'application/zip' });
const response = await client.graphs.generateSupermodelGraph(
fileBlob as any,
{ idempotencyKey }
);
const graph = buildIndexes(response, idempotencyKey);
graphCache.set(idempotencyKey, graph);
console.error('[Supermodel] Analysis complete.');
return graph;
} finally {
if (progressInterval) clearInterval(progressInterval);
await zipResult.cleanup();
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does resolveOrFetchGraph() do?
resolveOrFetchGraph() is a function in the mcp codebase.
What does resolveOrFetchGraph() call?
resolveOrFetchGraph() calls 7 function(s): buildIndexes, detectRepo, error, generateIdempotencyKey, get, set, zipRepository.
What calls resolveOrFetchGraph()?
resolveOrFetchGraph() is called by 8 function(s): annotateHandler, findDefinitionHandler, handler, handler, handler, handler, searchSymbolHandler, traceCallsHandler.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free