graph_detectCycles
Detect circular dependencies in dependency graphs to validate DAG integrity, identify circular references, and debug topological sorts. Uses SQL fetch and iterative DFS.
Instructions
Detect circular dependencies (cycles) in the dependency graph.
Pure-Python implementation — no stored procedure required. Issues a single SQL SELECT to fetch the scoped edge set, then performs WCC partitioning followed by iterative DFS cycle detection entirely in the MCP server process.
Use this tool for:
Validating graph integrity (DAG property)
Finding objects that form circular references
Identifying stub-then-replace code patterns
Debugging topological sort hangs
Pre-deployment cycle checks
Arguments: container_pattern - str: CSV LIKE patterns for container scope. Supports wildcards (%) and CSV format. Examples: 'DFJ%' — single database family '%WBC%,%StGeo%' — multiple families 'DEV01_%,DEV02_%' — multiple prefixes
exclude_objects - str: CSV LIKE patterns to exclude from the scan. Matches against container name (or DB.Object if the pattern contains a dot). Default: '' (no exclusions)
edge_repository - str: Edge repository view/table conforming to the Graph Edge Contract (Src_Container_Name, Src_Object_Name, Src_Kind, Tgt_Container_Name, Tgt_Object_Name, Tgt_Kind columns). For AI-Native Data Products use: '{ProductName}_Semantic.lineage_graph' Call graph_edgeContractDDL to generate a new one. Required — no default.
Returns: ResponseType: formatted response with cycle detection results.
Response structure: { "cycle_details": [...], // One row per node per cycle "cycle_summaries": [...], // One row per cycle with path string "summary_stats": [...] // Single aggregate row }
cycle_details row fields: Cycle_Id, Cycle_Pos, Node_FQ, Cycle_Length, Component_Id
cycle_summaries row fields: Cycle_Id, Cycle_Length, Component_Id, Cycle_Path
summary_stats row fields: Cycle_Count, Total_Nodes_In_Cycles, Components_With_Cycles, Edge_Count, Components_Scanned, Summary_Message
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| container_pattern | Yes | ||
| exclude_objects | No | ||
| edge_repository | No |