Skip to main content
Glama

get_complexity_metrics

Calculate cyclomatic and cognitive complexity metrics for code members, filtering by threshold and project to identify overly complex code.

Instructions

Calculate complexity for members (methods, constructors, properties, indexers, operators). Reports both 'complexity' (cyclomatic - the number of paths, starts at 1) and 'cognitive' (how hard the code is to follow, starts at 0 - a 0 is not a bug), plus 'maxNesting'. The 'metric' parameter selects which of the two the threshold filters on and the sort uses. Returns an envelope with items sorted worst-first, totalCount, truncated, limit (default 100), and a summary with max/avg/overThreshold plus maxCognitive.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of items to return (default: 100). Items are sorted by the selected metric desc (worst first).
metricNoWhich metric drives the threshold and the sort: 'cyclomatic' (default) or 'cognitive'. Both are always reported.cyclomatic
projectNoOptional project name filter
thresholdNoMinimum complexity threshold, applied to the selected metric (default: 10)
Behavior4/5

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

With no annotations, the description bears full burden. It details the envelope structure (items sorted worst-first, totalCount, truncated, limit, summary with max/avg/overThreshold, maxCognitive) and explains metric options and threshold filtering. It lacks explicit side-effect or permission info, but as a read-only analysis tool, this is acceptable.

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?

The description is a single focused paragraph with clear front-loading: it starts with the primary action, then details metrics and output structure. Every sentence adds unique value without redundancy or extraneous words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite lacking an output schema, the description thoroughly explains the return envelope (sorted items, totalCount, truncated, limit, summary fields). For a tool with 4 parameters and no nested objects, this is sufficient. Minor gap: no mention of error conditions or performance implications.

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?

Schema coverage is 100% (all 4 parameters have descriptions). The description adds significant value beyond schema: it explains the default limit (100), clarifies the 'metric' choices ('cyclomatic' default and 'cognitive') and that both are always reported, describes threshold as 'minimum complexity' applied to selected metric, and details sorting and envelope. This enriches parameter understanding.

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 description clearly states the tool calculates complexity for members, specifying two metrics (cyclomatic and cognitive) and maxNesting. It distinctly identifies the resource (members: methods, constructors, etc.) and the action (calculate). This differentiates it from sibling code analysis tools like 'analyze_data_flow' or 'find_circular_dependencies'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implicitly indicates when to use: to get complexity metrics for code members. It explains the metrics and envelope, giving context. However, it does not explicitly state when not to use or list alternatives, though no direct sibling overlaps in functionality.

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/MarcelRoozekrans/roslyn-codelens-mcp'

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