Skip to main content
Glama

Detect Circular Dependencies

detect_circular_dependencies
Read-onlyIdempotent

Detect circular namespace dependencies in C#/.NET solutions before splitting assemblies or moving types. Returns entangled namespace cycles with projects and witness type references.

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 narrows the report, not the graph.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sessionId": "<sessionId>"
    },
    "name": "detect_circular_dependencies"
  }
}

Input Schema

NameRequiredDescriptionDefault
scopeNo'solution' (default - all cycles) 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.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. Changed1 schema field changedv0.5.46521
    • changedInput schema / properties / scope / description
      Previous value: -"'solution' (default - all cycles) or a namespace prefix to report only cycles whose members include that prefix."New value: +"'solution' (default - all cycles) 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."
  2. 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."
  3. First observed

TDQS

A4.1/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and closed-world, and the description reinforces read-only plus session-requirement context. Much of the added text is really result-shape documentation (cap of 100 cycles, ordering, witness edges, edgesTruncated) rather than behavioral traits, and it correctly warns witnesses are EXAMPLES not a work list. Useful but largely a return-value narrative.

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?

Purpose and the sibling contrast are front-loaded, followed by usage, return shape, edge derivation and interpretation. Most sentences carry unique information, but there is redundancy: "scope narrows the report, not the graph" appears both in the description and the schema, and the edge-derivation paragraph is dense relative to its value to an agent deciding to call the tool.

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?

With no output schema, the description correctly compensates by describing the return fields, their caps and their ordering, plus the meaning of a zero count under each scope. It is complete enough to call and interpret, though it spends more on result structure than on the single remaining ambiguity (what 'spansMultipleProjects' means for action).

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

Parameters3/5

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

Schema coverage is 100%, so all three parameters are documented in the schema, including the prefix-narrowing semantics of scope. The description adds one genuinely new fact outside the schema – an unknown prefix yields the same zero as a real prefix with no cycles – but otherwise restates what the schema already says. Baseline 3 fits.

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 and resource ("Detect circular NAMESPACE dependencies") and defines the object precisely as groups of namespaces depending on each other in a cycle. It explicitly positions itself against the sibling insight: "The layer-violation insight in list_insights checks the direction rule; this answers the orthogonal 'who is mutually entangled?'" and against project-reference cycles.

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 a concrete triggering situation ("Use it before splitting an assembly or moving types between namespaces") and names the sibling it is not, with the distinguishing question each answers. It also supplies when-relevant caveats: test projects excluded by default because a test->production reference is one-way, and how to interpret a zero result under each scope.

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