labqc-mcp
by kaneko-ai
README.md
# labqc-cli
[日本語版 README はこちら (README_JA.md)](README_JA.md)
[](LICENSE)
[](pyproject.toml)
[-15803D.svg)](pyproject.toml)
[](#why-labqc-cli)
[](#use-as-an-offline-mcp-server-claude-desktop--cursor)
**Zero-dependency, offline-first CLI auditor, built-in stdio MCP server, and Agent Skill for wet-lab CSV/TSV datasets, qPCR plates, calibration curves, and Excel gene-name date corruption.**
`labqc` inspects experimental tables locally in milliseconds—using **Python standard library only**—and provides both an **Agent-First CLI** (`--format json`, `--quiet`, deterministic exit codes `0/1/2`), a **built-in JSON-RPC 2.0 MCP server** (`labqc mcp` / `labqc-mcp`), and a **single-file HTML report** (pure inline SVG charts, zero external CDNs).

---
## Why `labqc-cli`?
Every wet-lab spreadsheet fails in predictable ways right before manuscript submission or AI pipeline handoff:
- **Excel gene-name date corruption:** `MARCH1` becomes `1-Mar` / `March-1` / `3月1日`, `SEPT2` becomes `2-Sep` / `Sept-2`, `DEC1` becomes `1-Dec`, and `2310009E13` becomes `2.31E+13`.
- **Mixed measurement units:** Someone records `0.025 ug/mL` in a `ng/mL` column, or enters a `1,000x` prefix slip.
- **Hidden qPCR & calibration issues:** Missing NTC controls (`QPCR_MISSING_NTC`), NTC amplification (`Ct < 35`), Ct outliers (`QPCR_CT_OUTLIER`), replicate `SD > 0.5` (MIQE threshold), non-monotonic standard curves, or extrapolated unknowns.
- **Silent encoding & delimiter traps:** Japanese Excel `Shift_JIS / CP932`, UTF-8/UTF-16 BOMs, jagged unquoted commas, or duplicate `Sample_ID` rows.
- **Data governance blocks:** You cannot upload unpublished experimental or clinical cohorts to cloud SaaS validators.
`labqc` runs **100% offline** with **zero third-party `pip` dependencies**, launches in **under 1 second**, and never makes any outbound network request.
---
## Quick Start (1-Line Install & Instant Demo)
```bash
pip install labqc-cli
```
Or run directly with [`uv`](https://docs.astral.sh/uv/):
```bash
uvx --from labqc-cli labqc demo --format json
```
Try the synthetic wet-lab demo and generate an HTML report + cleaned CSV:
```bash
labqc demo --out demo_report.html --clean-out demo_cleaned.csv
```
Audit your own experimental file (human report or machine-readable agent JSON):
```bash
# Human-readable report + cleaned UTF-8 CSV
labqc audit experiment_results.csv --out qc_report.html --clean-out experiment_clean.csv
# Agent-first JSON audit (writes zero extra HTML files unless --out is passed)
labqc audit experiment_results.csv --format json --strict
```
---
## Use as an Offline MCP Server (Claude Desktop / Cursor)
`labqc-cli` v0.2 includes a **zero-dependency JSON-RPC 2.0 stdio MCP server** (`labqc mcp` / `labqc-mcp`) exposing three offline tools:
- `audit_lab_table`: Audits CSV/TSV files or inline `csv_text` for gene-date corruption, mixed units, missingness, IQR/MAD outliers, batch shifts, and formula injection.
- `audit_qpcr_plate`: Enforces MIQE plate QC (`QPCR_MISSING_NTC`, `QPCR_NTC_CONTAMINATION`, `QPCR_CT_OUTLIER`, `QPCR_INVALID_CT`, `QPCR_HIGH_REPLICATE_SD`).
- `generate_qc_html_report`: Writes a self-contained zero-CDN HTML report (with optional UTF-8 cleaned CSV).
### Claude Desktop (`claude_desktop_config.json`)
```json
{
"mcpServers": {
"labqc": {
"command": "uvx",
"args": ["--from", "labqc-cli", "labqc-mcp"]
}
}
}
```
### Cursor (`.cursor/mcp.json`)
```json
{
"mcpServers": {
"labqc": {
"command": "labqc",
"args": ["mcp"]
}
}
}
```
### Agent Skill Package (`skills/labqc/SKILL.md`)
Ready for **Claude Code**, **Cursor**, **Antigravity**, and **skills-hub.ai** — copy [`skills/labqc/`](skills/labqc/SKILL.md) into your workspace or global skills directory (`.claude/skills/labqc/` or `.gemini/skills/labqc/`).
---
## Before & After: What `labqc` Catches Automatically
| Raw Spreadsheet Trap | What `labqc` Detects & Reports | Action Taken in `--clean-out` CSV |
|---|---|---|
| `1-Mar`, `March-1`, `3月1日`, `2-Sep`, `2.31E+13` in `gene_symbol` | **CRITICAL** `EXCEL_GENE_DATE_CORRUPTION` with suggested symbols (`MARCH1/MARCHF1`, `SEPT2/SEPTIN2`, `DEC1`, `OCT4`) | **Never silently guessed/overwritten** — preserved intact and tagged in `labqc_flags` for scientist review |
| `12.5 ng/mL` mixed with `0.025 ug/mL` | **CRITICAL** `MIXED_UNITS` across concentration / molarity / mass / volume / time | Safely converts `0.025 ug/mL` -> `25 ng/mL` and logs conversion |
| `#DIV/0!`, `NA`, `nd`, `Undetermined`, `Inf`, `NaN` | Flags non-finite values (`NON_FINITE_VALUES`) & Excel errors (`EXCEL_ERROR_TOKENS`) | Normalizes missing placeholders to empty cells (`""`) cleanly |
| `Plate_1` vs `Plate_2` shift | **WARNING** `BATCH_SHIFT_DETECTED` (one-way ANOVA $F$, $\eta^2$, Kruskal–Wallis $H$) | Flags batch shift in terminal, JSON, and SVG batch comparison chart |
| Missing NTC, `NTC Ct = 31.4`, Ct outlier, replicate `SD > 0.5` | **CRITICAL / WARNING** MIQE qPCR alerts (`QPCR_MISSING_NTC`, `QPCR_NTC_CONTAMINATION`, `QPCR_CT_OUTLIER`, `QPCR_HIGH_REPLICATE_SD`) | Highlighted in dedicated qPCR panel and JSON summary |
| `=cmd\|'/C calc'!A0` formula strings | **WARNING** `CSV_FORMULA_INJECTION` | Neutralized with leading `'` when `--neutralize-formulas` is enabled |
| Japanese Excel `CP932` / UTF-8 BOM / UTF-16 | Auto-detected encoding (`cp932`, `utf-8-sig`, `utf-16`, `utf-8`, `latin-1`) | Re-encoded safely to portable UTF-8 CSV |
---
## Agent-First CLI Usage & Deterministic Exit Codes
```text
labqc audit INPUT [--out REPORT.html] [--clean-out CLEAN.csv] [--json-out AUDIT.json]
[--mode auto|general|qpcr|curve] [--id-col COL] [--batch-col COL]
[--delimiter DELIM] [--lang en|ja] [--format text|json] [--quiet]
[--neutralize-formulas] [--strict]
labqc demo [--scenario all|qpcr|curve] [--out DEMO.html] [--clean-out CLEAN.csv]
[--json-out AUDIT.json] [--lang en|ja] [--format text|json] [--quiet]
[--neutralize-formulas] [--strict]
labqc mcp # Start JSON-RPC 2.0 stdio MCP server (alias: labqc-mcp)
labqc version # Print version (--format json supported)
```
### Exit Code Contract
- `0`: Audit completed cleanly (or without `CRITICAL` blockers when `--strict` is omitted).
- `1`: Argument, input file, directory collision, or I/O error (all errors emit cause + copy-paste `Fix command`).
- `2`: One or more `CRITICAL` findings detected under `--strict`.
### Python API
```python
from pathlib import Path
from labqc import audit_file
report = audit_file(Path("experiment_results.csv"))
print(report.score, report.grade, report.critical_count)
```
---
## Features Inside Every Single-File HTML Report
- **Quality Scorecard (0–100, Grade A–F):** Transparent deduction across structural, statistical, and biological checks.
- **Prioritized Action Checklist:** Sorted `CRITICAL` -> `WARNING` -> `INFO` with row numbers, examples, and exact remediation guidance.
- **Pure Inline SVG Visualizations:** Missingness bar chart, per-column numeric histograms (with median & 1.5x IQR outlier fences), batch median comparison SVG, and calibration curve scatter + OLS fit SVG.
- **Zero External Requests:** Zero JavaScript frameworks, zero Google Fonts, zero external CDNs. Opens cleanly in air-gapped labs and prints cleanly to PDF.
- **Bilingual UI:** Supports `--lang en` (default) and `--lang ja`.
---
## Development & Running Tests
```bash
git clone https://github.com/kaneko-ai/labqc-cli.git
cd labqc-cli
uv run --with pytest pytest -v
uv build
```
---
## Research Use Only (RUO) & License
- **License:** [MIT License](LICENSE)
- **Research Use Only (RUO):** `labqc-cli` is provided strictly for research data quality auditing and statistical education. It is **not** intended for clinical diagnosis, treatment decisions, patient management, or regulatory (FDA / IVD / GLP / 21 CFR Part 11) validation.
Need a local desktop GUI for flow cytometry, statistics, and publication-ready figures? AutoTool Lab Complete Lab Suite (https://autotool-lab-showcase.kanekiti1125.workers.dev/)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues