Analyze Codebase Module Dependency Graph
analyze_code_dependenciesMaps module import graphs, traces symbol call chains, ranks architectural centrality, and detects dead code across polyglot repositories to reveal global dependency structure before refactoring.
Instructions
Analyzes module import graphs, symbol call chains, PageRank graph centrality, and dead code across polyglot source files, distinguishing from 'analyze_change_impact' and 'enforce_architecture_rules' by performing global dependency structure mapping rather than calculating change blast radius or verifying layer boundaries.
Parameters:
analysis_type: Structural analysis mode: 'dependencies' builds full inbound/outbound module import graph; 'call_chain' traces deep upstream callers and downstream callees; 'pagerank' computes architectural centrality rankings; 'dead_code' detects unreferenced functions and classes.project_root: Repository root directory path to scan and construct the dependency graph from.target_symbol: Specific function, method, or class name to trace when analysis_type is 'call_chain'; ignored for other modes.file_path: Optional file path to scope module dependency analysis to a single file rather than the entire repository.
Behavior:
Mutability: Strictly read-only; inspects source syntax trees without modifying, moving, or deleting files.
Idempotency: Deterministic; returns identical graph structures and rankings for the same codebase state.
Privacy & Network: 100% offline local parsing for Python, TypeScript, JavaScript, Go, Rust, Java, C#, C++; zero network calls.
Performance & Resources: Analyzes 1,000 files in <600ms consuming <60MB RAM; thread-safe.
Auth: Zero authentication or cloud credentials required.
Return Structure: Emits structured Markdown report detailing adjacency lists, Mermaid call diagrams, PageRank scores, or dead-code candidates.
Error Handling: Returns clean warning notices if target_symbol is not found in the AST index or if specified file path is missing.
Usage Guidelines:
When to use: Inspect inbound dependents, outbound dependencies, deep symbol call sequences, module importance ranks, or dead code prior to major refactoring.
When NOT to use: Do not use for calculating the blast radius score of modifying a specific function (use 'analyze_change_impact' instead); do not use for verifying compliance with layer boundary rules (use 'enforce_architecture_rules' instead).
Returns: Markdown report detailing import graphs, call chains, centrality rankings, or detected dead code.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "analyze_code_dependencies"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | Optional path to a specific file to analyze. | |
| project_root | No | Root directory of the repository to scan (default: current directory). | . |
| analysis_type | No | Type of structural analysis: 'dependencies' for module import/export graph, 'call_chain' for deep caller/callee execution trace, 'pagerank' for architectural backbone centrality, 'dead_code' for unreferenced symbols. | dependencies |
| target_symbol | No | Target class or function name when analysis_type is 'call_chain'. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |