Skip to content

Graph Analysis Tools

Graph tools help AI assistants understand how code connects—function calls, imports, dependencies, and architectural boundaries.

Tools in This Category

Tool Description Tier
get_call_graph Build function call graphs Community
get_project_map High-level project structure Community
get_graph_neighborhood K-hop graph traversal Pro
get_cross_file_dependencies Cross-file import chains Pro

get_call_graph

Build a graph showing how functions call each other.

What It Does

get_call_graph analyzes function relationships:

  • Call relationships: Who calls whom
  • Entry points: main(), CLI commands, route handlers
  • Mermaid diagrams: Visual call flow
  • Circular detection: Find circular import issues
  • Path queries: Find paths between functions (Pro+)

When AI Agents Use This

  • Understanding code flow
  • Impact analysis before changes
  • Finding entry points
  • Detecting circular dependencies

Quick Reference

Property Value
Tier Community (limited), Pro (full)
Languages Python
Token Cost ~200-1000 tokens

Parameters

Parameter Type Required Description
project_root string Project root directory
entry_point string Starting function (e.g., "main.py:main")
depth int Max traversal depth (default: 10)
include_circular_import_check bool Check for circular imports (default: true)
paths_from string Source for path query (Pro+)
paths_to string Destination for path query (Pro+)

Example Usage

Prompt:

"Show me how functions connect in this project"

Tool Call:

{
  "tool": "get_call_graph",
  "parameters": {
    "project_root": "/path/to/project"
  }
}

Prompt:

"Trace all calls starting from main()"

Tool Call:

{
  "tool": "get_call_graph",
  "parameters": {
    "project_root": "/path/to/project",
    "entry_point": "main.py:main",
    "depth": 5
  }
}

Prompt:

"How does user input reach the database?"

Tool Call:

{
  "tool": "get_call_graph",
  "parameters": {
    "project_root": "/path/to/project",
    "paths_from": "routes.py:handle_request",
    "paths_to": "db.py:execute_query"
  }
}

Response Format

{
  "data": {
    "nodes": [
      {
        "id": "main.py:main",
        "name": "main",
        "file": "main.py",
        "line": 10,
        "is_entry_point": true
      },
      {
        "id": "utils.py:process",
        "name": "process",
        "file": "utils.py",
        "line": 25,
        "is_entry_point": false
      }
    ],
    "edges": [
      {
        "from": "main.py:main",
        "to": "utils.py:process",
        "confidence": 1.0,
        "context": {
          "in_loop": false,
          "in_conditional": true
        }
      }
    ],
    "entry_points": ["main.py:main"],
    "circular_imports": [],
    "diagram": "graph TD\n  main.py:main --> utils.py:process"
  },
  "tier_applied": "community",
  "max_depth_applied": 3,
  "max_nodes_applied": 50,
  "duration_ms": 450
}

Tier Differences

Feature Community Pro Enterprise
Max depth 3 50 Unlimited
Max nodes 50 500 Unlimited
Mermaid diagrams
Circular import check
Path queries
Focus mode
Call context
Graph query language

Full deep dive


get_project_map

Get a high-level overview of project structure.

What It Does

get_project_map provides a bird's-eye view:

  • Package structure: Modules and their organization
  • Function/class inventory: Per-file counts
  • Complexity hotspots: Files needing attention
  • Entry point detection: main, CLI, routes
  • Mermaid diagrams: Project structure visualization

When AI Agents Use This

  • First look at a new project
  • Understanding project organization
  • Finding where to make changes
  • Identifying complex areas

Quick Reference

Property Value
Tier Community (100 files), Pro (1000), Enterprise (unlimited)
Languages Python (primary), others detected
Token Cost ~200-800 tokens

Parameters

Parameter Type Required Description
project_root string Project root directory
include_complexity bool Calculate complexity (default: true)
complexity_threshold int Hotspot threshold (default: 10)
include_circular_check bool Check circular imports (default: true)

Example Usage

Prompt:

"Give me an overview of this project's structure"

Tool Call:

{
  "tool": "get_project_map",
  "parameters": {
    "project_root": "/path/to/project"
  }
}

Response Format

{
  "data": {
    "packages": [
      {
        "name": "src",
        "path": "src/",
        "modules": ["main", "utils", "models", "api"]
      },
      {
        "name": "src.api",
        "path": "src/api/",
        "modules": ["routes", "handlers", "middleware"]
      }
    ],
    "summary": {
      "total_packages": 5,
      "total_modules": 23,
      "total_functions": 156,
      "total_classes": 34,
      "total_lines": 4500
    },
    "entry_points": [
      {"file": "src/main.py", "function": "main", "type": "cli"},
      {"file": "src/api/routes.py", "function": "app", "type": "flask"}
    ],
    "hotspots": [
      {"file": "src/utils/parser.py", "complexity": 45, "reason": "Many branches"}
    ],
    "circular_imports": [],
    "diagram": "graph TD\n  src --> src.api\n  src --> src.models"
  },
  "tier_applied": "community",
  "duration_ms": 890
}

