itksnap-mcp
An agent-callable interface for ITK-SNAP-based segmentation that enables automatic segmentation with human judgment routing for corrections, returning structured audit records.
README
itksnap-mcp
Model proposes, human disposes. An agent-callable interface to ITK-SNAP-based segmentation: an external agent (via MCP) runs automatic segmentation, applies a proposed structure into a live ITK-SNAP session, and when a case needs human judgment the expert corrects it — with the correction returned as a structured, audited record the agent can consume.
This repo is the Python glue that makes ITK-SNAP callable: a thin client for the ITK-SNAP
deep-learning segmentation (DLS) server, a socket client for ITK-SNAP's live command channel, and an
MCP server exposing the whole workflow as agent tools. The C++ pieces (voxel edit + audit record +
--agent-listen command channel) live in itksnap; the
model server lives in itksnap-dls.
Status: working prototype built for the SIIM-CAIMI26 AI Builder Showcase. The full propose → apply → audit backbone is verified live end-to-end (see below). This is also the intended pip-installable, agent-facing surface for the ITK-SNAP "composable human-in-the-loop" effort.
See docs/DESIGN.md for the architecture and the why, with the
architecture and end-to-end flow figures.
What it does
An agent orchestrates an automatic model and a human expert as two callable steps in one pipeline, and every change comes back as machine-readable provenance:
{
"op": "Agent apply (proposal)",
"timestamp": "2026-07-19T02:26:20Z",
"actor": "agent",
"changed_voxels": 1169665,
"bbox": { "valid": true, "min": [84, 2, 0], "max": [247, 189, 180] },
"before_counts": { "0": 1169665 },
"after_counts": { "1": 1169665 }
}
actor distinguishes an agent-applied proposal from a human correction — so a downstream pipeline
knows who made each change and can feed corrections back into model fine-tuning and QA.
MCP tools
| Tool | What it does |
|---|---|
list_models() |
list available segmentation models |
propose(ct_path, model_id="TotalSegmentator", fast=True) |
run automatic segmentation → present labels + voxel counts |
apply(label_id, itksnap_label=1, actor="agent") |
apply one proposed structure into the running ITK-SNAP; return the audit record |
read_audit() |
the most recent committed edit's audit record |
set_actor(actor) |
tag who is responsible for the next committed edit (agent | human) |
Run the full demo (3 commands)
Prereqs: a GPU box with the DLS server dependencies, an ITK-SNAP build with --agent-listen, and a
3-D body CT (ct.nii.gz).
pip install -e '.[dev]'
# 1) Model server (from an itksnap-dls checkout on feature/agentic-api):
python -m itksnap_dls --port 8911 --device cuda
# 2) ITK-SNAP with the live command channel (add `xvfb-run -a` if headless):
ITK-SNAP -g ct.nii.gz --agent-listen /tmp/snap-agent.sock
# 3) Drive the whole flow — propose → apply → read the audit record:
python demo/run_p2.py --ct ct.nii.gz --sock /tmp/snap-agent.sock --url http://localhost:8911
run_p2.py runs TotalSegmentator on the CT, applies the largest proposed structure (or --label N)
into the live ITK-SNAP tagged actor: agent, and prints the audit record. Then correct the result in
the GUI with the paintbrush and call read_audit again — the correction comes back tagged
actor: human.
What's here
src/itksnap_mcp/
dls_client.py # thin HTTP client for the itksnap-dls server (status/models/start/upload/run_automatic)
channel.py # SnapChannel: client for ITK-SNAP's --agent-listen Unix socket (JSON-RPC)
server.py # MCP server: propose / apply / read_audit / set_actor / list_models
confidence.py # confidence gate: decide auto-accept vs route-to-human (WIP)
demo/
run_p2.py # scripted end-to-end driver (propose → apply → read_audit)
agent_send.py # send one raw command to the live socket (debugging)
smoke_totalseg.py # DLS-only automatic-segmentation smoke test
manifest.example.yaml # per-case demo manifest (copy to manifest.yaml, gitignored)
docs/
DESIGN.md · architecture.svg · flow-chart.svg
Architecture (three repos)
| Piece | Repo | Role |
|---|---|---|
Voxel edits + audit record + --agent-listen command channel |
itksnap (sprint/caimi) |
C++ Logic tier + GUI |
| Model server (TotalSegmentator automatic; nnInteractive, SAM2) | itksnap-dls (feature/agentic-api) |
FastAPI + PyTorch |
| This repo — DLS client, socket client, MCP server, demo | itksnap-mcp |
Python glue / agent surface |
Known limitations (prototype)
- The DLS
upload_rawscalar path currently ships pixels only (no spacing/origin/direction), so the proposal comes back on identity geometry; the agent restores the source CT's geometry before applying (server.write_label_mask). Proposal and image must share the same voxel grid. applyapplies one structure under one label; a full multi-label apply is a straightforward extension.confidence.py(auto-accept vs route-to-human gating) is still a placeholder.- The audit
actortag is armed one commit ahead (set_actor) and consumed by the next commit; arm it immediately before a committing operation.
License
MIT — see LICENSE. This repo is pure HTTP/socket glue and contains no ITK-SNAP
(GPL) source; the GUI and model server keep their own licenses in their respective repos.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。