analyze_dependencies
Analyze and map dependencies in codebases to identify internal module relationships and external package dependencies for better project understanding.
Instructions
Analyze and map internal and external dependencies
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Root directory path | |
| include_external | No | Include external package dependencies | |
| include_internal | No | Include internal module dependencies | |
| max_depth | No | Maximum dependency depth to traverse |
Implementation Reference
- src/tools/analyze-dependencies.ts:47-100 (handler)Core handler function that executes the analyze_dependencies tool: destructures args, initializes dependency graph, analyzes external/internal deps, detects cycles, enriches with KG, stores RDF, formats markdown results.export async function analyzeDependencies( args: AnalyzeDependenciesArgs ): Promise<{ content: Array<{ type: string; text: string }> }> { const { path, include_external = true, include_internal = true, max_depth = 5, } = args; const graph: DependencyGraph = { nodes: new Map(), edges: [], circular: [], orphans: [], stats: { total_external: 0, total_internal: 0, max_depth: 0, circular_count: 0, }, }; // Analyze external dependencies (from package.json) if (include_external) { await analyzeExternalDependencies(path, graph); } // Analyze internal dependencies (import/require statements) if (include_internal) { await analyzeInternalDependencies(path, graph, max_depth); } // Detect circular dependencies detectCircularDependencies(graph); // Enrich with knowledge graph await enrichDependenciesWithKG(graph); // Store in database as RDF triples await storeDependencyGraph(graph); // Format results const results = formatDependencyResults(graph); return { content: [ { type: 'text', text: results, }, ], }; }
- TypeScript interface defining input parameters for the analyze_dependencies tool handler.interface AnalyzeDependenciesArgs { path: string; include_external?: boolean; include_internal?: boolean; max_depth?: number; }
- src/tools/index.ts:52-53 (registration)Registration of analyze_dependencies tool in the CallToolRequestSchema switch dispatcher: imports and calls the handler function.case "analyze_dependencies": return await analyzeDependencies(args as any);
- src/index.ts:223-251 (registration)Tool registration in ListToolsRequestSchema response: defines name, description, and inputSchema for analyze_dependencies.{ name: "analyze_dependencies", description: "Analyze and map internal and external dependencies", inputSchema: { type: "object", properties: { path: { type: "string", description: "Root directory path", }, include_external: { type: "boolean", description: "Include external package dependencies", default: true, }, include_internal: { type: "boolean", description: "Include internal module dependencies", default: true, }, max_depth: { type: "number", description: "Maximum dependency depth to traverse", default: 5, }, }, required: ["path"], }, },
- Compiled TypeScript declaration for AnalyzeDependenciesArgs interface (schema).interface AnalyzeDependenciesArgs { path: string; include_external?: boolean; include_internal?: boolean; max_depth?: number; } export declare function analyzeDependencies(args: AnalyzeDependenciesArgs): Promise<{ content: Array<{ type: string; text: string; }>; }>; export {}; //# sourceMappingURL=analyze-dependencies.d.ts.map