Tier Differences

Feature Community Pro Enterprise
Max files 100 1,000 Unlimited
Complexity analysis
Entry point detection
Circular import check
Service boundary detection
Historical trends

Full deep dive


get_graph_neighborhood

Extract a focused subgraph around a specific node.

What It Does

get_graph_neighborhood prevents graph explosion on large codebases:

  • K-hop extraction: Get nodes within K hops of center
  • Directional filtering: Incoming, outgoing, or both
  • Confidence filtering: Only high-confidence edges
  • Truncation protection: Warns if graph was cut off

When AI Agents Use This

  • Focused analysis on specific function
  • Understanding a function's context
  • Avoiding memory issues on large graphs
  • Targeted refactoring analysis

Quick Reference

Property Value
Tier Pro
Languages Python
Token Cost ~100-500 tokens

Parameters

Parameter Type Required Description
center_node_id string Node ID (e.g., "python::module::function::name")
k int Hops from center (default: 2)
max_nodes int Max nodes to include (default: 100)
direction string "outgoing", "incoming", "both" (default: "both")
min_confidence float Min edge confidence (default: 0.0)
project_root string Project root directory

Example Usage

Prompt:

"Show me what's connected to the process_order function"

Tool Call:

{
  "tool": "get_graph_neighborhood",
  "parameters": {
    "center_node_id": "python::orders::function::process_order",
    "k": 2,
    "max_nodes": 50
  }
}

Response Format

{
  "data": {
    "center_node": "python::orders::function::process_order",
    "nodes": [
      {"id": "python::orders::function::process_order", "depth": 0},
      {"id": "python::models::class::Order", "depth": 1},
      {"id": "python::db::function::save", "depth": 1},
      {"id": "python::notifications::function::send_email", "depth": 2}
    ],
    "edges": [
      {"from": "process_order", "to": "Order", "type": "instantiates"},
      {"from": "process_order", "to": "save", "type": "calls"},
      {"from": "process_order", "to": "send_email", "type": "calls"}
    ],
    "truncated": false,
    "diagram": "graph TD\n  process_order --> Order\n  process_order --> save\n  process_order --> send_email"
  },
  "tier_applied": "pro",
  "duration_ms": 234
}

Full deep dive


get_cross_file_dependencies

Analyze import chains and dependencies across files.

What It Does

get_cross_file_dependencies traces how code depends on other files:

  • Import resolution: Follows imports to their sources
  • Dependency chain: Complete chain with confidence
  • Combined code: All dependent code in one response
  • Circular detection: Finds import cycles

When AI Agents Use This

  • Understanding what a function needs
  • Preparing for extraction with deps
  • Refactoring impact analysis
  • Detecting circular imports

Quick Reference

Property Value
Tier Pro
Languages Python
Token Cost ~200-1000 tokens

Parameters

Parameter Type Required Description
target_file string File containing the symbol
target_symbol string Symbol to analyze
project_root string Project root
max_depth int Max resolution depth (default: 3)
include_code bool Include source code (default: true)
include_diagram bool Include Mermaid diagram (default: true)
confidence_decay_factor float Confidence decay per depth (default: 0.9)

Example Usage

Prompt:

"What are all the dependencies of process_order?"

Tool Call:

{
  "tool": "get_cross_file_dependencies",
  "parameters": {
    "target_file": "src/services/orders.py",
    "target_symbol": "process_order",
    "max_depth": 3
  }
}

Response Format

{
  "data": {
    "target_symbol": "process_order",
    "target_file": "src/services/orders.py",
    "dependencies": [
      {
        "symbol": "Order",
        "file": "src/models/order.py",
        "depth": 1,
        "confidence": 0.9,
        "code": "class Order:\n    ..."
      },
      {
        "symbol": "Database",
        "file": "src/db/connection.py",
        "depth": 2,
        "confidence": 0.81,
        "code": "class Database:\n    ..."
      }
    ],
    "circular_imports": [],
    "combined_code": "# From src/models/order.py\nclass Order:\n    ...\n\n# From src/db/connection.py\nclass Database:\n    ...",
    "low_confidence_count": 0,
    "diagram": "graph TD\n  process_order --> Order\n  Order --> Database"
  },
  "tier_applied": "pro",
  "duration_ms": 567
}

Confidence Decay

Dependencies further from the target have lower confidence:

Depth Confidence (0.9 decay)
0 1.000 (target)
1 0.900
2 0.810
3 0.729

Dependencies below 0.5 confidence are flagged as "low confidence."

Full deep dive


Common Patterns

Understanding New Codebase

1. get_project_map()
   → High-level structure

2. get_call_graph(entry_point="main.py:main")
   → How code flows from entry

3. get_graph_neighborhood(center_node="interesting_function")
   → Focus on specific area

Impact Analysis

1. get_call_graph(paths_to="function_to_change")
   → Who calls this function?

2. get_cross_file_dependencies(target_symbol="function_to_change")
   → What does it depend on?