-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
Summary
Implement a new MCP tool detect_cycles that identifies circular dependencies in codebases using the RPG dependency graph.
Motivation
Circular dependencies are architectural smells that:
- Prevent independent compilation, testing, and reuse
- Cause changes to ripple through the entire cycle
- Make refactoring risky and expensive
Currently, the RPG system provides dependency graphs but lacks a dedicated tool to detect and report circular dependencies. Users need a way to:
- Identify cycles in their codebase
- Understand which areas/files are affected
- Filter to specific areas or cross-file/cross-area cycles
Proposed Solution
Add a new detect_cycles MCP tool with:
Core Functionality
- Detect circular dependencies using DFS algorithm
- Report statistics: total cycles, entities involved, files affected
- Break down by hierarchy area
- Filter by area, cycle length, cross-file, cross-area
Output Format
Use TOON-optimized format for LLM efficiency:
- Summary with inline objects
- Tabular area breakdown
- Compact cycle representation with file:entity chains
Funnel Design
- First call returns summary + recommendations
- Agent calls again with filters for details
- Guides LLM on next steps
Parameters
| Parameter | Type | Description |
|---|---|---|
| area | string | Filter to hierarchy area(s) |
| max_cycles | number | Limit results |
| min_cycle_length | number | Skip trivial 2-cycles |
| cross_file_only | boolean | Only cross-file cycles |
| cross_area_only | boolean | Only cross-area cycles |
| sort_by | string | Sort by length/file_count |
| include_files | boolean | Include file paths |
| ignore_rpgignore | boolean | Include ignored files |
Example Output
cycles: {total: 512, entities: 467, files: 46, areas: 8, cross_file: 152}
area_breakdown[8]{area,cycles,len2,len3,len4+,files}:
Navigation,45,20,15,10,8
Parser,38,12,14,12,6
next_step: Use area/max_cycles/cross_file_only to filter
Acceptance Criteria
- Tool detects circular dependencies in RPG graph
- Outputs TOON-optimized format
- Supports area, length, cross-file, cross-area filtering
- Provides summary with recommendations (funnel design)
- Respects .rpgignore patterns
- Includes unit tests for all filter paths
- Documented in server_instructions.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels