
Clinical AI Agents, MCP Tooling, and Vector Search with dicomtk.ai
Source:vignettes/ai_agents_and_mcp.Rmd
ai_agents_and_mcp.RmdOverview
dicomtk.ai extends dicomtk with
ellmer-based clinical imaging agents, a Model Context
Protocol (MCP) server via mcptools, pluggable
AI segmentation backends with uncertainty maps, clinical report NLP,
RadLex / LOINC-RSNA protocol harmonisation,
and DuckDB vector similarity search.
1. Guardrailed 5-Stage Agent Workflow
Every de-identification workflow enforces the PS3.15 monotonic
join-semilattice (K < C < U < D < Z < X),
preventing any LLM or caller from weakening the baseline profile:
library(dicomtk)
library(dicomtk.ai)
synth <- dicom_synthesize(modality = "CT", dims = c(16L, 16L, 4L), phi_profile = "basic")
out_dir <- tempfile("ai_vignette_out_")
plan <- ai_agent_plan(
task = "deid_and_qc",
path = synth[["out_dir"]],
baseline_profile = dicom_deid_profile("ps3.15"),
chat = ai_chat("offline")
)
dry <- ai_agent_dry_run(plan)
approved <- ai_agent_approve(dry, auto_approve = TRUE, approver = "vignette")
exec_res <- ai_agent_execute(approved, out_dir = out_dir)
ver <- ai_agent_verify(exec_res)
ver$passed
#> [1] TRUE2. Protocol Harmonisation & Weak-Label Extraction
hdrs <- tibble::tibble(
SeriesDescription = c("CHEST WO CON 3.0mm", "BRAIN_T1_POST_GAD"),
Modality = c("CT", "MR"),
BodyPartExamined = c("CHEST", "HEAD")
)
ai_harmonize_protocol(hdrs)
#> # A tibble: 2 × 9
#> SeriesDescription Modality rpid long_common_name short_name body_region
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 CHEST WO CON 3.0mm CT RPID29 CT Chest WO contra… CT Chest … CHEST
#> 2 BRAIN_T1_POST_GAD MR RPID102 MR Brain WO and W … MR Brain … HEAD
#> # ℹ 3 more variables: radlex_id <chr>, contrast <lgl>, confidence <dbl>