Skip to main content
Glama

calibra-mcp

CI Python License: MIT

An MCP server + AI agent that audits the confidence calibration of ML classifiers.

A model that says "95% sure" should be right 95% of the time. Most modern neural networks aren't: they are overconfident, which is dangerous in medicine, finance and any system that acts on predicted probabilities. calibra-mcp lets any LLM agent (Claude Desktop, Claude Code, Cursor, your own agent) measure, visualise and fix miscalibration from your model's saved predictions.

reliability diagram

Features

Tool

What it does

evaluate_calibration

Accuracy, ECE, MCE, Brier, NLL + plain-language diagnosis

reliability_diagram

Confidence-vs-accuracy plot (returned as an image to the LLM)

fit_temperature

Temperature scaling (Guo et al., 2017), before/after metrics

compare_models

Ranks several models by ECE

generate_demo

Synthetic calibrated / over- / under-confident predictions

Plus an audit prompt and calibra-audit, a standalone agent that connects to the server over stdio and writes a Markdown audit report.

Related MCP server: MCP Agent Reliability Server

Architecture

┌──────────────┐  MCP (stdio / HTTP)  ┌──────────────────────────────┐
│ Claude / any │ ───────────────────▶ │ calibra-mcp server           │
│ MCP client   │ ◀─────────────────── │  metrics · plots · scaling   │
└──────────────┘   tools, images      └──────────────┬───────────────┘
       ▲                                             │ reads
       │ calibra-audit (agent loop)                  ▼
       └──────────── Markdown report        preds.npz / preds.csv

The server is model-agnostic: it audits predictions, not weights. Export your model's outputs on a held-out set and you're done, whatever framework you use.

Quickstart

pip install "calibra-mcp[agent]"        # or: uv tool install "calibra-mcp[agent]"
export ANTHROPIC_API_KEY=sk-...
python -c "from calibra_mcp import data; data.save(data.make_demo('overconfident'), 'demo.npz')"
calibra-audit demo.npz --out reports/audit.md

Use it from Claude Desktop / Claude Code

{
  "mcpServers": {
    "calibra": { "command": "uvx", "args": ["calibra-mcp"] }
  }
}

Claude Code: claude mcp add calibra -- uvx calibra-mcp

Then ask: "Audit the calibration of ~/experiments/resnet_test.npz".

Input format

.npz with labels (N,) and either logits (N, K) (preferred: enables temperature scaling) or probs (N, K). Or a .csv with columns label,p_0,...,p_{K-1}.

# PyTorch
logits = torch.cat([model(x) for x, _ in test_loader]).cpu().numpy()
np.savez("preds.npz", logits=logits, labels=test_labels)

Development

uv venv && uv pip install -e ".[dev,agent]"
pytest                # unit + end-to-end MCP tests
ruff check . && ruff format .

Roadmap

  • Classwise ECE, adaptive binning, KS calibration error

  • More recalibrators: Platt, isotonic, vector/matrix scaling, Dirichlet

  • Direct loaders for HuggingFace models and datasets

  • Agent benchmark: detection accuracy over N seeded miscalibrated models

  • Publish on PyPI and the MCP Registry

References

  • Guo et al., On Calibration of Modern Neural Networks, ICML 2017

  • Naeini et al., Obtaining Well Calibrated Probabilities Using Bayesian Binning, AAAI 2015

  • Model Context Protocol

License

MIT © Daniele Santoro

Available Tools

5 tools
compare_modelsC

Evaluate several predictions files side by side and rank them by ECE.

Inputs: paths (required), n_bins. Returns: object

evaluate_calibrationB

Compute accuracy, ECE, MCE, Brier score and NLL for a predictions file, plus a plain-language diagnosis (over/underconfidence).

Inputs: path (required), n_bins. Returns: object

fit_temperatureA

Fit temperature scaling on a predictions file that contains logits. Returns the optimal temperature and before/after metrics. Optionally saves the recalibrated predictions to save_to (.npz).

Note: for a fair estimate, fit on a validation split and evaluate on a test split.

Inputs: path (required), n_bins, save_to. Returns: object

generate_demoB

Create a synthetic predictions file to try the tools. kind: 'calibrated' | 'overconfident' | 'underconfident'.

Inputs: kind, path, seed. Returns: object

reliability_diagramC

Render a reliability diagram (confidence vs accuracy) for one or more predictions files.

Inputs: paths (required), n_bins.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: metric computation, diagram rendering, temperature fitting, multi-model comparison, and demo data generation. Although evaluate_calibration and compare_models both involve evaluation, compare_models is explicitly scoped to side-by-side ranking, so boundaries remain clear.

    Naming Consistency4/5

    All names use consistent snake_case, and four follow a verb_noun pattern (evaluate_calibration, fit_temperature, compare_models, generate_demo). reliability_diagram is a noun phrase rather than a verb-led name, which is a minor deviation but still readable and predictable.

    Tool Count5/5

    Five tools are well-scoped for a focused calibration toolkit. Each tool covers a distinct part of the workflow, and there is no obvious redundancy or bloat.

    Completeness4/5

    The surface covers core calibration evaluation, visualization, recalibration via temperature scaling, model comparison, and demo generation. Minor gaps exist, such as alternative recalibration methods (e.g., isotonic/Platt scaling) or explicit data splitting utilities, but the stated purpose is well served.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLM agents to perform SRE reliability calculations like error budgets and burn rates using deterministic tools, integrating with Prometheus and Loki for real data.
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Enables LLMs to audit data drift and model degradation in tabular ML pipelines through deterministic statistical tests such as Kolmogorov-Smirnov and Population Stability Index, plus reusable prompts and standards resources.
      4
      -
    • A
      license
      A
      quality
      A
      maintenance
      Enables agents to verify claims against cited evidence, screen content for prompt injection and relevance before reading it, and rank candidates by meaning, all with calibrated probability verdicts.
      12
      4,378 npm
      595
      MIT