回购信用:https://github.com/ChristianHinge/dicom-mcp
运行它
- 最小配置(
configuration.yaml):
nodes:
orthanc:
host: "localhost"
port: 4242
ae_title: "ORTHANC"
description: "Default Local Orthanc DICOM server"
aliases: ["local", "dev-orthanc"]
radiant:
host: "localhost"
port: 11112
ae_title: "RADIANT"
description: "Radiant Viewer Dicom Node"
aliases: ["viewer"]
current_node: "orthanc"
calling_aets:
default:
ae_title: "MCPSCU"
description: "Default calling AE"
calling_aet: "default"
query_root: "study"
allow_remote_hosts: false
network:
acse_timeout: 10
dimse_timeout: 30
network_timeout: 30
assoc_timeout: 10
max_pdu: 16384
retry:
max_attempts: 2
backoff_seconds: 1.0
backoff_multiplier: 2.0
backoff_max_seconds: 5.0
- 启动服务器(dev):
uv run --with-editable '.' -m dicom_mcp configuration.yaml- 如果uv缓存旧代码:add
--no-cache或--reinstall-package simple-dicom-mcp.
Claude桌面(JSON格式)
{
"mcpServers": {
"DicomMCP": {
"command": "C:\\Windows\\System32\\wsl.exe",
"args": [
"--distribution",
"Ubuntu",
"--",
"bash",
"-lc",
"cd '/mnt/c/Users/paulo/Python Projects/simple-dicom-mcp' && uv run --with-editable '.' python -m dicom_mcp '/mnt/c/Users/paulo/Python Projects/simple-dicom-mcp/configuration.yaml'"
]
}
},
"globalShortcut": "",
"preferences": {
"menuBarEnabled": false
}
}WSL提示
- 启用镜像网络
localhost适用于Windows和WSL。 - 使用
--with-editable '.'因此,您的代码更改是实时可见的。
您可以调用的工具
- 连接:
list_dicom_nodes,switch_dicom_node,verify_connection - 注册表:
get_manifest - 查询:
query_patients,query_studies,query_series,query_instances,get_attribute_presets
查询工具返回结构化状态元数据:
{
"success": true,
"results": [],
"dicom_statuses": [],
"warnings": [],
"error": null
}示例
- 查找日期范围内的研究:
query_studies(study_date="20230101-20231231")- 按患者属性筛选研究:
query_studies(patient_id="12345678", patient_sex="O", patient_birth_date="19700101")故障排除
- 如果uv没有反映代码更改,请添加
--no-cache或--reinstall-package simple-dicom-mcp. - 在WSL/Windows上,启用镜像网络,以便
localhost适用于Windows和WSL。
许可证和信用证
- MIT许可证(见许可证)
- 基于:https://github.com/ChristianHinge/dicom-mcp
 ](https://www.python.org/downloads/) ](https://pypi.org/project/dicom-mcp/) ](https://pypi.org/project/dicom-mcp/)
这 simple-dicom-mcp 服务器使AI助手能够查询和读取DICOM服务器(PACS、VNA等)上的数据。
🤝 贡献指南 • 🐞 报告Bug • 🛟 支持 • 🔐 安全
✨ 核心能力
simple-dicom-mcp 提供工具以:
- 🔍 查询元数据:使用各种标准搜索患者、研究、系列和实例。
- ⚙️ 公用事业:管理连接并了解查询选项。
🚀 快速开始
📥 安装
使用紫外线进行安装:
uv tool install simple-dicom-mcp或者通过克隆存储库:
# Clone and set up development environment
git clone https://github.com/ThalesMMS/simple-dicom-mcp
cd simple-dicom-mcp
# Create and activate virtual environment
uv venv
source .venv/bin/activate
# Install with dev dependencies
uv pip install -e ".[dev]"⚙️ 配置
simple-dicom-mcp 需要一个YAML配置文件(config.yaml 或类似)定义DICOM节点并调用AE标题。调整配置或保持原样,以与示例ORTHANC服务器兼容。
nodes:
main:
host: "localhost"
port: 4242
ae_title: "ORTHANC"
description: "Local Orthanc DICOM server"
aliases: ["local", "dev-orthanc"]
current_node: "main"
calling_aets:
default:
ae_title: "MCPSCU"
description: "Default calling AE"
calling_aet: "default"
query_root: "study"
allow_remote_hosts: false
network:
acse_timeout: 10
dimse_timeout: 30
network_timeout: 30
assoc_timeout: 10
max_pdu: 16384
retry:
max_attempts: 2
backoff_seconds: 1.0
backoff_multiplier: 2.0
backoff_max_seconds: 5.0
笔记:
calling_aet可以是在中定义的名称、别名或AE标题calling_aets.query_root接受study或patient.allow_remote_hosts默认为false并阻止非环回DICOM主机,除非您明确选择加入。
\[!警告\] 简单的DICOM-MCP不适用于临床使用,也不应与实时医院数据库或包含患者敏感数据的数据库连接。这样做可能会导致患者数据丢失,以及患者数据泄露到互联网上。如果您有意需要远程PACS或VNA,请设置 allow_remote_hosts: true 只有在审查了风险并使用了私有、可信的环境之后。(可选)示例ORTHANC服务器
如果您没有可用的DICOM服务器,可以使用Docker运行本地ORTHANC服务器:
克隆存储库并安装测试依赖项:
uv pip install -e ".[dev]"启动Orthanc并运行测试:
cd tests
docker compose up -d
cd ..
uv run pytest -m integration🔌 MCP集成
添加到您的客户端配置中(例如。 claude_desktop_config.json):
{
"mcpServers": {
"dicom": {
"command": "uv",
"args": ["tool","simple-dicom-mcp", "/path/to/your_config.yaml"]
}
}
}发展:
{
"mcpServers": {
"simple-dicom-mcp": {
"command": "uv",
"args": [
"--directory",
"path/to/cloned/simple-dicom-mcp",
"run",
"simple-dicom-mcp",
"/path/to/your_config.yaml"
]
}
}
}🛠️ 工具概述
simple-dicom-mcp 提供了五类用于与DICOM服务器和DICOM数据交互的工具。
🔍 查询元数据
query_patients:根据ID或出生日期等标准搜索患者。query_studies:使用患者ID、日期、方式、描述、登录号或研究UID查找研究。query_series:使用模态、序列号/描述或序列UID在特定研究中定位序列。query_instances:使用实例号或SOP实例UID查找序列中的单个实例(图像/对象)
⚙️ 公用事业
list_dicom_nodes:显示当前活动的DICOM节点,调用AE标题,并列出所有配置的节点。switch_dicom_node:更改活动DICOM节点以进行后续操作。verify_connection:使用C-ECHO测试与当前活动节点的DICOM网络连接。get_attribute_presets:列出元数据查询结果的可用属性预设(无、自定义)。
get_manifest:返回MCP工具合同清单(必需/可选工具版本)。
交互示例
这些工具可以链接在一起以回答复杂的问题:
🤝 社区卫生
- 阅读
CONTRIBUTING.md在打开pull请求之前。 - 使用问题表单查找错误和重点功能想法。
- 跟随
SECURITY.md用于漏洞报告。 - 使用
SUPPORT.md获取设置/帮助指导。 - 请勿在问题或PR中发布PHI、真实的DICOM研究或实时PACS凭据。
📈 贡献
运行测试
单元测试在没有Orthanc的情况下运行;集成测试需要运行Orthanc DICOM服务器。你可以使用Docker:
# Navigate to the directory containing docker-compose.yml (e.g., tests/)
cd tests
docker compose up -d使用uv运行单元测试:
# From the project root directory
uv run pytest -m "not integration"使用uv运行集成测试:
# From the project root directory
uv run pytest -m integration停止Orthanc集装箱:
cd tests
docker compose down调试
使用MCP检查器调试服务器通信:
npx @modelcontextprotocol/inspector uv run simple-dicom-mcp /path/to/your_config.yaml --transport stdio日志记录
集 LOG_LEVEL 为了控制冗长(例如。, DEBUG, INFO, WARNING):
LOG_LEVEL=DEBUG uv run simple-dicom-mcp /path/to/your_config.yaml --transport stdio装订、格式化、类型检查
uv run ruff check .
uv run ruff format .
uv run pyright预承诺
uv run pre-commit install
uv run pre-commit run --all-files🙏 致谢
- 使用 Pynetdicom
