Check changed C/C++ lines for SEI CERT violations
check_diffRuns 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
| Name | Required | Description | Default |
|---|---|---|---|
| base | No | Base git ref (branch, tag or SHA). Required unless diff_text is given. | |
| head | No | Head git ref. Omit to compare base with the working tree (uncommitted changes included). | |
| repo | Yes | Absolute path of the git checkout; diff paths are resolved against it. | |
| tools | No | 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. | |
| compdb | No | 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. | |
| profile | No | Review profile: 'default' (plain SEI CERT), 'ceph' (Ceph severities, suppressions and idioms) or an absolute path to a profile .yaml file. | default |
| diff_text | No | Unified diff text (git diff format, a/ b/ prefixes allowed). Overrides base and head. | |
| min_confidence | No | 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. | |
| include_suppressed | No | Also return findings hidden by the profile or by `// cert-review: ignore <RULE>` comments, each with its suppression reason (for audits). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| root | Yes | Absolute repository root used to resolve diff paths. | |
| files | Yes | Files analysed (absolute paths). | |
| notes | Yes | Engine notes, e.g. 'no C/C++ files selected'. | |
| tools | Yes | 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'). | |
| profile | Yes | Profile used. | |
| summary | Yes | total, by_severity {error, warning, note}, top_rules [[rule_id, count], ...]. | |
| findings | Yes | Sorted by severity, priority, confidence. Each also has lang, col, priority, level, tool, checker, title, cert_severity, also_found_by[], note, url. | |
| warnings | Yes | One line per analyzer that could not fully analyse its input (compile errors or timeouts); non-empty means the result is incomplete. | |
| changed_files | Yes | Every file in the diff, relative to root, including non-C/C++ files that were skipped. | |
| suppressed_count | Yes | Findings hidden by the profile or inline ignores. |