graph-cache.ts — mcp Source File
Architecture documentation for graph-cache.ts, a typescript file in the mcp codebase. 12 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7["graph-cache.ts"] 3c41e44b_ebb5_f793_8014_42ade5f9b440["graph-types.ts"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 3c41e44b_ebb5_f793_8014_42ade5f9b440 19f4d048_f875_3a64_f6f5_2d534dca972b["constants.ts"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 19f4d048_f875_3a64_f6f5_2d534dca972b 5c6acde2_5ba8_604f_70ae_120f7b72feaa["types.ts"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 5c6acde2_5ba8_604f_70ae_120f7b72feaa 9ab4aae7_6acf_c11b_eb86_226086872d36["ClientContext"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 9ab4aae7_6acf_c11b_eb86_226086872d36 4bef1572_5a60_651d_3247_2779d2e6bd57["api-helpers.ts"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 4bef1572_5a60_651d_3247_2779d2e6bd57 cfff71c5_842d_825f_a41f_4e4cbd45a930["generateIdempotencyKey"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> cfff71c5_842d_825f_a41f_4e4cbd45a930 b00e0b6e_8e66_44d2_f709_c8c6bbb476c9["zip-repository.ts"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> b00e0b6e_8e66_44d2_f709_c8c6bbb476c9 bbbd3356_722d_4bf8_09d2_706412487d25["zipRepository"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> bbbd3356_722d_4bf8_09d2_706412487d25 c78d0ed7_0af5_dfcf_6bfb_aff1a1d68fb1["logger.ts"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> c78d0ed7_0af5_dfcf_6bfb_aff1a1d68fb1 222b60e9_a6a9_f11c_deba_8f76f9527fbc["fs"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 222b60e9_a6a9_f11c_deba_8f76f9527fbc 326b2a40_61be_c67e_3a48_e7ce3411f260["path"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 326b2a40_61be_c67e_3a48_e7ce3411f260 26a4bbdb_e521_8e6f_d753_d6cac9ea272c["buffer"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 --> 26a4bbdb_e521_8e6f_d753_d6cac9ea272c 919aa576_8ce8_a725_8ee0_92bce17724fa["graph-cache.test.ts"] 919aa576_8ce8_a725_8ee0_92bce17724fa --> 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 54581714_e921_5e5e_17c6_d2040cdc3b55["server.ts"] 54581714_e921_5e5e_17c6_d2040cdc3b55 --> 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 style 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* LRU Cache for indexed graphs
* Stores raw API responses + derived indexes for fast query execution
* Supports disk persistence for pre-computed graphs
*/
import { SupermodelIR, CodeGraphNode, CodeGraphRelationship } from './graph-types';
import { DEFAULT_MAX_GRAPHS, DEFAULT_MAX_NODES, DEFAULT_CACHE_TTL_MS } from '../constants';
import { ClientContext } from '../types';
import { generateIdempotencyKey } from '../utils/api-helpers';
import { zipRepository } from '../utils/zip-repository';
import { promises as fs } from 'fs';
import { join, basename } from 'path';
import { Blob } from 'buffer';
import * as logger from '../utils/logger';
// Adjacency list for traversal
interface AdjacencyList {
out: string[];
in: string[];
}
// Path index entry - what entities are defined in a file
interface PathIndexEntry {
fileId: string;
classIds: string[];
functionIds: string[];
typeIds: string[];
}
// Indexed graph structure
export interface IndexedGraph {
// Raw data
raw: SupermodelIR;
// Indexes
nodeById: Map<string, CodeGraphNode>;
labelIndex: Map<string, string[]>; // label -> node ids
pathIndex: Map<string, PathIndexEntry>; // filePath -> entities
dirIndex: Map<string, string[]>; // dir path -> child file/dir ids
nameIndex: Map<string, string[]>; // lowercase name -> node ids
callAdj: Map<string, AdjacencyList>; // function id -> callers/callees
importAdj: Map<string, AdjacencyList>; // file/module id -> imports/importers
domainIndex: Map<string, { memberIds: string[], relationships: CodeGraphRelationship[] }>;
// Precomputed
summary: {
filesProcessed: number;
classes: number;
functions: number;
types: number;
domains: number;
primaryLanguage: string;
nodeCount: number;
relationshipCount: number;
};
// Metadata
cachedAt: string;
cacheKey: string;
// ... (646 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
Imported By
Source
Frequently Asked Questions
What does graph-cache.ts do?
graph-cache.ts is a source file in the mcp codebase, written in typescript. It belongs to the GraphCache domain, LruManagement subdomain.
What functions are defined in graph-cache.ts?
graph-cache.ts defines 11 function(s): buildIndexes, detectRepo, detectRepoName, loadCacheFromDisk, normalizePath, precacheForDirectory, resolveOrFetchGraph, sanitizeFileName, saveCacheToDisk, setNoApiFallback, and 1 more.
What does graph-cache.ts depend on?
graph-cache.ts imports 12 module(s): ClientContext, api-helpers.ts, buffer, constants.ts, fs, generateIdempotencyKey, graph-types.ts, logger.ts, and 4 more.
What files import graph-cache.ts?
graph-cache.ts is imported by 5 file(s): graph-cache.test.ts, overview.ts, server.ts, symbol-context.test.ts, symbol-context.ts.
Where is graph-cache.ts in the architecture?
graph-cache.ts is located at src/cache/graph-cache.ts (domain: GraphCache, subdomain: LruManagement, directory: src/cache).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free