dicom_mcp
A Model Context Protocol (MCP) server for downloading DICOM medical images from multiple Chinese hospital imaging systems.
README
DICOM MCP Server
English | 中文
A Model Context Protocol (MCP) server for downloading DICOM medical images from multiple Chinese hospital imaging systems.
Overview
This MCP server wraps the dicom_download project, providing a clean interface for LLMs and AI agents to download DICOM images from supported medical imaging providers.
Supported Providers
- tz (天肿): Tianjin Medical University Cancer Institute - zlyy.tjmucih.cn
- fz (复肿): Fudan University Cancer Hospital - ylyyx.shdc.org.cn
- nyfy (宁夏总医院): Ningxia General Hospital - zhyl.nyfy.com.cn
- cloud: Cloud-based DICOM services (*.medicalimagecloud.com and others)
Installation
Prerequisites
- Python 3.9+
- Playwright (for browser automation)
Setup
# Install the package in development mode
pip install -e .
# Install Playwright browsers (required once)
playwright install chromium
Usage
As an MCP Server
# Start the MCP server (stdio transport)
dicom-mcp
# Or with explicit Python
python -m dicom_mcp.server
Integration with Claude/LLM
Method 1: Local Python Deployment
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"dicom-downloader": {
"command": "python",
"args": ["-m", "dicom_mcp.server"],
"env": {
"PYTHONPATH": "/path/to/dicom_mcp"
}
}
}
}
Method 2: NPX Deployment (Recommended)
Using npx, you can run the MCP server directly without manual setup.
⚠️ IMPORTANT: You MUST modify DICOM_DEFAULT_OUTPUT_DIR to use an absolute path. Do NOT use relative paths like ./dicom_downloads.
{
"mcpServers": {
"dicom-downloader": {
"command": "npx",
"args": ["-y", "dicom-mcp"],
"env": {
"DICOM_DEFAULT_OUTPUT_DIR": "/Users/your-username/Downloads/dicom_downloads",
"DICOM_DEFAULT_MAX_ROUNDS": "3",
"DICOM_DEFAULT_STEP_WAIT_MS": "40"
}
}
}
}
Configuration Requirements:
DICOM_DEFAULT_OUTPUT_DIR[REQUIRED TO MODIFY]: Use absolute path (e.g.,/Users/username/Downloads/dicom_downloads)- ❌ Do NOT use relative paths like
./dicom_downloads(files will be saved to IDE default directories) - ✅ Use full paths:
/Users/username/...(macOS/Linux) orC:\\Users\\username\\...(Windows)
- ❌ Do NOT use relative paths like
This method:
- Automatically handles Python dependency detection
- Installs required packages on first run
- No manual PYTHONPATH configuration needed
- Works across different operating systems
- Supports environment variables for default parameters:
DICOM_DEFAULT_OUTPUT_DIR: Directory for downloaded files (MUST BE ABSOLUTE PATH)DICOM_DEFAULT_MAX_ROUNDS: Default scan rounds (default:3)DICOM_DEFAULT_STEP_WAIT_MS: Default delay between frames in ms (default:40)
Note: First run may take 2-3 minutes as it installs Python dependencies. Subsequent runs will be faster.
Real-Time Progress Feedback
Downloads now display real-time progress information:
======================================================================
🚀 DICOM 下载开始
======================================================================
📍 下载数量: 2 个URL
📁 输出目录: ./dicom_downloads
⚙️ 扫描次数: 3, 帧间延迟: 40ms
⏳ 请稍候,下载中... (可能需要 2-10 分钟)
>>> 打开检查页面: https://ylyyx.shdc.org.cn/viewer?...
[1/2] provider=fz
>>> 已进入 viewer iframe
======================================================================
✅ 下载完成!处理结果中...
======================================================================
Expected Download Time (varies by parameters and image size):
- Fast mode (2 rounds, 30ms): 1-5 minutes
- Balanced mode (3 rounds, 40ms): 2-8 minutes [recommended]
- Complete mode (5 rounds, 80ms): 4-15 minutes
- Deep scan (10 rounds, 100ms): 8-30 minutes
For details, see PROGRESS_FEEDBACK.md
Available Tools
1. download_dicom
Download DICOM images from a single URL.
Parameters:
url(required): Medical imaging viewer URL- Auto-detects security code: Include code in URL like
URL 安全码:8492and it will be automatically extracted - Supports formats:
安全码:8492,密码:8492,password:8492,code:8492,验证码:8492
- Auto-detects security code: Include code in URL like
output_dir(default:./dicom_downloads): Directory to save downloaded DICOM filesprovider(default:auto): Provider type (auto, tz, fz, nyfy, cloud)mode(default:all): Download mode (all, diag, nondiag)headless(default:true): Run browser in headless mode (no UI)password(optional): Share password/code if required (auto-extracted from URL if present)create_zip(default:true): Create ZIP archive of downloaded filesmax_rounds(default:3): Maximum number of scan rounds (扫描次数) - controls frame-by-frame playback iterationsstep_wait_ms(default:40): Delay between steps in milliseconds (延迟时间) - delay between frames during playback
Returns:
success: Whether download succeededoutput_dir: Directory containing downloaded fileszip_path: Path to ZIP archive if createdfile_count: Number of files downloadedmessage: Status or error message
2. batch_download_dicom
Download from multiple URLs in batch.
Parameters:
urls(required): List of URLs to download from- Auto-detects security code: Include code in URL like
URL 安全码:8492and it will be automatically extracted - Supports formats:
安全码:8492,密码:8492,password:8492,code:8492,验证码:8492
- Auto-detects security code: Include code in URL like
output_parent(default:./dicom_downloads): Parent directory for all downloads (each URL gets its own subdirectory)provider(default:auto): Provider type (auto, tz, fz, nyfy, cloud)mode(default:all): Download mode (all, diag, nondiag)headless(default:true): Run in headless mode (no UI)password(optional): Share password/code if required (auto-extracted from URLs if present)create_zip(default:true): Create ZIP archives for each URLmax_rounds(default:3): Maximum number of scan rounds (扫描次数) - applied to all URLsstep_wait_ms(default:40): Delay between steps in milliseconds (延迟时间) - applied to all URLs
Returns: List of download results for each URL, with success status and file count
3. detect_provider_from_url
Identify which provider a URL belongs to.
Parameters:
url(required): URL to check
Returns:
detected_provider: The provider identifierprovider_info: Details about the provideris_auto_detected: Whether detection was successful
4. list_supported_providers
Get information about all supported providers.
Returns: List of provider information with supported domains and descriptions
5. validate_url
Check if a URL is from a supported provider.
Parameters:
url(required): URL to validate
Returns:
valid: Whether URL is from a supported providerprovider: Detected provider if validerror: Error message if invalid
Examples
Single Download
# Download from a single URL
download_dicom(
url="https://zlyy.tjmucih.cn/viewer?share_id=AAAA",
output_dir="./my_downloads",
mode="all",
create_zip=True
)
Batch Download
# Download from multiple URLs
batch_download_dicom(
urls=[
"https://zlyy.tjmucih.cn/viewer?share_id=AAAA",
"https://ylyyx.shdc.org.cn/viewer?share_id=BBBB",
"https://zhyl.nyfy.com.cn/viewer?share_id=CCCC"
],
output_parent="./batch_downloads",
provider="auto", # Auto-detect for each URL
create_zip=True
)
With Password
# Download URL that requires a password/share code
download_dicom(
url="https://example.medicalimagecloud.com/viewer?id=XYZ",
password="secret123",
provider="cloud"
)
Architecture
dicom_mcp/
├── pyproject.toml # Project configuration
├── README.md # This file
└── dicom_mcp/
├── __init__.py # Package initialization
└── server.py # MCP server implementation
The MCP server acts as a wrapper around the underlying dicom_download project, handling:
- Tool Registration: Exposing download functions as MCP tools
- Input Validation: Validating URLs and parameters
- Provider Detection: Auto-detecting the correct provider for a URL
- Process Management: Running the underlying download scripts
- Result Formatting: Returning structured results to the LLM
Error Handling
The server provides detailed error messages for common issues:
- Invalid URL format
- Unsupported provider domain
- Download failures (expired links, authentication required, etc.)
- File system errors
Security Considerations
- Passwords are passed to the underlying service but not logged or cached
- URLs are validated before processing
- File operations use temporary directories for intermediate results
- The server runs in read-only mode by default (use only for downloads)
Limitations
- Browser Automation: Some providers require Chromium/Firefox via Playwright
- Desktop Environment: Headless mode requires X11 or similar on Linux servers
- Authentication: Some URLs require valid share codes or authentication
- Link Expiration: Share links may expire after a certain period
Development
Running Tests
# Run with pytest (after installing dev dependencies)
pip install -e ".[dev]"
pytest tests/
Building
# Build the package
python -m build
# Or with setuptools directly
python setup.py sdist bdist_wheel
License
This MCP server wrapper is provided under the same license as the underlying dicom_download project (Apache 2.0). See the original project for details.
Credits
- Original project: dicom_download
- Cloud provider adapter based on: cloud-dicom-downloader
Support
For issues with:
- MCP Server: Check this repository
- DICOM Downloads: See the dicom_download project
- Specific Providers: Refer to provider-specific documentation
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。