Back to MCP directory
publicPublicdnsLocal runtime

DICOM

DICOM-MCP是一个基于Model Context Protocol的DICOM服务器交互工具,支持LLM访问和分析医学影像元数据。

article

README

🚀 DicomMcp 简介

DicomMcp 是一个遵循 Model Context Protocol (MCP) 规范的 DICOM 服务端实现,可用于与模型建立上下文连接。它基于 pynetdicom 开发,还支持 PDF 文本提取功能,为相关应用场景提供了便利。

🚀 快速开始

初始化服务

在 Python 脚本中初始化 DicomMcp 服务:

from dicom_mcp import DicomMcpServer

# 创建配置文件
config = {
    "port": 11112,
    "title": "DicomMcp Server",
    "description": "A DICOM server following the Model Context Protocol"
}

# 初始化服务
server = DicomMcpServer(config)

# 启动服务
server.start()

使用命令行启动

通过命令行运行:

python -m dicom_mcp.run --config config.json

✨ 主要特性

  • 遵循 MCP 协议
  • 支持 DICOM 标准
  • 提供配置管理
  • 包含测试用例
  • 使用 PyPDF2 进行 PDF 解析

📦 安装指南

通过 pip 安装:

pip install dicom-mcp

📚 详细文档

配置

创建一个配置文件 config.json,内容如下:

{
    "port": 11112,
    "title": "DicomMcp Server",
    "description": "A DICOM server following the Model Context Protocol"
}

功能模块

核心组件

  • server.py:实现 MCP 服务器逻辑。
  • dicom_client.py:处理 DICOM 请求和响应。
  • attributes.py:定义 DICOM 属性预设。
  • config.py:管理配置文件。

测试用例

tests/ 文件夹中提供多个测试脚本,包括:

pytest tests/test_dicom_mcp.py  # 运行所有测试
pytest tests/test_dicom_pdf.py  # 测试 PDF 解析功能

开发环境

  1. 克隆仓库:
git clone https://github.com/yourusername/dicom-mcp.git
cd dicom-mcp
  1. 创建虚拟环境并安装依赖:
python -m venv .venv
source .venv/bin/activate  # 在 Windows 上使用:.venv\Scripts\activate
pip install -e .
  1. 启动测试用例的 Orthanc 服务器:
cd tests
docker-compose up -d
  1. 运行测试:
pytest tests/test_dicom_mcp.py
pytest tests/test_dicom_pdf.py

📄 许可证

DicomMcp 项目在 MIT 协议下开源,具体细节请参见 LICENSE 文件。

致谢

  • 基于 pynetdicom 开发
  • 遵循 Model Context Protocol 规范
  • 使用 PyPDF2 进行 PDF 解析
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client