基于 MCP (Model Context Protocol) 的 DICOM 医学影像文件分析工具
Project description
DicomToolsForMCP
DicomToolsForMCP 是一个基于 MCP (Model Context Protocol) 的 DICOM 医学影像文件分析与上传工具。它提供了一整套命令行工具,用于处理、分析 DICOM 文件,并将其安全地上传到兼容 MCP 的服务器。
功能特性
- DICOM 文件扫描与解析: 递归扫描指定目录,解析 DICOM 文件,并提取元数据。
- 数据映射与预处理: 根据预定义的规则,将 DICOM 标签映射为 MCP 模型所需的数据结构。
- 安全上传: 通过 Cookie 认证,将处理后的序列安全上传到服务器。
- 批量上传: 支持批量上传多个 DICOM 序列,后台执行不阻塞。
- 状态查询: 实时查询已上传序列的处理状态。
- 日志记录: 自动记录每次上传的详细信息(如
study_uid和目录路径),方便后续追踪。
安装
您可以通过 pip 从 PyPI 安装此工具:
pip install dicomtoolsformcp
配置 MCP Server
该工具可以作为 MCP Server 运行,通过 stdio 协议与 MCP 客户端通信。
Claude Desktop 配置
在 Claude Desktop 的配置文件中(macOS: ~/Library/Application Support/Claude/claude_desktop_config.json),添加以下配置:
{
"mcpServers": {
"dicom-tools": {
"timeout": 600,
"type": "stdio",
"command": "uvx",
"args": [
"dicomtoolsformcp"
],
"env": {
"base_url": "https://tavi.fit",
"name": "tavimercy",
"password": "!Az123",
"tel": ""
}
}
}
}
配置说明:
timeout: 超时时间(秒),建议设置为 600 秒以支持长时间运行的批量上传任务type: 通信协议类型,使用stdiocommand: 使用uvx命令(uv 包管理器的工具,可直接运行 PyPI 包)args: 包名dicomtoolsformcp
前置要求:
确保已安装 uv 工具:
curl -LsSf https://astral.sh/uv/install.sh | sh
或使用 pip 安装:
pip install uv
其他 MCP 客户端配置
对于 Cursor 或其他支持 MCP 的客户端,可以使用相同的配置格式。如果 uvx 不可用,也可以尝试使用 Python 模块方式:
{
"mcpServers": {
"dicom-tools": {
"timeout": 600,
"type": "stdio",
"command": "python3",
"args": ["-m", "dicomtoolsformcp"],
"env": {
"base_url": "https://tavi.fit",
"name": "tavimercy",
"password": "!Az123",
"tel": ""
}
}
}
}
环境变量说明
配置中的环境变量用于自动登录和认证:
base_url: 服务器基础 URL(必需)name: 登录用户名(必需)password: 登录密码(必需)tel: 电话号码(可选,可为空字符串)
使用方法
可用工具
- scan-dicom-directory: 扫描指定目录下所有可读的 .dcm 文件
- parse-dicom-file: 解析单个 DICOM 文件,提取元数据
- Analysis_dicom_directory: 上传单个 DICOM 序列进行分析
- batch_upload_dicom_directory: 批量上传目录中的所有 DICOM 序列(后台执行,不阻塞)
- fileforsep: 按患者和序列拆分目录下的 DICOM 文件
- get_result_tool: 根据 study_uid 查询分析结果
命令行使用
也可以通过命令行直接运行:
dicomtoolsformcp
使用示例
批量上传 DICOM 序列
批量上传功能支持在后台执行,不会阻塞 MCP 通信:
{
"name": "batch_upload_dicom_directory",
"arguments": {
"directory_path": "/path/to/dicom/folder",
"series_type": "1"
}
}
series_type 说明:
1: 主动脉分析9: 二尖瓣分析
查询分析结果
{
"name": "get_result_tool",
"arguments": {
"study_uid": "1.3.12.2.1107.5.1.4.76315.30000021042706150001900118311"
}
}
依赖项
本项目依赖于以下 Python 包:
mcp>=0.9.0pydicom>=2.4.0requests>=2.31.0pydantic>=2.0.0tqdm>=4.66.0pyorthancsympy
所有依赖项将在安装 dicomtoolsformcp 时自动安装。
许可证
本项目采用 MIT 许可证。详情请参阅 LICENSE 文件。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dicomtoolsformcp-1.3.0.tar.gz.
File metadata
- Download URL: dicomtoolsformcp-1.3.0.tar.gz
- Upload date:
- Size: 101.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e85f99d8fb3dd886c78943a723d3d304933283b7638b5b9f62e2832eeab41ad9
|
|
| MD5 |
a2e7bf71521b1c520a541ad8300e3016
|
|
| BLAKE2b-256 |
d1daf70df2126cc8ae0b8690f2b19895a2a3ee037cb0f78ad3006f3669091a0f
|
File details
Details for the file dicomtoolsformcp-1.3.0-py3-none-any.whl.
File metadata
- Download URL: dicomtoolsformcp-1.3.0-py3-none-any.whl
- Upload date:
- Size: 37.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ad06b133ea001b0e5f4c5e2196ec68f4f6e56e86c6730fa785c530571859b80
|
|
| MD5 |
6b289ee29b5bdf57e1f1f15cd121418c
|
|
| BLAKE2b-256 |
acdbf0906398405b3cfab8db551825e1c2b96f4fa5814fd62cae77651edfa979
|