Repository navigation
Add JSON and SARIF output for lint and diff - #30
Merged
Merged
Conversation
lint and diff take --format text|json|sarif for stdout, and --sarif <file> writes a SARIF 2.1.0 file like --report. The library gets LintReport.ToJson/ToSarif and ToolSurfaceDiff.ToJson/ToSarif. The JSON report format (1) is described in docs/mcpprobe-report.schema.json. SARIF results point at the baseline or --from-file snapshot (default mcp-tools.json) and carry a stable fingerprint for GitHub code scanning.
A diff can report several changes with the same change kind, tool and path, for example allowed values removed and added on one parameter, or two constraints on one parameter. Those results got the same primaryLocationLineHash. Repeats now get :2, :3 and so on in order of appearance, the way GitHub numbers identical fingerprints. Also loads test schemas under a lock with a private registry, and compares goldens from the source tree so MCPPROBE_UPDATE_GOLDENS=1 works in the same run.
GitHub resolves those URIs from the repository root, so lint and diff should both be run from there.
# Conflicts: # CHANGELOG.md
This was referenced Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add JSON and SARIF output for lint and diff
mcpprobe lintandmcpprobe diffcan now write machine-readable output.--format jsonprints the McpProbe report format, and--format sarifprints SARIF 2.1.0, for example for GitHub code scanning. The default is still--format text, so existing scripts and the Action get the same stdout as before.--sarif <file>works like--report: it writes a SARIF file and leaves stdout and the exit code alone. You can use it together with--formatand--report.JSON
One document per run, format version 1, described in
docs/mcpprobe-report.schema.json. It haskind(lintordiff), the McpProbe version,result(passorfail, same as exit 0 or 1), a summary with counts, and the findings or changes. Diff changes for title and description also havebeforeandafter. There are no timestamps, so the output is stable between runs.With
--format jsonor--format sarif, stdout is exactly one document. The diff hint ("If the change is intended...") and the lint--write-baselineline ("Wrote N finding(s)...") go to stderr instead. Exit codes don't change, and on exit 2 (usage or connection error) nothing is written to stdout or to the--sariffile.SARIF
MCPP0xxids. Diff change kinds use kebab-case ids liketool-removedordescription-changed.error, warning iswarning, info isnote. Diff breaking iserror, non-breaking isnote.diffuses--baseline,lintuses--from-file, relative to the working directory. If the path is outside it, only the file name is used. When lint checks a live server, the default ismcp-tools.json. Runlintanddifffrom the repo root so those artifact paths are relative to the repository root (GitHub resolves them from there).partialFingerprints.primaryLocationLineHashfrom the rule id, tool and path, so the same alert is matched across runs. If several results share the same rule, tool and path, they get:1,:2and so on.One thing to know about GitHub: PR annotations only show up for alerts whose file lines changed in that PR. Other findings still appear in the code scanning alerts list. The README says this. Uploading SARIF from the Action is left for a follow-up.
Library
LintReport.ToJson(),LintReport.ToSarif(artifactUri),ToolSurfaceDiff.ToJson(failOnNonBreakingChanges)andToolSurfaceDiff.ToSarif(artifactUri).Tests
Golden files for lint and diff in JSON and SARIF, schema validation against the report schema and the SARIF 2.1.0 schema, CLI tests for the new flags (stdout vs stderr, exit codes, no files on exit 2,
--write-baseline, artifact paths), hostile text, and non-invariant culture.