Skip to main content
Glama

Get Solution Metrics

solution_metrics
Read-onlyIdempotent

Returns solution-wide code quality metrics (complexity, coupling, severities, debt) for production code, and evaluates a --fail-on gate expression so you can compare before/after numbers or test a gate.

Instructions

The solution-wide quality rollup in one call - the numbers the CLI '--fail-on' quality gate evaluates. symbol_metrics ranks single methods; list_insights shows the findings behind the severity counts.

Use it for a before/after number, or to try a gate expression.

Returns metrics {typeCount, methodCount, complexityMax, complexityAvg, methodsOverComplexityThreshold, ceMax, caMax}, scope (always 'production'), testMethodCount, testTypeCount, severities {critical, warning, info, ok}, debtMinutes, debtApprox, debtRating, complexityThreshold, qualityProfile, layerProfile (when one is in force), knownGateMetrics and, with failOn, gate {expression, passed, violatedClauses}. degradedProducers appears when an insight producer failed; severities and debt are then incomplete. debtMinutes is a coarse estimate from fixed per-finding rules, not measured effort; debtApprox rounds it (1 d = 8 h).

PRODUCTION code only: test projects (per the session's test profile) are excluded from every number; testMethodCount / testTypeCount give that side. Types are logical (partial fragments merged, multi-TFM deduplicated); methods exclude constructors and accessors. methodsOverComplexityThreshold counts STRICTLY greater than complexityThreshold, while symbol_metrics' minComplexity is inclusive. ceMax / caMax: coupling maxima (caMaxNote: same-named types could raise caMax). severities count insights - one per producer that found something - not findings. The rollup is NOT triage-filtered: suppressed and dismissed findings still count, as in the CLI gate, so debt and severities can exceed what list_insights shows.

failOn takes the tokens in knownGateMetrics; this gate is advisory, the blocking one is the CLI's.

Profiles: the session's own layer profile wins; otherwise the quality and layer profiles come from the DBs the dbPath parameter names. Writes nothing of its own (an older dbPath DB is upgraded on open). 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": "solution_metrics"
  }
}

Input Schema

NameRequiredDescriptionDefault
dbPathNoOptional path to an AIContextBuilder SQLite DB. When set, the complexity threshold and producer toggles come from that DB's active QualityProfile (same semantics as list_insights); omit to fall back to the server's default config DB (the GUI's, if resolved), else the default profile. Omitted, the layer profile comes from the config DB the session was analysed against.
failOnNoOptional quality-gate expression to evaluate against the rollup (CLI '--fail-on' syntax, e.g. 'critical>0 OR debt>120min OR ce-max>50'). An invalid expression or unknown metric is rejected with the known tokens.
sessionIdYesThe session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.46514
    • changedInput schema / properties / dbPath / description
      Previous value: -"Optional path to an AIContextBuilder SQLite DB. When set, the complexity threshold and producer toggles come from that DB's active QualityProfile (same semantics as list_insights); omit to fall back to the server's default config DB (the GUI's, if resolved), else the default profile."New value: +"Optional path to an AIContextBuilder SQLite DB. When set, the complexity threshold and producer toggles come from that DB's active QualityProfile (same semantics as list_insights); omit to fall back to the server's default config DB (the GUI's, if resolved), else the default profile. Omitted, the layer profile comes from the config DB the session was analysed against."
  2. 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."
  3. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the read-only and idempotent annotations, the description discloses production-only scope, test exclusion, logical type and method counting rules, strict threshold semantics, non-triage-filtered severities, advisory gate behavior, profile resolution order, and degraded-producer caveats. It also notes the older-dbPath upgrade-on-open behavior, which is important context for a read-only tool.

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 dense but front-loaded: purpose and alternatives come first, followed by return values and caveats. The length is justified by the many behavioral nuances, though some sentences could be split for readability.

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 carries the burden of explaining return fields and caveats, which it does thoroughly. It covers gate evaluation, profile precedence, incomplete metrics when producers fail, debt approximation, and production-only counting rules.

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 schema already documents all three parameters. The description adds useful meaning about failOn using knownGateMetrics tokens, the gate being advisory rather than blocking, and how dbPath affects quality and layer profile resolution.

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 states a specific verb and resource: the solution-wide quality rollup in one call. It explicitly distinguishes this tool from symbol_metrics and list_insights, so an agent can tell what it returns without opening the 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?

It gives concrete use cases: a before/after number, or trying a gate expression. It also names the alternatives and what they are for, making the selection between this tool, symbol_metrics, and list_insights clear.

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