traverse_graph
Traverse a codebase graph to analyze dependencies, impact of changes, or reachability by following specified edge types from start nodes in incoming or outgoing direction.
Instructions
Traverse the graph using BFS from start nodes, following specific edge types.
Use this for:
Impact analysis: "What's affected if I change this?" (outgoing CALLS, DEPENDS_ON)
Dependency trees: "What does this module import?" (outgoing IMPORTS_FROM)
Reverse dependencies: "Who depends on this?" (incoming DEPENDS_ON)
Reachability: "Can data flow from X to Y?" (outgoing FLOWS_INTO, ASSIGNED_FROM)
Returns nodes with depth info (0 = start, 1 = direct neighbor, 2+ = transitive).
Direction:
outgoing: Follow edges FROM start nodes (default)
incoming: Follow edges TO start nodes
Examples:
All transitive callers: traverse_graph(startNodeIds=[fnId], edgeTypes=["CALLS"], direction="incoming")
Module dependency tree: traverse_graph(startNodeIds=[modId], edgeTypes=["IMPORTS_FROM"], maxDepth=10)
Tip: Start with maxDepth=5. Use get_schema(type="edges") to find valid edge type names.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| startNodeIds | Yes | Starting node IDs (semantic IDs) | |
| edgeTypes | Yes | Edge types to follow (e.g., ["CALLS", "DEPENDS_ON"]). Use get_schema to see available types. | |
| maxDepth | No | Maximum traversal depth (default: 5, max: 20) | |
| direction | No | Traversal direction: outgoing or incoming (default: outgoing) |