linac-forensics MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
linac-forensics
Closed-Loop Linac Telemetry, Three-Way EPID & Heterogeneity-Aware Perturbative 3D Delivery-Forensics Engine with Frontier Agent Harness & MCP Server
Research Software — NOT A MEDICAL DEVICE.
linac-forensicsis open-source scientific research software for radiotherapy machine physics, AAPM TG-142 / TG-218 QA methodology research, and delivery-forensics benchmarking. It has not been cleared or approved by the FDA, EU MDR/CE, or any regulatory authority and must never be used for clinical patient QA sign-off, treatment decisions, or linear accelerator calibration.
Why linac-forensics?
Consumer AI chat interfaces cannot parse 50 Hz binary Varian TrueBeam trajectory logs (.bin) or legacy Dynalogs (.dlg), deconvolve a-Si EPID portal images to catch encoder-blind silent faults, project sub-millimeter MLC aperture errors through CT electron-density heterogeneities into 3D patient OAR anatomy, or run Bayesian causal attribution and Kalman RUL forecasting across a treatment fleet. linac-forensics closes the loop across every layer:
Native Varian TrueBeam
.bin(v3.0/v4.0/v5.0) + Legacy Dynalog.dlg+ JSON/CSV ingestion with 5 hardAbstentionErrorsafety gates (TIMESTAMP_DESYNC,MU_CONSERVATION_VIOLATION,UNMAPPED_IEC61217_COORDINATES,CORRUPTED_BINARY_LOG,INTERLOCK_INCOMPLETE_DELIVERY).CT-Heterogeneity-Aware Perturbative Fluence-to-3D-Dose Replay (
ΔΦ → ΔDose → ΔDVH / ΔgEUD / ΔTCP / ΔNTCP) across a SHA-256 verified 3-patient OpenKBP cohort (pt_1,pt_2,pt_3, CC BY 4.0) using piecewise-linear HU-to-$\rho_e$ radiological depth & scatter scaling — exposing Nelms et al. (2011) 2D 3%/2mm Gamma blindspots while preserving exact zero-error identity (actual == expected ⇒ ΔΦ ≡ 0, ΔDose ≡ 0, γ ≡ 100.0%).Three-Way Closed-Loop EPID Portal Dosimetry Forensics (
Planned TPSvs.Trajectory Logvs.Measured EPID): catches encoder-blind silent hardware faults (slipped optical encoders, unrecorded DLG/jaw drift, or TG-142 beam-steering symmetry tilts) invisible to trajectory logs alone.5-Mode Electro-Mechanical Causal Attribution (Matched-Filter + Bayesian BIC) separating:
Localized MLC leaf motor viscous drag ($\Delta x_i(t) \approx -\tau_i v_i(t)$)
Nonlinear MLC Coulomb / Stribeck stiction & leadscrew backlash ($\Delta x_i(t) \approx -\beta_i \tanh(v_i / v_0)$)
Systematic Bank / Dosimetric Leaf Gap (DLG) calibration offset ($\Delta\text{gap} = c$)
Gantry gravity-sag harmonic ($\Delta y(\theta) = A\sin\theta + B\cos\theta$)
Monitor ion-chamber / dose-rate calibration drift ($\Delta\text{MU}/\text{MU} = \delta$)
Kalman State-Space Remaining-Useful-Life (RUL) Forecasting & Multi-Fraction Cumulative 3D Dose Accumulation: predicts TG-142 action-limit breaches with 95% credible envelopes, separates systematic vs. random fraction errors, and computes compensatory remaining-course adaptive MU scaling.
Exact Saltelli–Jansen QMC Global Sobol' Sensitivity, Autonomous Fleet Physicist Harness (with 6-check Critic-Verifier Gate), and an 8-Tool + Resource-Enabled JSON-RPC 2.0 Stdio MCP Server.
Related MCP server: Crucible
System Architecture
flowchart LR
A["50 Hz Trajectory Logs<br/>Varian .bin v3-v5 | Dynalog .dlg | JSON/CSV"] --> B["Provenance & Hard Abstention Gates<br/>SHA-256 | IEC 61217 | MU | CRC32"]
B --> C["5-Mode Causal Attribution<br/>Viscous + Stiction + DLG + Sag + MU (BIC)"]
B --> D["CT-Heterogeneous 2D→3D Dose Replay<br/>HU→ρ_e + ΔΦ→ΔDose on OpenKBP pt_1–pt_3"]
B --> E["Three-Way EPID Forensics<br/>TPS vs Log vs Deconvolved a-Si EPID"]
F["OpenKBP pt_1–pt_3 Cohort<br/>CC BY 4.0 | SHA-256 Verified"] --> D
D --> G["3D ΔDVH, Multi-Fx Accumulation<br/>Nelms Blindspots & Saltelli Sobol'"]
C & E & G --> H["Autonomous Fleet Physicist Harness<br/>Kalman RUL + Triage Queue + Work Order"]
H --> I["Independent Critic-Verifier Gate<br/>6/6 Checks | JSON + Markdown Ledger"]
B & C & D & E & G & H <--> J["JSON-RPC 2.0 Stdio MCP Server<br/>8 Typed Tools + Live Resources"]Verified Benchmark Dashboard (v0.2.0)
All metrics below are deterministically reproduced by scripts/run_benchmarks.py (benchmark_summary.json) on real OpenKBP pt_1, pt_2, pt_3 anatomies paired with explicitly provenance-tagged synthetic fault benchmarks:
Benchmark & Physics Invariant | Measured Result | Reference / Gate |
Varian | Write | IEEE-754 |
Zero-Error Identity Invariant (w/ CT HU→$\rho_e$ Heterogeneity) |
| Exact machine epsilon |
5-Mode Causal BIC Attribution (Viscous, Stiction, DLG, Sag, MU) | Exact classification; Stiction | 95% CIs cover ground truths |
Three-Way EPID Encoder-Blind Silent Fault Detection | Plan-vs-Log | Caught & classified |
Nelms 2D Gamma Blindspot Sweep (32 faulted deliveries) | 17/17 (100%) failing plans passed 2D | AAPM TG-218 / Nelms 2011 |
Kalman State-Space RUL Forecast (Cutoff Day 20) | Predicted breach in |
|
Multi-Fraction Accumulation ( | Cumulative | Real 3D OpenKBP |
Global Sobol' Sensitivity ( |
| Saltelli 2010 QMC |
Publication-Grade Figures (7 × 300-DPI PNG + PDF, Visually Audited)
1. High-Frequency (50 Hz) Trajectory Log Forensics

2. Heterogeneity-Aware Perturbative Fluence-to-3D-Dose Replay on OpenKBP pt_1

3. Nelms et al. (2011) 2D Gamma Blindspot vs True 3D ΔDVH

4. Bayesian BIC Causal Fault Attribution & Joint 4-Fault Recovery

5. 30-Day Multi-Linac TG-142/MPC Drift & Clinical Patient Triage Matrix

6. Global Saltelli–Jansen QMC Sobol' Sensitivity (S₁ vs S_T)

7. Three-Way EPID Silent Faults, Nonlinear Coulomb Stiction & Kalman RUL Forecasting (v0.2)

Quickstart
# 1. Install dependencies with uv (Python 3.12)
uv sync --python 3.12 --extra dev
# 2. Verify / fetch OpenKBP pt_1, pt_2, pt_3 anatomies (CC BY 4.0, SHA-256 verified)
uv run python scripts/fetch_openkbp_anatomy.py
# 3. Run full test suite (38 tests, 0 warnings, >= 75% coverage gate) & lint
uv run pytest --cov=linac_forensics --cov-report=term-missing
uv run ruff check src tests scripts
# 4. Reproduce all benchmarks and 7 publication-grade figures (300-DPI PNG + PDF)
uv run python scripts/run_benchmarks.py
uv run python scripts/generate_figures.pyfrom pathlib import Path
from linac_forensics import (
analyze_three_way_epid_forensics,
compute_perturbative_dose_replay,
diagnose_causal_faults,
forecast_tg142_kalman_rul,
generate_synthetic_vmat_log,
load_openkbp_cohort,
simulate_measured_epid_image,
)
from linac_forensics.harness.agent_orchestrator import generate_tg142_fleet_trends
# 1. Diagnose nonlinear Coulomb stiction + systematic DLG offset
log = generate_synthetic_vmat_log(
log_id="TB01_STICTION_DLG",
failing_bank="B",
failing_leaf_index=34,
leaf_stiction_mm=0.65,
dlg_offset_mm=0.50,
noise_sigma_mm=0.02,
)
diag = diagnose_causal_faults(log)
print(diag.primary_root_cause, diag.active_faults, diag.service_recommendation)
# 2. Catch an encoder-blind silent fault via three-way EPID forensics
nom_log = generate_synthetic_vmat_log(log_id="SILENT_CHECK")
_, _, epid = simulate_measured_epid_image(nom_log, silent_dlg_bias_mm=1.6, silent_leaf_slip_mm=3.5)
epid_rep = analyze_three_way_epid_forensics(nom_log, epid)
print(epid_rep.classification, epid_rep.gamma_plan_vs_log_2pct_1mm, epid_rep.gamma_log_vs_epid_2pct_1mm)
# 3. CT-heterogeneity-aware 3D perturbative replay on real OpenKBP cohort
cohort = load_openkbp_cohort(Path("data/openkbp"), verify_manifest=True)
impact = compute_perturbative_dose_replay(log, cohort["pt_1"], use_heterogeneity=True)
print(f"2D γ(3%/2mm)={impact.gamma_2d_3pct_2mm_pass_pct:.1f}% | 3D γ(2%/1mm)={impact.gamma_3d_2pct_1mm_pass_pct:.1f}%")
# 4. Kalman state-space Remaining-Useful-Life forecast prior to TG-142 breach
tb01 = generate_tg142_fleet_trends()[0]
rul = forecast_tg142_kalman_rul(tb01, observation_cutoff_day=20, horizon_days=10)
print(f"Predicted RUL: {rul.rul_mean_days} days (95% CI {rul.rul_ci95_days})")Launch the MCP server directly via the installed console entrypoint:
uv run linac-forensics-mcpExposed Tools (tools/list):
linac_parse_trajectory_log— Parse & validate.bin(v3.0/v4.0/v5.0),.json, or.csvlogs with hard abstention gates.linac_compute_perturbative_dvh— CT-heterogeneity-aware 2D fluence → 3D perturbative dose replay (ΔD95,ΔD0.03cc,ΔgEUD,ΔTCP/NTCP, 2D/3D Gamma).linac_diagnose_causal_fault— 5-mode matched-filter & Bayesian BIC attribution (viscous drag, Coulomb stiction, DLG, gravity sag, MU drift).linac_compare_gamma_vs_dvh— Sweep DLG/MLC faults and quantify Nelms et al. (2011) 2D gamma blindspots vs 3DΔDVH.linac_triage_patient_fleet— Multi-patient OpenKBP Autonomous Fleet Physicist harness + Kalman RUL + Critic-Verifier Gate.linac_run_sobol_sensitivity— Exact Saltelli–Jansen QMC global Sobol' sensitivity (S₁,S_T, 95% CIs).linac_analyze_epid_three_way— Three-way TPS vs. Trajectory-Log vs. Deconvolved EPID silent-fault forensics.linac_forecast_tg142_rul— Local-linear-trend Kalman state-space RUL & breach-probability forecasting.
Exposed Read-Only Resources (resources/list, resources/read):
linac://manifest/openkbp_pt1·linac://results/benchmark_summary·linac://results/incident_report·linac://docs/audit_report
Documentation, Provenance & Citations
Key Scientific References
AAPM TG-142: Klein EE et al. Med. Phys. 2009;36(9):4197–4212. DOI:
10.1118/1.3190392AAPM TG-218: Miften M et al. Med. Phys. 2018;45(4):e53–e83. DOI:
10.1002/mp.12810Planar Gamma Blindspot: Nelms BE, Zhen H, Tomé WA. Med. Phys. 2011;38(2):1037–1044. DOI:
10.1118/1.3544657OpenKBP Dataset (CC BY 4.0): Babier A et al. Med. Phys. 2021;48(9):5549–5561. DOI:
10.1002/mp.14845Global Sobol' Sensitivity: Saltelli A et al. Comput. Phys. Commun. 2010;181(2):259–270. DOI:
10.1016/j.cpc.2009.09.018
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Live behavioral security verifier, schema auditor, and trust oracle for A2A, MCP & x402 agents.
Workflow diagnostics, capability routing, and x402 settlement for MCP-compatible agents.
Offline log parsing, CI failures, HTTP capture analysis and bounded JSON configuration validation.
Errors, traces, replays and logs from Talaria for coding agents.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables agents to manage space-compute mission cards, run readiness forecasts, verify audit trails, and export decision briefs through JSON-RPC tools.MIT
- AlicenseNot gradedqualityBmaintenanceEnables agents to turn a real model failure into a deterministic benchmark task by forging it with exact assertions, grading the task itself across six weighted factors, and inspecting a tamper-evident SHA-384 audit trail. Exposes eleven typed JSON-RPC 2.0 tools that call the same idempotent service layer as the UI, so mutations and decisions stay sealed and reproducible.MIT
- FlicenseNot gradedqualityBmaintenanceEnables agents to query live surf-break conditions, run what-if tide and engine evaluations, and create, update, log, export, or verify sealed session records through typed JSON-RPC tools.-
- FlicenseBqualityCmaintenanceExposes five typed, provenance-gated physics tools over JSON-RPC 2.0 stdio so frontier agents can compute 3D deformable biophysical dose accumulation, DIR-uncertainty envelopes, and inverse remaining-dose ceilings for multi-course re-irradiation. Every output is audited by a critic-verifier gate with a hard abstention check, returning safety-flagged dossiers and provenance ledgers instead of unsupported clinical numbers.7-