Skip to main content
Glama

gograph_complexity

Read-onlyIdempotent

Report estimated cyclomatic complexity for Go functions, sorted highest-to-lowest with severity labels, to find functions needing decomposition and set complexity budgets in CI.

Instructions

Report estimated cyclomatic complexity for Go functions, sorted highest-to-lowest with severity labels (LOW/MEDIUM/HIGH/VERY HIGH). A function whose repository source cannot be read or parsed safely is retained as UNKNOWN with score -1. The MCP server checks freshness before this call and refreshes in the current requested analysis mode; precise and precise_fallback graphs retry CHA/SSA after source changes. Read-only; no side effects. Optional symbol substring filters to a specific function or set of functions. WHEN TO USE: During code quality audits, identifying functions that need decomposition, or setting complexity budgets in CI. NOT TO USE: For import dependency metrics (use gograph_coupling or gograph_deps); for God Object detection (use gograph_godobj). RETURNS: Structured list of functions with complexity score and severity label; empty when no functions match the filter.

Input Schema

NameRequiredDescriptionDefault
rootNoAbsolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean.
symbolNoOptional Go function or method symbol name substring to filter the complexity report (e.g., 'Build')
intentionNoTechnical rationale, required for analytical calls selecting an active session.
session_idNoCaller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.7.18
    • addedInput schema / properties / intention
      Added value: +{
      +  "description": "Technical rationale, required for analytical calls selecting an active session.",
      +  "type": "string"
      +}
    • addedInput schema / properties / root
      Added value: +{
      +  "description": "Absolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean.",
      +  "type": "string"
      +}
    • addedInput schema / properties / session_id
      Added value: +{
      +  "description": "Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session.",
      +  "type": "string"
      +}
  2. Addedv1.5.3
  3. Removedv1.5.3
  4. Changed1 schema field changedv1.4.70
    • changedInput schema / properties / symbol / description
      Previous value: -"Optional symbol name substring to filter results"New value: +"Optional Go function or method symbol name substring to filter the complexity report (e.g., 'Build')"
  5. First observedv1.0.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint and destructiveHint=false, so the safety profile is covered; the description goes well beyond that by disclosing sort order, the severity taxonomy, the UNKNOWN/-1 sentinel for unreadable or unparseable repository source, and a freshness check with refresh plus CHA/SSA retry under precise/precise_fallback modes. These are non-obvious behaviors an agent could not infer from the annotations, and none of them contradict the declared read-only, idempotent nature.

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?

The description is well front-loaded: purpose, then the UNKNOWN edge case, then WHEN/NOT TO USE and RETURNS blocks. The one soft spot is the dense mid-paragraph sentence about freshness checking and CHA/SSA retry, which packs internal implementation jargon into a run-on clause that an agent must parse to extract the actionable point (results are fresh and safe to trust).

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?

With no output schema, the description carries the return contract and does so: a structured list of functions with complexity score and severity label, sorted descending, empty when the filter matches nothing, plus the -1/UNKNOWN sentinel. Given four optional parameters, full schema coverage, and complete safety annotations, nothing an agent needs in order to call this correctly is missing.

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 baseline is 3 per the rubric. The description restates the `symbol` substring behavior ('filters to a specific function or set of functions') without adding format or matching semantics beyond what the schema already says, and it never mentions `root`, `intention`, or `session_id`, leaving those entirely to the schema — which does document them adequately.

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 names a specific verb and resource — 'Report estimated cyclomatic complexity for Go functions' — and immediately states the output ordering and severity labeling. The NOT TO USE block names the exact siblings to route away to (gograph_coupling, gograph_deps for import metrics; gograph_godobj for God Objects), so an agent can separate this tool from a large family of similarly named gograph_* tools without opening a 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?

The description provides an explicit WHEN TO USE list (quality audits, decomposition candidates, CI complexity budgets) and an explicit NOT TO USE list with the alternative tool named for each excluded case. This is the strongest form of routing guidance: both the positive trigger and the negative trigger are stated, leaving little to inference.

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