Skip to main content
Glama

find_circular_dependencies

Detect circular dependencies between Java packages and report cycle paths and affected packages. Filter by package prefix or limit cycle length after loading a project.

Instructions

Detect cycles in packages.

USAGE: find_circular_dependencies() USAGE: find_circular_dependencies(packageFilter="com.example") OUTPUT: List of circular dependency cycles

Uses Tarjan's SCC algorithm to efficiently detect all cycles. Reports cycle paths and affected packages.

maxCycleLength, the most packages a reported cycle joins, is 2 or more (a cycle joins at least two packages); below 2 is INVALID_PARAMETER.

Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
packageFilterNoPackage prefix to analyze (default: all project packages)
maxCycleLengthNoMaximum cycle length to report, 2 or more (default: 10)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.5.3
    • changedInput schema / properties / maxCycleLength / description
      Previous value: -"Maximum cycle length to report (default: 10)"New value: +"Maximum cycle length to report, 2 or more (default: 10)"
  2. Addedv1.3.4
  3. Removedv1.3.3
  4. First observedv1.2.0

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden and does well: it discloses the algorithm (Tarjan's SCC), what the output contains (cycle paths and affected packages), and the specific failure mode for maxCycleLength < 2 (INVALID_PARAMETER). It omits scale/performance characteristics and behavior when the project has no cycles.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the verb+resource, then labeled USAGE/OUTPUT blocks and a prerequisite line — easy to scan. Minor redundancy between "Detect cycles" and "circular dependency cycles," but nothing wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by describing the return value (list of cycles with paths and affected packages). Combined with the prerequisite and validation rule, an agent has what it needs; only edge-case behavior (empty results, project size limits) is unspecified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds real semantics beyond the schema: what maxCycleLength actually bounds ("the most packages a reported cycle joins") and a usage example showing packageFilter as a prefix. This goes past restating field descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: detect cycles / circular dependency cycles in packages. The purpose is unambiguous and clearly distinct from graph-oriented siblings like get_dependency_graph or find_unused_code, though it never names those alternatives explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides two concrete invocation patterns (bare and with packageFilter) and a hard prerequisite: "Requires load_project to be called first." It does not state when to prefer this over e.g. get_dependency_graph, so no 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.