Stellarion
Tools

stellarion_get_dependency_graph

Map file and module import relationships with depth control

Analyzes file-level import and dependency relationships. Shows what a file imports, what imports it, or both -- traversing multiple levels to reveal the full module dependency structure.

When to Use

  • Understanding module architecture and how files relate
  • Finding circular dependencies between modules
  • Planning refactoring to reduce coupling
  • Tracing import chains to understand why a module is included
  • Assessing the scope of a module's influence

This tool operates at the file/module level. For function-level call relationships, use stellarion_get_call_graph instead.

Parameters

ParameterTypeRequiredDefaultDescription
uristringYes--File URI to analyze (e.g., file:///path/to/file.ts)
depthnumberNo3How many levels of dependencies to traverse (1-10)
includeExternalbooleanNofalseWhether to include external dependencies from node_modules or packages
directionenumNobothimports (what this file uses), importedBy (what uses this file), or both
summarybooleanNofalseReturn a condensed summary for large graphs

Examples

Full Dependency Map

Natural Language: "Show me all the dependencies of the auth module"

MCP Tool Call:

{
  "name": "stellarion_get_dependency_graph",
  "arguments": {
    "uri": "file:///home/dev/project/src/auth/index.ts",
    "depth": 3,
    "direction": "both"
  }
}

Returns: A graph showing the auth module's imports (crypto, database, config) and everything that imports it (routes, middleware, tests), traversed 3 levels deep.

Find Consumers of a Module

Natural Language: "What files depend on the database connection module?"

MCP Tool Call:

{
  "name": "stellarion_get_dependency_graph",
  "arguments": {
    "uri": "file:///home/dev/project/src/db/connection.py",
    "depth": 2,
    "direction": "importedBy"
  }
}

Returns: All files that import the database connection module, plus files that import those files, showing the full consumer chain.

Include External Dependencies

Natural Language: "What external libraries does this file use?"

MCP Tool Call:

{
  "name": "stellarion_get_dependency_graph",
  "arguments": {
    "uri": "file:///home/dev/project/src/api/client.ts",
    "depth": 1,
    "includeExternal": true,
    "direction": "imports"
  }
}

Returns: Both internal imports (utils, config) and external packages (axios, lodash, zod) used by this file.

Output Format

The response is a graph structure containing:

  • nodes -- Each node represents a file/module with its path and metadata.
  • edges -- Each edge represents an import relationship with source (importer) and target (imported) references.
  • root -- The node ID of the file you queried.
  • cycles -- Any circular dependency paths detected in the traversal.

Tips

  • Start with direction: "importedBy" before modifying a module to see everything that depends on it. This is the module-level equivalent of impact analysis.
  • Set depth: 1 for a quick view of direct relationships. Increase depth to trace longer import chains.
  • Leave includeExternal: false (default) when you only care about your own code's structure. Set it to true when auditing third-party dependency usage.
  • Circular dependencies show up in the cycles field. Use stellarion_analyze_coupling (Pro) for deeper coupling metrics including instability scores.
  • For function-level "who calls what" analysis, use stellarion_get_call_graph instead. Dependency graphs show file-level imports, not runtime call relationships.