Skip to main content
Glama

cgis_get_structure

Show the containment hierarchy of a module, class, or package. Get members or held modules as an indented tree, Mermaid diagram, or JSON payload.

Instructions

Members of a module or class — or, for a package prefix, the modules it holds.

Follows containment (CONTAINS/DECLARES) only, so no call or import appears.
A package is not a node in the graph (#487), so its row and the edges to its
modules are synthesized for the answer and marked with a virtual file path.
For how the code connects use ``cgis_trace_flow`` (what it depends on) or
``cgis_analyze_impact`` (what depends on it).

Matches the CLI ``structure`` command. ``output_format="text"`` returns the
hierarchy as an indented tree, one line per member; ``"mermaid"`` (default) a
diagram of the hierarchy rooted at the given FQN; ``"json"`` the
joinable ``{root, nodes, edges}`` payload with real FQNs.

Input Schema

NameRequiredDescriptionDefault
fqnYesFully qualified name, e.g. pkg.module.Class.method. A unique dot-boundary suffix also resolves; an ambiguous one returns candidates. Use cgis_find_symbol to look a name up.
depthNoMaximum containment levels to descend (module → class → method).
db_pathNoSQLite graph built by cgis_ingest. A relative path resolves against the MCP server's working directory, not the agent's — prefer an absolute path.graph.db
output_formatNo"text" for an indented tree, one line per node — the cheapest to read; "mermaid" for a diagram; or "json" for a payload with real FQNs, to compute with (case-insensitive). Any other value returns an error.mermaid

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.21.12
    • changedInput schema / properties / output_format / description
      Previous value: -"\"mermaid\" for a diagram, or \"json\" for a payload with real FQNs (case-insensitive). Any other value returns an error."New value: +"\"text\" for an indented tree, one line per node — the cheapest to read; \"mermaid\" for a diagram; or \"json\" for a payload with real FQNs, to compute with (case-insensitive). Any other value returns an error."
  2. Changed4 schema fields changedv0.21.1
    • addedInput schema / properties / db_path / description
      Added value: +"SQLite graph built by cgis_ingest. A relative path resolves against the MCP server's working directory, not the agent's — prefer an absolute path."
    • addedInput schema / properties / depth / description
      Added value: +"Maximum containment levels to descend (module → class → method)."
    • addedInput schema / properties / fqn / description
      Added value: +"Fully qualified name, e.g. pkg.module.Class.method. A unique dot-boundary suffix also resolves; an ambiguous one returns candidates. Use cgis_find_symbol to look a name up."
    • addedInput schema / properties / output_format / description
      Added value: +"\"mermaid\" for a diagram, or \"json\" for a payload with real FQNs (case-insensitive). Any other value returns an error."
  3. First observedv0.21.0

TDQS

A4.6/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so well: it discloses that only CONTAINS/DECLARES edges appear, that packages are not real graph nodes (#487) so their rows and edges are synthesized and marked with a virtual file path. These are exactly the non-obvious behaviors an agent 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?

Purpose is front-loaded, followed by containment caveats, routing guidance, and format notes in a logical order. It is slightly verbose in re-describing output_format, which the schema already covers, but no sentence is truly wasted.

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?

An output schema exists, so return-shape explanation is unnecessary, and the description still covers containment semantics, package virtualization, and format choices. Combined with 100% schema coverage, an agent has everything needed to call it correctly.

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 description coverage is 100%, so the schema already documents fqn, depth, db_path, and output_format. The description's output_format gloss largely restates the schema entry rather than adding syntax or format detail beyond it, so the baseline 3 applies.

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?

The opening sentence states a specific verb and resource: the members of a module or class, or the modules held by a package prefix. It distinguishes itself from siblings by explicitly noting it follows containment only, and names the alternatives for connectivity queries.

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?

It routes the agent explicitly: use cgis_trace_flow for what the code depends on and cgis_analyze_impact for what depends on it, leaving no inference about when not to use this tool. The CLI parity note ('Matches the CLI structure command') further anchors context.

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