Skip to main content
Glama

LeakageLens MCP

Dataset forensics for AI coding agents. LeakageLens catches target leakage, cross-split entities, time leakage, PII, identifier features, class imbalance, and preprocessing-before- split errors before an agent trains a misleading model.

It is not a “chat with CSV” server. The dataset remains local; the MCP client receives bounded, structured evidence and an explicit pass, review, or block verdict.

Why MCP?

Any MCP-compatible coding agent can discover the same audit tools and guidance without a custom integration. Resources provide experiment policy, prompts enforce a review workflow, and tools return typed evidence. The core engine works without an LLM; an optional Gemini check reasons about whether features exist at prediction time.

Related MCP server: COUE

Quick start

python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'

leakagelens examples/leaky_churn.csv \
  --target churned --split split --entity customer_id --time-column signup_date

pytest -q
python evals/benchmark.py

Expected demo verdict: block, with direct-target, entity-overlap, PII, identifier, and semantic leakage findings.

Connect an MCP client

Example local configuration:

{
  "mcpServers": {
    "leakagelens": {
      "command": "/absolute/path/to/.venv/bin/leakagelens-mcp",
      "env": {
        "LEAKAGELENS_DATA_ROOT": "/absolute/path/to/leakagelens-mcp"
      }
    }
  }
}

Then ask your agent:

Review examples/leaky_churn.csv before training a churn model. The target is churned, the entity is customer_id, signup_date is the time column, and split defines train/test.

Remote transport

MCP_TRANSPORT=streamable-http LEAKAGELENS_DATA_ROOT="$PWD" leakagelens-mcp

Or run the container with a read-only data mount:

docker build -t leakagelens-mcp .
docker run --rm -p 8000:8000 -v "$PWD/examples:/data:ro" leakagelens-mcp

MCP surface

Primitive

Name

Purpose

Tool

profile_dataset

Bounded schema, missingness, uniqueness, and samples

Tool

audit_dataset

Leakage, PII, split, identifier, and metric checks

Tool

audit_training_code

AST audit of split/preprocessing order

Tool

review_feature_availability

Optional Gemini semantic review

Resource

guidance://experiment-contract

Minimum valid experiment contract

Prompt

review_before_training

Reusable pre-training workflow

All file tools are restricted to LEAKAGELENS_DATA_ROOT to avoid arbitrary host-file access.

Detection design

  • Direct leakage: equality, near-perfect numeric association, deterministic categorical maps

  • Semantic leakage: outcome-like and target-derived column names

  • Split leakage: entity overlap and invalid chronological boundaries

  • Privacy: PII column names and value-pattern scans

  • Pipeline leakage: Python AST detects fitting or resampling before the split

  • Evaluation risk: imbalance-aware metric recommendations

Every finding includes a stable code, severity, evidence, affected columns, and remediation. The risk score is deterministic: critical 30, high 15, medium 7, low 3, capped at 100.

Optional Gemini review

pip install -e '.[gemini]'
export GEMINI_API_KEY='...'
export GEMINI_MODEL='gemini-2.5-flash'

Only column names/types and the user-provided prediction moment are sent. Raw rows are not sent. Security decisions never depend solely on the model.

Benchmark

evals/benchmark.py generates 35 reproducible scenarios: 25 seeded leakage/privacy/evaluation cases and 10 clean negative controls. It reports scenario recall and false-block rate. Add cases before adding heuristics; this prevents a growing collection of unmeasured rules.

Current synthetic benchmark result: 35/35 scenarios passed, 100% scenario recall, 0% false-block rate. These figures validate the included seeded cases; they are not estimates of performance on arbitrary real-world datasets.

Current boundaries

  • Statistical association is a warning, not proof of leakage.

  • Semantic rules cannot know feature availability without a prediction-time contract.

  • The AST audit recognizes common scikit-learn patterns, not arbitrary dynamic Python.

  • This release audits supplied splits; it does not mutate the user’s dataset.

Architecture

MCP client → FastMCP tools → path boundary → audit engine → typed findings
                                      ├── dataframe checks
                                      ├── split validation
                                      ├── Python AST audit
                                      └── optional Gemini review

Development

ruff check .
pytest -q
python evals/benchmark.py

See HELPER_GUIDE.md for a concise code walkthrough.

Available Tools

4 tools
audit_datasetC

Detect target, entity and temporal leakage, PII, identifiers, and metric risks.

Inputs: path (required), split, entity, target, +1 more.

audit_training_codeA

Statically detect preprocessing or resampling before the train/test split.

Inputs: path (required). Returns: result

profile_datasetA

Profile a local CSV, Parquet, or JSONL without sending the full dataset to the model.

Inputs: path (required), sample_rows.

review_feature_availabilityC

Optionally ask Gemini which features may be unavailable at the prediction moment.

Inputs: path (required), target (required), prediction_time (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 4 tools

    Disambiguation4/5

    Each tool targets a distinct stage of leakage detection: profiling, dataset auditing, code auditing, and feature availability review. However, profile_dataset and audit_dataset could be confused by an agent since both operate on datasets, though their descriptions help separate general profiling from leakage-specific auditing.

    Naming Consistency5/5

    All tool names consistently follow a verb_noun pattern using lowercase snake_case: profile_dataset, audit_dataset, audit_training_code, and review_feature_availability. This makes the tool set predictable and easy to navigate.

    Tool Count5/5

    Four tools is well-scoped for a specialized leakage-detection server. Each tool has a clear, non-redundant role, and the count feels appropriate rather than thin or bloated.

    Completeness4/5

    The tool surface covers the core leakage-detection workflow: profile data, audit data for leakage, audit training code, and verify feature availability. Minor gaps exist around remediation or actionable reporting after an audit, but the main detection loop is complete.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Evidence-backed, read-only codebase diagnostics for coding agents: secrets, dependency, RLS, and source-impact audits with a verify loop and PR review verdicts. Never writes files or uses the network by default.
      7
      101 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to audit AI/ML projects for production readiness through deterministic static analysis, check ML system descriptions, compare model configurations, and generate readiness reports or deployment checklists. It returns scored, evidence-based findings with explicit unknowns while never executing submitted code or accessing the network.
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to run deterministic, read-only local repository audits for risky GitHub workflows, undocumented environment variables, possible credentials, and conflicting dependency configuration, returning structured findings without sending source code to a service.
      43 npm
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables local privacy scanning and masking of secrets and PII, verifies test-suite integrity to prevent silent fake success, and inspects or blocks destructive terminal and SQL commands before execution.
      4
      Apache 2.0