Skip to main content
Glama

Check changed C/C++ lines for SEI CERT violations

check_diff
Read-onlyIdempotent

Runs clang-tidy, Clang Static Analyzer, and cppcheck on C/C++ changes, keeping only findings on added or modified lines for pull-request or pre-commit review.

Instructions

Run the check_files analyzers on the C/C++ files of a change and keep only findings on added or modified lines. The change is base..head in the git repo at repo, base against the working tree when head is omitted, or a pasted unified diff (diff_text, paths relative to repo). Use for pull-request or pre-commit review; for whole files use check_files. Runs git diff and the analyzers locally; writes nothing. For git refs, files must exist at head or line numbers will not match. With diff_text, missing files are reconstructed under repo (or a temp tree when repo is omitted) so remote MCP hosts can review without your checkout. Check tools[].status and warnings before trusting an empty result.

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": {
      "repo": "<repo>"
    },
    "name": "check_diff"
  }
}

Input Schema

NameRequiredDescriptionDefault
baseNoBase git ref (branch, tag or SHA). Required unless diff_text is given.
headNoHead git ref. Omit to compare base with the working tree (uncommitted changes included).
repoYesAbsolute path of the git checkout; diff paths are resolved against it.
toolsNoAnalyzers to run. clang-tidy = clang-tidy cert-*/bugprone checks plus Clang Static Analyzer checks; clangsa = standalone `clang --analyze` (adds alpha checkers); cppcheck = cppcheck. Missing binaries are skipped and reported.
compdbNoAbsolute path of the directory that contains compile_commands.json. Strongly recommended: without it files are compiled with guessed flags and often fail to parse. Omitted: auto-detected in root, root/build or root/build-clang.
profileNoReview profile: 'default' (plain SEI CERT), 'ceph' (Ceph severities, suppressions and idioms) or an absolute path to a profile .yaml file.default
diff_textNoUnified diff text (git diff format, a/ b/ prefixes allowed). Overrides base and head.
min_confidenceNoDrop findings below this confidence. Rule-specific checkers score 0.9, general checkers 0.3-0.65, +0.1 when two tools agree. 0.5 keeps most real hits.
include_suppressedNoAlso return findings hidden by the profile or by `// cert-review: ignore <RULE>` comments, each with its suppression reason (for audits).

Output Schema

