Skip to main content
Glama

Check C/C++ files for SEI CERT violations

check_files
Read-onlyIdempotent

Audits C/C++ files or directories recursively for SEI CERT violations using clang-tidy, Clang Static Analyzer, and cppcheck, then maps findings to rule IDs.

Instructions

Run clang-tidy, the Clang Static Analyzer and cppcheck on a C/C++ file or a directory (recursive) and return every finding mapped to SEI CERT rule IDs. Use for whole-file or whole-tree audits; for a change set use check_diff, which keeps only changed lines. Runs the analyzers as local subprocesses (4 in parallel, 300 s timeout per file and tool) and writes no files. Takes under a second per small file but minutes for large trees. Pass compdb when the project has a compilation database; without it flags are guessed and project headers are often missing. A tools[].status of 'partial' or non-empty warnings means some files did not compile or timed out, so an empty result is not proof.

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": {
      "path": "<path>"
    },
    "name": "check_files"
  }
}

Input Schema

NameRequiredDescriptionDefault
langNoAnalyse only .c files (c) or only C++ files (cpp).any
pathYesAbsolute path of a C/C++ file or a directory to scan recursively. Files are picked by the profile's extensions and exclude_paths.
rootNoAbsolute project root: adds root/src, root/include and similar as include paths, enables compdb auto-detection, and is the base for the profile's path globs.
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
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
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.
suppressed_countYesFindings hidden by the profile or inline ignores.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.2

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive, closed-world), and the description adds substantial context beyond them: analyzers run as local subprocesses with 4-way parallelism, a 300 s per-file/per-tool timeout, no files written, and realistic latency ("under a second per small file but minutes for large trees"). It also discloses the failure mode of guessed compile flags and missing project headers when compdb is absent.

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?

Five tight sentences, front-loaded with what runs and what it returns before moving to alternatives, runtime, and caveats. The parentheticals (parallelism, timeout) carry real operational information rather than filler, and there is no redundant restatement of the name or title.

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?

For an 8-parameter, multi-analyzer tool with an output schema, this covers everything an agent needs: how to invoke it, cost expectations, the compdb prerequisite, and how to read degraded output (tools[].status 'partial', warnings). Return-value detail is rightly deferred to the output schema.

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 per-parameter meaning is already fully documented. The description only reinforces `compdb` ("without it flags are guessed and project headers are often missing"), which largely restates the schema's own note that it is "strongly recommended." No new syntax, formats, or parameter interactions are added beyond that.

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?

Opens with a concrete verb and named toolchain ("Run clang-tidy, the Clang Static Analyzer and cppcheck") applied to a specific resource ("a C/C++ file or a directory (recursive)") and states the output shape ("every finding mapped to SEI CERT rule IDs"). It also explicitly separates itself from the sibling check_diff ("for a change set use check_diff, which keeps only changed lines").

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?

Gives explicit when-to-use (whole-file/whole-tree audits) and when-not (change sets → check_diff), plus a conditional instruction for `compdb` ("Pass compdb when the project has a compilation database"). It even explains how to interpret a negative result: a 'partial' status or non-empty warnings means "an empty result is not proof."

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