get_dependencies
Analyze code dependencies by identifying imports and requires for files or specific symbols to understand what external code is needed.
Instructions
Find all dependencies (imports/requires) for a file or symbol. Useful for understanding what code needs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | File path to analyze dependencies for | |
| symbol | No | Optional: specific symbol to trace dependencies for |
Implementation Reference
- src/retriever.ts:248-275 (handler)The implementation of getDependencies, which retrieves imports and (if a symbol is specified) analyzes symbol usage within the file.
async getDependencies(filePath: string, symbol?: string): Promise<any> { const fileIndex = this.indexer.getFileIndex(filePath); if (!fileIndex) { return { error: `File "${filePath}" not found in index.`, }; } const result: any = { file: filePath, imports: fileIndex.imports, importCount: fileIndex.imports.length, }; if (symbol) { // Find the symbol and analyze its dependencies const symbolObj = fileIndex.symbols.find((s) => s.name === symbol); if (symbolObj) { result.symbol = symbol; result.symbolType = symbolObj.type; result.usedSymbols = this.extractUsedSymbols(symbolObj.code, fileIndex.imports); } else { result.error = `Symbol "${symbol}" not found in ${filePath}`; } } return result; - src/index.ts:292-303 (registration)Registration of the 'get_dependencies' MCP tool.
{ name: 'get_dependencies', description: 'Find all dependencies (imports/requires) for a file or symbol. Useful for understanding what code needs.', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'File path to analyze dependencies for', }, symbol: { type: 'string',