NameRequiredDescriptionDefault
rootYesAbsolute repository root used to resolve diff paths.
filesYesFiles analysed (absolute paths).
notesYesEngine notes, e.g. 'no C/C++ files selected'.
toolsYesPer analyzer: tool, available, version, files, raw_findings, parse_errors, files_with_errors[], timed_out[], notes[], status ('ok' | 'partial' = some files did not compile or timed out | 'missing').
profileYesProfile used.
summaryYestotal, by_severity {error, warning, note}, top_rules [[rule_id, count], ...].
findingsYesSorted by severity, priority, confidence. Each also has lang, col, priority, level, tool, checker, title, cert_severity, also_found_by[], note, url.
warningsYesOne line per analyzer that could not fully analyse its input (compile errors or timeouts); non-empty means the result is incomplete.
changed_filesYesEvery file in the diff, relative to root, including non-C/C++ files that were skipped.
suppressed_countYesFindings hidden by the profile or inline ignores.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed26 schema fields changedv0.1.2
    • addedInput schema / properties / base / description
      Added value: +"Base git ref (branch, tag or SHA). Required unless diff_text is given."
    • addedInput schema / properties / base / examples
      Added value: +[
      +  "origin/main",
      +  "HEAD~1"
      +]
    • addedInput schema / properties / compdb / description
      Added value: +"Absolute path of the directory that contains compile_commands.json. Strongly recommended: without it files are compiled with guessed flags and often fail to parse. Omitted: auto-detected in root, root/build or root/build-clang."
    • addedInput schema / properties / compdb / examples
      Added value: +[
      +  "/home/me/ceph/build"
      +]
    • addedInput schema / properties / diff_text / description
      Added value: +"Unified diff text (git diff format, a/ b/ prefixes allowed). Overrides base and head."
    • addedInput schema / properties / head / description
      Added value: +"Head git ref. Omit to compare base with the working tree (uncommitted changes included)."
    • addedInput schema / properties / include_suppressed / description
      Added value: +"Also return findings hidden by the profile or by `// cert-review: ignore <RULE>` comments, each with its suppression reason (for audits)."
    • addedInput schema / properties / min_confidence / description
      Added value: +"Drop findings below this confidence. Rule-specific checkers score 0.9, general checkers 0.3-0.65, +0.1 when two tools agree. 0.5 keeps most real hits."
    • addedInput schema / properties / min_confidence / maximum
      Added value: +1
    • addedInput schema / properties / min_confidence / minimum
      Added value: +0
    • addedInput schema / properties / profile / description
      Added value: +"Review profile: 'default' (plain SEI CERT), 'ceph' (Ceph severities, suppressions and idioms) or an absolute path to a profile .yaml file."
    • addedInput schema / properties / profile / examples
      Added value: +[
      +  "default",
      +  "ceph"
      +]
    • removedInput schema / properties / repo / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • removedInput schema / properties / repo / default
      Removed value: -null
    • addedInput schema / properties / repo / description
      Added value: +"Absolute path of the git checkout; diff paths are resolved against it."
    • addedInput schema / properties / repo / examples
      Added value: +[
      +  "/home/me/ceph"
      +]
    • addedInput schema / properties / repo / type
      Added value: +"string"
    • removedInput schema / properties / tools / anyOf
      Removed value: -[
      -  {
      -    "items": {
      -      "type": "string"
      -    },
      -    "type": "array"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • changedInput schema / properties / tools / default
      Previous value: -nullNew value: +[
      +  "clang-tidy",
      +  "clangsa",
      +  "cppcheck"
      +]
    • addedInput schema / properties / tools / description
      Added value: +"Analyzers to run. clang-tidy = clang-tidy cert-*/bugprone checks plus Clang Static Analyzer checks; clangsa = standalone `clang --analyze` (adds alpha checkers); cppcheck = cppcheck. Missing binaries are skipped and reported."
    • addedInput schema / properties / tools / items
      Added value: +{
      +  "enum": [
      +    "clang-tidy",
      +    "clangsa",
      +    "cppcheck"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / tools / minItems
      Added value: +1
    • addedInput schema / properties / tools / type
      Added value: +"array"
    • addedInput schema / properties / tools / uniqueItems
      Added value: +true
    • addedInput schema / required
      Added value: +[
      +  "repo"
      +]
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$defs": {
      +    "Finding": {
      +      "additionalProperties": true,
      +      "properties": {
      +        "confidence": {
      +          "description": "0-1.",
      +          "title": "Confidence",
      +          "type": "number"
      +        },
      +        "file": {
      +          "description": "Absolute path of the file.",
      +          "title": "File",
      +          "type": "string"
      +        },
      +        "line": {
      +          "description": "1-based line.",
      +          "title": "Line",
      +          "type": "integer"
      +        },
      +        "message": {
      +          "description": "Analyzer message.",
      +          "title": "Message",
      +          "type": "string"
      +        },
      +        "rule_id": {
      +          "description": "SEI CERT rule ID.",
      +          "title": "Rule Id",
      +          "type": "string"
      +        },
      +        "severity": {
      +          "enum": [
      +            "error",
      +            "warning",
      +            "note"
      +          ],
      +          "title": "Severity",
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "rule_id",
      +        "file",
      +        "line",
      +        "severity",
      +        "message",
      +        "confidence"
      +      ],
      +      "title": "Finding",
      +      "type": "object"
      +    }
      +  },
      +  "additionalProperties": true,
      +  "properties": {
      +    "changed_files": {
      +      "description": "Every file in the diff, relative to root, including non-C/C++ files that were skipped.",
      +      "items": {
      +        "type": "string"
      +      },
      +      "title": "Changed Files",
      +      "type": "array"
      +    },
      +    "files": {
      +      "description": "Files analysed (absolute paths).",
      +      "items": {
      +        "type": "string"
      +      },
      +      "title": "Files",
      +      "type": "array"
      +    },
      +    "findings": {
      +      "description": "Sorted by severity, priority, confidence. Each also has lang, col, priority, level, tool, checker, title, cert_severity, also_found_by[], note, url.",
      +      "items": {
      +        "$ref": "#/$defs/Finding"
      +      },
      +      "title": "Findings",
      +      "type": "array"
      +    },
      +    "notes": {
      +      "description": "Engine notes, e.g. 'no C/C++ files selected'.",
      +      "items": {
      +        "type": "string"
      +      },
      +      "title": "Notes",
      +      "type": "array"
      +    },
      +    "profile": {
      +      "description": "Profile used.",
      +      "title": "Profile",
      +      "type": "string"
      +    },
      +    "root": {
      +      "description": "Absolute repository root used to resolve diff paths.",
      +      "title": "Root",
      +      "type": "string"
      +    },
      +    "summary": {
      +      "additionalProperties": true,
      +      "description": "total, by_severity {error, warning, note}, top_rules [[rule_id, count], ...].",
      +      "title": "Summary",
      +      "type": "object"
      +    },
      +    "suppressed_count": {
      +      "description": "Findings hidden by the profile or inline ignores.",
      +      "title": "Suppressed Count",
      +      "type": "integer"
      +    },
      +    "tools": {
      +      "description": "Per analyzer: tool, available, version, files, raw_findings, parse_errors, files_with_errors[], timed_out[], notes[], status ('ok' | 'partial' = some files did not compile or timed out | 'missing').",
      +      "items": {
      +        "additionalProperties": true,
      +        "type": "object"
      +      },
      +      "title": "Tools",
      +      "type": "array"
      +    },
      +    "warnings": {
      +      "description": "One line per analyzer that could not fully analyse its input (compile errors or timeouts); non-empty means the result is incomplete.",
      +      "items": {
      +        "type": "string"
      +      },
      +      "title": "Warnings",
      +      "type": "array"
      +    }
      +  },
      +  "required": [
      +    "profile",
      +    "files",
      +    "findings",
      +    "tools",
      +    "warnings",
      +    "notes",
      +    "suppressed_count",
      +    "summary",
      +    "changed_files",
      +    "root"
      +  ],
      +  "title": "DiffCheckResult",
      +  "type": "object"
      +}
  2. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the read-only, idempotent, and closed-world annotations, it explains local execution, the head file-existence requirement for correct line numbers, and missing-file reconstruction for pasted diffs. The instruction to inspect tools[].status and warnings before trusting an empty result is especially valuable reliability disclosure.

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 front-loaded and, despite its density, every sentence contributes distinct operational value: scope, input modes, tool selection, side effects, prerequisites, remote behavior, or result interpretation. Its length is justified by the tool's multiple input modes and edge cases.

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?

It is nearly complete for a complex nine-parameter tool, covering input modes, prerequisites, local behavior, remote review, and interpretation of empty results, while the output schema covers return details. The unresolved repo-required versus repo-omitted inconsistency is the one material gap in otherwise reliable invocation guidance.

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?

With 100% schema description coverage, the baseline is 3, but the description adds value through mode-selection guidance and operational caveats for head and diff_text. Other parameter details appropriately remain in the schema; however, saying repo can be omitted conflicts with the schema's required repo field.

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 opening sentence gives a precise action and scope: run the check_files analyzers on C/C++ files in a change and retain only findings on added or modified lines. It also explicitly distinguishes whole-file analysis with check_files, making this tool's niche unambiguous.

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 explicitly recommends pull-request and pre-commit review and routes whole-file analysis to check_files. It also explains when to use git refs, the working tree, or pasted diff_text, giving clear guidance for each supported review scenario.

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