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 or set CI complexity budgets.

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. Optional symbol substring filters to a specific function or set of functions; top limits the report (default: 20; 0 = all). 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.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "gograph_complexity"
  }
}

Input Schema

NameRequiredDescriptionDefault
topNoNumber of results to return, highest first (default: 20, 0 = all)
pathNoKeep functions in this repository-relative directory subtree
rootNoAbsolute path of your checkout or worktree (alias cwd).
symbolNoOptional Go function or method symbol name substring to filter the complexity report (e.g., 'Build')
no_testsNoDrop functions declared in _test.go files
intentionNoRationale; required with an active session.
session_idNoSession from session_create; omit for none.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv1.7.21
    • changedInput schema / properties / intention / description
      Previous value: -"Technical rationale, required for analytical calls selecting an active session."New value: +"Rationale; required with an active session."
    • addedInput schema / properties / no_tests
      Added value: +{
      +  "description": "Drop functions declared in _test.go files",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / path
      Added value: +{
      +  "description": "Keep functions in this repository-relative directory subtree",
      +  "type": "string"
      +}
    • changedInput schema / properties / root / description
      Previous value: -"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."New value: +"Absolute path of your checkout or worktree (alias cwd)."
    • changedInput schema / properties / session_id / description
      Previous value: -"Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session."New value: +"Session from session_create; omit for none."
    • addedInput schema / properties / top
      Added value: +{
      +  "description": "Number of results to return, highest first (default: 20, 0 = all)",
      +  "type": "integer"
      +}
  2. 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"
      +}
  3. Addedv1.5.3
  4. Removedv1.5.3
  5. 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')"
  6. First observedv1.0.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, non-destructive, and closed-world, so the safety profile is covered. The description adds real behavioral value beyond that: the UNKNOWN/-1 handling for unreadable or unparsable sources, and the empty-result case. It does not discuss permission/session requirements, though the schema hints at session_id.

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?

Front-loaded with the core purpose, then cleanly segmented into WHEN TO USE / NOT TO USE / RETURNS blocks. Every sentence carries information (severity labels, edge-case score, filter semantics, return shape) with no filler.

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?

Despite no output schema, the RETURNS section describes the structured list shape and the empty-result case. For a read-only reporting tool with annotated safety and fully documented parameters, nothing an agent needs to invoke it 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 schema already documents all seven parameters, establishing a baseline of 3. The description reinforces `symbol` as a substring filter and `top` defaults (20, 0 = all), but adds no semantics the schema doesn't already state.

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 first sentence names a specific verb and resource ('Report estimated cyclomatic complexity for Go functions') plus the output ordering and severity labeling. The NOT TO USE clause explicitly disambiguates it from gograph_coupling, gograph_deps, and gograph_godobj, so an agent can route without opening any 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?

States concrete use cases ('code quality audits', 'identifying functions that need decomposition', 'complexity budgets in CI') and explicitly names the sibling tools to use instead for adjacent needs. When-to-use and when-not-to-use are both covered with named alternatives.

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