Skip to main content
Glama

get_circular_imports

Read-onlyIdempotent

Detect circular dependency chains in code imports to refactor and eliminate cycles. Excludes test files by default to avoid spurious cycles.

Instructions

Find circular dependency chains in the import graph (Kosaraju SCC algorithm). Considers only import-typed edges (esm_imports / imports / py_imports / py_reexports); call, reference, member_of, and test_covers edges are NOT walked. Test files (paths matching tests/**, **/.test., **/.spec., /tests/) are excluded by default to suppress spurious test↔source cycles — pass include_tests: true to opt in. Use to detect and break dependency cycles. Read-only. Returns JSON: { total_cycles, cycles: [{ files, length }] }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_testsNoInclude test files in cycle detection. Default false — paths matching tests/**, **/*.test.*, **/*.spec.*, **/__tests__/** are excluded because they routinely produce spurious cycles (test imports source, while an indexer scan adds a reverse imports edge into the fixture).
Behavior5/5

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

Beyond annotations (readOnly, idempotent, non-destructive), the description adds algorithmic detail (Kosaraju), clarifies edge types not walked (call, reference, etc.), and explains test file exclusion behavior. No contradiction with annotations.

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

Conciseness5/5

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

Three sentences cover purpose, constraints, use case, and output format. No redundant information, every sentence adds value. Front-loaded with key action and algorithm.

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?

For a simple tool with one optional parameter and no output schema, the description is fully complete: it explains the algorithm, edge types, test exclusion logic, return structure, and typical use case. No gaps.

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

Parameters5/5

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

The single parameter 'include_tests' is fully described in both the schema and the description. The description adds context about why tests are excluded (spurious cycles) and the specific path patterns, enhancing understanding beyond the schema alone.

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?

Clearly states the tool finds circular dependency chains using the Kosaraju SCC algorithm, specifies the resource (import graph) and the scope (only import edges). It differentiates from siblings like get_import_graph and get_dependency_diagram by its specific purpose and constraints.

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?

Explicitly says 'Use to detect and break dependency cycles.' Provides clear context on when to use, what edges are considered, and why test files are excluded by default with an opt-in option. Offers rationale for the exclusion, aiding agent decision-making.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nikolai-vysotskyi/trace-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server