Skip to main content
Glama

Explain a SEI CERT finding and suggest a fix

explain_finding
Read-onlyIdempotent

Explains a single flagged finding with its rule summary, match rationale, closest compliant/noncompliant examples, diff, and concrete fix steps so you can resolve it.

Instructions

Explain one finding: a short rule summary, why the finding matches the rule (checker mapping, APIs, shared identifiers), the rule's noncompliant/compliant example pair most similar to the flagged code (token overlap), a unified diff between them, and concrete fix steps derived from that compliant example plus per-API and per-category advice. Use after check_files or check_diff when you need to explain or fix a finding; pass the finding object unchanged, or rule_id with file and line, or with a code snippet. Use get_rule instead for the full rule text and all examples, and validate_findings (not this tool) to check that a manually written finding is grounded. Deterministic and offline: reads only the bundled rules and the named file. An unknown rule_id returns an error listing close matches.

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": {
      "finding": "<finding>"
    },
    "name": "explain_finding"
  }
}

Input Schema

NameRequiredDescriptionDefault
findingYesThe finding: an item of check_files/check_diff `findings` as is, or {rule_id, file, line} or {rule_id, code}.
profileNoReview profile: 'default' (plain SEI CERT), 'ceph' (Ceph severities, suppressions and idioms), 'misra' (MISRA C:2012 + MISRA C++:2023), 'autosar' (AUTOSAR C++14) or an absolute path to a profile .yaml file.default
context_linesNoLines shown around the flagged line in finding.snippet (and used as fallback tokens when the line is blank).

Output Schema

NameRequiredDescriptionDefault
fixYessummary (one-line advice), steps[] (ordered advice: follow the compliant example, API replacements, lines it adds), example_diff (unified diff noncompliant -> compliant), category_advice.
whyYesReasons the finding matches the rule: checker mapping (rule-specific or general), message, APIs the rule discusses, identifiers shared with the CERT example, profile notes.
ruleYesid, title, lang, category, url, severity, priority, level, cwe[], summary (first sentence of the rule), coverage (checker tier).
exampleYesClosest CERT example pair: index, similarity (token Jaccard 0-1), shared_tokens[], noncompliant {heading, code}, compliant {heading, code, text}; null when the rule has no example pair.
findingYesEcho of the input: file, line, tool, checker, message, code (flagged line) and snippet (numbered lines around it, read from the file).
profileYesProfile used for notes and disabled rules.
alternativesYesNext best example pairs {index, heading, score}; pass a different code snippet to steer the choice.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.4.1

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare read-only, idempotent, closed-world, and non-destructive behavior. The description adds substantive context beyond that: deterministic offline operation, reading only bundled rules and the named file, and unknown rule_id returning an error with close matches.

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 front-loaded with the tool's output and follows with usage, alternatives, and behavior, with no filler. However, it is a dense single paragraph with several parentheticals, which slightly reduces scanability.

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?

This is a complex tool, but the annotations cover safety traits and the output schema covers the return shape. The description completes the picture with invocation modes, offline/deterministic behavior, sibling alternatives, and an error case, leaving no major operational gap.

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 FindingRef, profile, and context_lines. The description adds accepted invocation modes (pass the finding unchanged, or rule_id with file and line, or with a code snippet), but this largely restates what the schema already exposes. Baseline 3 is appropriate.

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 names a specific verb and resource (explain one finding) and enumerates the outputs: rule summary, match reasoning, example pair, diff, and fix steps. It also explicitly distinguishes this tool from get_rule and validate_findings, so an agent can select it confidently.

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 an explicit usage context: use after check_files or check_diff when you need to explain or fix a finding. It also names the alternatives, get_rule for full rule text and examples and validate_findings for checking manually written findings, which resolves the main selection ambiguity.

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