Reports Module

The reports module generates evaluation reports in various formats.

JSON Reports

toolscore.reports.generate_json_report(result, output_path='toolscore.json')[source]

Generate JSON report from evaluation result.

Parameters:
  • result (EvaluationResult) – Evaluation result to report.

  • output_path (str | Path) – Path to save the JSON report.

Return type:

Path

Returns:

Path to the generated report file.

HTML Reports

toolscore.reports.generate_html_report(result, output_path='toolscore.html')[source]

Generate HTML report from evaluation result.

Parameters:
  • result (EvaluationResult) – Evaluation result to report.

  • output_path (str | Path) – Path to save the HTML report.

Return type:

Path

Returns:

Path to the generated report file.

Markdown and CSV Reports

toolscore.reports.generate_markdown_report(result, output_path='toolscore.md')[source]

Generate Markdown report from evaluation result.

Creates a Markdown file perfect for embedding in GitHub issues, PRs, wikis, or documentation. Includes formatted tables and emoji indicators.

Parameters:
  • result (EvaluationResult) – Evaluation result to report.

  • output_path (str | Path) – Path to save the Markdown report.

Return type:

Path

Returns:

Path to the generated report file.

toolscore.reports.generate_csv_report(result, output_path='toolscore.csv')[source]

Generate CSV report from evaluation result.

Creates a CSV file with metrics that can be opened in Excel or Google Sheets. Perfect for sharing results with non-technical stakeholders.

Parameters:
  • result (EvaluationResult) – Evaluation result to report.

  • output_path (str | Path) – Path to save the CSV report.

Return type:

Path

Returns:

Path to the generated report file.

Behavior and Safety Findings

toolscore.reports.findings.behavior_findings(result)[source]

Collect behavior and safety findings from an evaluation result.

Parameters:

result (EvaluationResult) – The evaluation result.

Return type:

list[tuple[str, str]]

Returns:

(severity, message) pairs, "error" first (forbidden calls, credentials, false success claims, escape hatches), then "warning" (failed calls, blind retries, undisclosed warnings). Call numbers are 1-based positions in the actual trace.

SARIF and JUnit

SARIF 2.1.0 and JUnit XML for the commands that produce findings.

One model, two formats. Each command turns what it found into a list of Outcome objects (one per check: a scenario, a lint issue, a probe, a pin difference, an honesty rule…) with a tri-state status, and write_ci_reports() writes them as:

  • SARIF 2.1.0 (--sarif PATH), for GitHub code scanning and other SARIF viewers. A failed check is a result with kind: "fail" and the level of its severity (error, warning or note); a check that could not be decided is kind: "open" with level: "none" (SARIF’s “not enough information”), never a pass; passing checks are left out.

  • JUnit XML (--junit PATH), for GitLab, Jenkins, Azure DevOps and any test-report viewer. Every check is a test case: a failed error-severity check is a <failure>, an unknown one is <skipped>, and a passing one is a plain test case. JUnit has no warning state, so a warning or note is a passing test case whose <system-out> says warning: ....

Code scanning shows a SARIF result only when it has a location. Results point at the file the check is about (a config or instruction file with its line, the lock file, the trace) or, for a server, at the file passed with --report-location, the --config file, or the server script in the command; see default_location().

toolscore.reports.ci.STATUSES = ('fail', 'warn', 'note', 'unknown', 'pass')

Outcome statuses, worst first.

class toolscore.reports.ci.Outcome(check, status, message, subject='', location=None, line=None, fix='')[source]

One check and what came of it.

Variables:
  • check (str) – A stable name for the check (the rule ID for a finding).

  • status (str) – "fail" (error severity), "warn", "note", "unknown" (could not be decided) or "pass".

  • message (str) – What was found, or what passed.

  • subject (str) – What the check is about (a tool, a call), for grouping.

  • location (str | None) – A file path the check is about, or None.

  • line (int | None) – A 1-based line in that file, or None.

  • fix (str) – How to fix a failure (the SARIF rule help).

Parameters:
check: str
status: str
message: str
subject: str = ''
location: str | None = None
line: int | None = None
fix: str = ''
__init__(check, status, message, subject='', location=None, line=None, fix='')
Parameters:
Return type:

None

toolscore.reports.ci.rule_description(rule)[source]

The one-line meaning of a Toolscore rule ID, from the rule tables.

Return type:

str

Parameters:

rule (str)

toolscore.reports.ci.default_location(explicit, config=None, command=(), pin=None)[source]

The file SARIF results about a server point to.

The first that applies: --report-location, the --config file, a file under the working directory named in the server command (python server.py gives server.py), the lock file. None when there is none (a remote URL with no config file): code scanning then does not display the results.

Return type:

str | None

Parameters:
toolscore.reports.ci.to_sarif(outcomes, category)[source]

A SARIF 2.1.0 log with one run.

Parameters:
  • outcomes (list[Outcome]) – The checks; passing ones are not written.

  • category (str) – The analysis category (runAutomationDetails.id prefix), such as "toolscore/mcp-test"; GitHub uses it to keep analyses of different commands apart.

Return type:

dict[str, Any]

toolscore.reports.ci.to_junit(outcomes, suite)[source]

A JUnit XML document with one test suite and one test case per check.

Return type:

str

Parameters:
toolscore.reports.ci.write_ci_reports(outcomes, command, sarif=None, junit=None)[source]

Write the SARIF and/or JUnit files a command was asked for.

Parameters:
  • outcomes (list[Outcome]) – The command’s checks.

  • command (str) – The command name ("mcp test"), used for the SARIF category and the JUnit suite name.

  • sarif (Path | None) – Where to write SARIF, or None.

  • junit (Path | None) – Where to write JUnit XML, or None.

Return type:

list[tuple[str, Path]]

Returns:

(format, path) for each file written ("SARIF", "JUnit").

toolscore.reports.ci.outcomes_from_lint(issues, tools, location)[source]

Lint issues, plus one passing check per tool without any.

Return type:

list[Outcome]

Parameters:
toolscore.reports.ci.outcomes_from_scorecard(card, location)[source]

Scenarios, lint issues, scenario findings and effect probes of a scorecard.

Return type:

list[Outcome]

Parameters:
toolscore.reports.ci.outcomes_from_pin(report, location)[source]

Pin differences: the ones that fail under --fail-on are errors, the rest notes.

Return type:

list[Outcome]

Parameters:
toolscore.reports.ci.outcomes_from_diff(diff, fail_on, location)[source]

Breaking changes, other differences and new lint issues between two servers.

Return type:

list[Outcome]

Parameters:
toolscore.reports.ci.outcomes_from_config_lint(report)[source]

Config-lint issues with their file and line; skipped rules are unknown.

Return type:

list[Outcome]

Parameters:

report (ConfigLintReport)

toolscore.reports.ci.outcomes_from_honesty(report, location)[source]

Honesty findings, and for each rule that did not fire: pass, or unknown without evidence.

Return type:

list[Outcome]

Parameters:
toolscore.reports.ci.outcomes_from_evaluation(result, location)[source]

The tri-state evidence checks of an evaluation (toolscore eval).

Return type:

list[Outcome]

Parameters:
toolscore.reports.ci.ci_report_options(location=False)[source]

Add --sarif PATH and --junit PATH (and --report-location FILE) to a command.

Return type:

Callable[[_Command], _Command]

Parameters:

location (bool)