Skip to main content
Glama

Measure Method Complexity

symbol_metrics
Read-onlyIdempotent

Reports cyclomatic and cognitive complexity plus parameter count for a named C# method, or ranks methods to locate complexity hotspots before code changes.

Instructions

Report method complexity: McCabe CYCLOMATIC complexity (independent paths) and COGNITIVE complexity (how hard the method is to follow: nesting is penalised, boolean-operator runs collapse), plus the parameter count - for one method by name, or as a hotspot ranking. solution_metrics gives the solution-wide rollup.

Use it before touching an unfamiliar method, and to find where the complexity sits. Both metrics measure CODE SHAPE, not runtime cost; for a hot path use a profiler.

With symbol (mode 'symbol'): every method unit of that name (bare or 'Type.Member', see the parameter). scope, includeTests, minComplexity and rankByCognitive are ignored. Accessors, constructors and operators answer by metadata name ('get_Items', '.ctor', 'op_Equality'); '.ctor' is every constructor unit of the solution, 'Type..ctor' one type's. Without symbol (mode 'ranked'): methods only, sorted by cyclomatic complexity descending - by cognitive with rankByCognitive=true - and filtered to complexity >= minComplexity (inclusive; 0 = no floor).

Returns scope, mode, metricMeaning, minComplexity, methodsScanned, methods - at most 200 items (name, declaringType, namespace, cyclomaticComplexity, cognitiveComplexity, parameterCount; project when two projects compile one type) - and when they apply 'note', minComplexityBoundary, 'nearest' (a close declared name on an empty lookup) and testMethodsFiltered. In a ranking, test projects are excluded unless includeTests=true; testMethodsFiltered counts those that cleared the floor, and the note names the strongest one when it would have ranked inside the shown list. The note also says when the two axes would have listed different methods.

An empty ranking means nothing cleared the floor - or the scope matched nothing: methodsScanned 0, plus a note. An empty lookup means no METHOD of that name; a bare property or type name gets a note saying so.

Read-only; works on a recalled session.

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": "symbol_metrics"
  }
}

Input Schema

NameRequiredDescriptionDefault
scopeNoWhen ranking: 'solution' (default) or a namespace prefix to narrow scope. Ignored when symbol is given.solution
symbolNoExact (case-sensitive) method name to report - bare (every same-named method) or in the qualified Type.Member form (that type's member only). Omit to rank all methods by complexity.
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.
includeTestsNoWhen ranking: include test-project methods (default false - production hotspots; CC-heavy test harnesses would otherwise skew the top-N). Ignored in the by-name symbol lookup (which always returns the named method).
minComplexityNoWhen ranking (no symbol): only include methods whose ranking complexity (cyclomatic, or cognitive when rankByCognitive=true) >= this. 0 (default) = no filter.
rankByCognitiveNoWhen ranking: rank + filter by COGNITIVE complexity instead of cyclomatic (default false). Both numbers are always present per method; this only changes the sort + minComplexity axis. Ignored in the by-name symbol lookup.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.46513
    • 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."
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only declare read-only/idempotent/non-destructive, and the description goes well beyond them: a 200-item cap, test-project exclusion in rankings, which parameters are silently ignored in symbol mode, constructor/accessor naming conventions, and what 'works on a recalled session' implies. It also explains degenerate outcomes (empty ranking could mean nothing cleared the floor or the scope matched nothing; empty lookup could mean the name is a property or type).

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?

Front-loaded and logically ordered: purpose, guidance, then mode-by-mode behavior, then return shape, then edge cases. It is dense and long, with several run-on sentences and parenthetical asides that could be tightened, but almost every clause carries decision-relevant information rather than 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?

There is no output schema, so the description must carry the return shape — and it does: scope, mode, metricMeaning, minComplexity, methodsScanned, the per-method fields, the 200-item cap, and conditional 'note'/'nearest'/'testMethodsFiltered'. Combined with the mode and edge-case coverage, an agent has everything needed to call it and interpret results without guessing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3; the description still adds genuine meaning beyond it, notably the metadata-name conventions ('get_Items', '.ctor' meaning every constructor unit of the solution vs 'Type..ctor' for one type) which appear nowhere in the schema. It also clarifies inclusion rules ('complexity >= minComplexity', 'inclusive; 0 = no floor') and that ranking axes only change sort/filter, not the returned numbers.

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 precise verb and resource (report method cyclomatic + cognitive complexity and parameter count) and names the two operating modes explicitly ('for one method by name, or as a hotspot ranking'). It also names the sibling it is not ('solution_metrics gives the solution-wide rollup'), so the agent can separate the two without opening either 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?

Gives concrete when-to-use ('before touching an unfamiliar method, and to find where the complexity sits'), an explicit when-not with alternative ('Both metrics measure CODE SHAPE, not runtime cost; for a hot path use a profiler'), and a sibling alternative for solution-wide aggregation. The mode-selection rule (with vs without symbol) is stated directly rather than left to inference.

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