Skip to main content
Glama

Detect Circular Dependencies

detect_circular_dependencies
Read-onlyIdempotent

Detect circular namespace dependencies in a C# solution before splitting an assembly or moving types, revealing mutually entangled namespaces in a cycle.

Instructions

Detect circular NAMESPACE dependencies: groups of namespaces that depend on each other in a cycle - a modularity smell the compiler allows, unlike project-reference cycles. The layer-violation insight in list_insights checks the direction rule; this answers the orthogonal 'who is mutually entangled?'.

Use it before splitting an assembly or moving types between namespaces.

Returns scope, namespacesScanned, cyclesFound and cycles, at most 100. Each cycle is a strongly connected component of two or more namespaces and carries namespaces, size, projects, spansMultipleProjects, edgeCount, edgesTruncated and edges: one 'witness' type -> type reference per directed namespace pair (fromNamespace, toNamespace, fromType, toType, typeEdgeCount). Read the witnesses as EXAMPLES, not as a work list: edgeCount counts directed namespace pairs, and typeEdgeCount says how many distinct type references cross that one boundary. Where it is above 1, removing the shown reference leaves the edge standing. Cycles that span assemblies come first, then the largest. Witness edges are capped per cycle, and edgesTruncated says when; the namespace list is complete. A cycle inside one assembly is namespace organisation; one that spans assemblies means a namespace is reused across DLL boundaries.

Edges come from the type references a type's facts record by full name - member, field, parameter, return and typeof types, base class and interfaces among them - so a same-named type in two namespaces is never conflated, and external references are ignored.

cyclesFound 0 under scope 'solution' means no cycle among the scanned namespaces. Under a prefix it only means no cycle touches a namespace starting with that text, and an unknown prefix answers the same zero.

Read-only; works on a recalled session. Test projects are excluded by default (includeTests=true includes them). scope is 'solution' or a plain case-insensitive namespace prefix: it narrows the report, not the graph, and returns a whole cycle when one of its namespaces matches.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scopeNo'solution' (default - all cycles) or a namespace prefix to report only cycles whose members include that prefix.solution
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.
includeTestsNoInclude test projects (default FALSE - production focus: a test->production reference is one-way and not an architecture cycle). Set true to include them.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.5.46513
    • changedInput schema / properties / includeTests / description
      Previous value: -"Include test projects (default FALSE - production focus: a test->production reference is one-way and not an architecture cycle). Set true to include *.Tests/*.Spec projects."New value: +"Include test projects (default FALSE - production focus: a test->production reference is one-way and not an architecture cycle). Set true to include them."
    • changedInput schema / properties / sessionId / description
      Previous value: -"The session_id returned by analyze_solution."New value: +"The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use."
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already establish read-only/idempotent, but the description goes well beyond them: it discloses the 100-cycle cap, ordering (solution-spanning first, then largest), witness edges being EXAMPLES not a work list, edgeCount/typeEdgeCount semantics, edgesTruncated capping (with the namespace list still complete), and how edges are derived from recorded type facts. This is exactly the extra behavioural context a caller needs.

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 purpose in the first clause, then alternatives, then return semantics. It is long, and the witness-edge paragraph is dense, but with no output schema every sentence is doing load-bearing work; only minor tightening is possible.

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

Completeness5/5

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

No output schema exists, so the description must carry return semantics and it does: field list, caps, ordering, truncation flag, and the interpretation rule for a zero count under each scope. Combined with annotations covering safety, an agent has everything needed to call and read this correctly.

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 the baseline is 3, but the description genuinely adds meaning: scope 'narrows the report, not the graph' and returns a whole cycle when any member matches the prefix; includeTests is justified (test->production is one-way, not an architecture cycle); sessionId accepts a .sln/.slnx/.slnf path analyzed on first use. This exceeds what the schema alone conveys.

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

Purpose5/5

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

States a specific verb+resource ('Detect circular NAMESPACE dependencies') and immediately scopes it as cycles among groups of namespaces, explicitly contrasting with the 'layer-violation insight in list_insights'. An agent can distinguish it from that sibling and from other architecture tools without opening the schema.

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

Usage Guidelines5/5

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

Gives an explicit trigger ('Use it before splitting an assembly or moving types between namespaces') and a precise division of labour with list_insights (direction rule vs mutual entanglement). It also explains the interpretation of results under each scope value, including that an unknown prefix likewise answers zero, which is real guidance, not just context.

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