dicomguard
README.md
<div align="center">
# dicomguard
**Zero-dependency binary DICOM Part 10 inspector, NEMA PS3.15 de-identifier, burned-in pixel PHI risk detector & MCP server — 100% offline.**
[](https://github.com/tranhoangtu-it/dicomguard/actions/workflows/ci.yml)
[](https://tranhoangtu-it.github.io/dicomguard/)
[](package.json)
[](package.json)
[](LICENSE)
```bash
npx dicomguard scan ./dicom-studies --fail-on high
```
**[Try the 100% Offline Browser Playground](https://tranhoangtu-it.github.io/dicomguard/)** — drag and drop real `.dcm` studies or sample CT / high-risk Ultrasound fixtures directly in your browser tab with **zero uploads**, inspect `(gggg,eeee)` elements, verify `PixelData` SHA-256 unchanged, and download `.safe.dcm` + signed `uid-vault.json`.
<p align="center">
<img src="assets/quickstart-demo.svg" alt="dicomguard Binary DICOM NEMA PS3.15 Demo" width="820" />
</p>
</div>
---
## Why `dicomguard`?
Radiology AI teams and medical-imaging engineers preparing `.dcm` datasets hit four recurring failure modes:
1. **Corrupted Binary Headers & Group `0002` Lengths** — Hand-rolled scripts that replace patient strings in binary DICOM break odd-length VR padding or leave `(0002,0000)` `FileMetaInformationGroupLength` stale so PACS/VNA viewers reject the file. `dicomguard` re-serializes Part 10 cleanly with valid even padding and recomputed `(0002,0000)` + synchronized `(0002,0003)` / `(0008,0018)` UIDs.
2. **Broken Multi-Slice Study/Series Referential Integrity** — Randomizing `StudyInstanceUID` / `SeriesInstanceUID` per slice breaks 3D CT/MRI reconstruction. `dicomguard` uses deterministic HMAC-SHA256 `2.25.<uint128>` OID derivation across slices and exports an HMAC-signed `UidVault`.
3. **Hidden Odd-Group Private Tags** — Vendor private blocks (`(0009,xxxx)`, `(0019,xxxx)`) often store plaintext clinician notes or station IDs. `dicomguard` strips odd-group private tags by default (`--keep-private` opt-out).
4. **Silent Burned-In Pixel PHI** — Ultrasound (`US`), Secondary Capture (`SC`), and screen-save series often rasterize patient banners into pixel buffers. `dicomguard` flags high-risk modalities, `ImageType` (`SECONDARY`/`SCREEN`), `(0028,0301) BurnedInAnnotation`, `(0018,6011)`, and `(60xx,3000)` `OverlayData`.
---
## Quick Start
```bash
# Generate synthetic CT or high-risk Ultrasound DICOM Part 10 fixtures
npx dicomguard sample --preset ct-chest -o sample-ct.dcm
npx dicomguard sample --preset ultrasound-burned -o sample-us.dcm
# Inspect binary headers, private tags, burned-in risk, and PixelData SHA-256
npx dicomguard inspect sample-ct.dcm
# Audit a directory (outputs: text, --json, --sarif, --markdown, --junit, --badge)
npx dicomguard scan ./studies --sarif -o dicomguard.sarif
# De-identify per NEMA PS3.15 (preserves 7FE0,0010 PixelData byte-for-byte)
npx dicomguard clean sample-ct.dcm --secret "$UID_KEY" --vault-out uid-vault.json -o sample-ct.safe.dcm
# Shift clinical/birth dates deterministically while preserving intervals
npx dicomguard clean sample-ct.dcm --profile retain-dates-shifted --secret "$UID_KEY" -o sample-ct.shifted.dcm
# Install git pre-commit hook blocking staged .dcm files with unredacted PHI
npx dicomguard guard install
```
---
## MCP Server (Claude Desktop, Cursor, VS Code, Codex, Gemini CLI)
Expose all 5 offline DICOM tools (`dicomguard_inspect`, `dicomguard_scan`, `dicomguard_deidentify_base64`, `dicomguard_burned_in_risk`, `dicomguard_list_tags`) via stdio JSON-RPC 2.0:
```json
{
"mcpServers": {
"dicomguard": {
"command": "npx",
"args": ["-y", "dicomguard", "mcp"]
}
}
}
```
Or manage/install alongside your existing stack via [`mcphub`](https://github.com/tranhoangtu-it/mcphub) and [`mcpman`](https://github.com/tranhoangtu-it/mcpman).
---
## GitHub Action (`@v1`)
```yaml
- name: DICOM Confidentiality Gate
uses: tranhoangtu-it/dicomguard@v1
with:
target: "./dicom-fixtures"
profile: "basic"
fail-on: "high"
sarif-file: "dicomguard.sarif"
```
---
## TypeScript / JavaScript SDK (Node & Browser)
```ts
import {
buildSampleDicomBytes,
deidentifyDicom,
inspectDicom,
scanDicom,
verifyUidVault,
} from "dicomguard";
const raw = buildSampleDicomBytes("ct-chest");
const before = scanDicom(raw, { file: "ct.dcm" });
const result = deidentifyDicom(raw, { profile: "basic", secret: "pacs-key" });
console.log(result.pixelDataIntact); // true (SHA-256 identical)
console.log(scanDicom(result.bytes).score); // 100
console.log(verifyUidVault(result.vault, "pacs-key")); // true
```
---
## Related Open-Source Security & Healthcare Tools
- **[`phiguard`](https://github.com/tranhoangtu-it/phiguard)** — Zero-dependency offline PHI de-identification, HIPAA / VN QĐ 4750 / JP APPI guardrails & MCP server for HL7 FHIR, HL7v2, and clinical notes ([Live Playground](https://tranhoangtu-it.github.io/phiguard/)).
- **[`clawleak`](https://github.com/tranhoangtu-it/clawleak)** — Find, losslessly redact, and block plaintext API keys leaked into AI coding agents (`0` deps, 100% offline).
- **[`mcphub`](https://github.com/tranhoangtu-it/mcphub)** — Curated hub & CLI for verified MCP servers.
- **[`mcpman`](https://github.com/tranhoangtu-it/mcpman)** — Universal package manager & security auditor for MCP servers.
---
## License
[MIT](LICENSE) © 2026 [Tran Hoang Tu](https://github.com/tranhoangtu-it)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues