DICOM MCP Server
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
dicom-mcp: A DICOM Model Context Protocol Server
This repo is part of a blog post: Agentic Healthcare LLMs
Overview
A Model Context Protocol server for DICOM (Digital Imaging and Communications in Medicine) interactions. This server provides tools to query and interact with DICOM servers, enabling Large Language Models to access and analyze medical imaging metadata.
dicom-mcp allows AI assistants to query patient information, studies, series, and instances from DICOM servers using standard DICOM networking protocols. It also supports extracting text from encapsulated PDF documents stored in DICOM format, making it possible to analyze clinical reports. It's built on pynetdicom and follows the Model Context Protocol specification.
Tools
list_dicom_nodes
- Lists all configured DICOM nodes and calling AE titles
- Inputs: None
- Returns: Current node, available nodes, current calling AE title, and available calling AE titles
switch_dicom_node
- Switches to a different configured DICOM node
- Inputs:
node_name
(string): Name of the node to switch to
- Returns: Success message
switch_calling_aet
- Switches to a different configured calling AE title
- Inputs:
aet_name
(string): Name of the calling AE title to switch to
- Returns: Success message
verify_connection
- Tests connectivity to the configured DICOM node using C-ECHO
- Inputs: None
- Returns: Success or failure message with details
query_patients
- Search for patients matching specified criteria
- Inputs:
name_pattern
(string, optional): Patient name pattern (can include wildcards)patient_id
(string, optional): Patient IDbirth_date
(string, optional): Patient birth date (YYYYMMDD)attribute_preset
(string, optional): Preset level of detail (minimal, standard, extended)additional_attributes
(string[], optional): Additional DICOM attributes to includeexclude_attributes
(string[], optional): DICOM attributes to exclude
- Returns: Array of matching patient records
query_studies
- Search for studies matching specified criteria
- Inputs:
patient_id
(string, optional): Patient IDstudy_date
(string, optional): Study date or range (YYYYMMDD or YYYYMMDD-YYYYMMDD)modality_in_study
(string, optional): Modalities in studystudy_description
(string, optional): Study description (can include wildcards)accession_number
(string, optional): Accession numberstudy_instance_uid
(string, optional): Study Instance UIDattribute_preset
(string, optional): Preset level of detailadditional_attributes
(string[], optional): Additional DICOM attributes to includeexclude_attributes
(string[], optional): DICOM attributes to exclude
- Returns: Array of matching study records
query_series
- Search for series within a study
- Inputs:
study_instance_uid
(string): Study Instance UID (required)modality
(string, optional): Modality (e.g., "CT", "MR")series_number
(string, optional): Series numberseries_description
(string, optional): Series descriptionseries_instance_uid
(string, optional): Series Instance UIDattribute_preset
(string, optional): Preset level of detailadditional_attributes
(string[], optional): Additional DICOM attributes to includeexclude_attributes
(string[], optional): DICOM attributes to exclude
- Returns: Array of matching series records
query_instances
- Search for instances within a series
- Inputs:
series_instance_uid
(string): Series Instance UID (required)instance_number
(string, optional): Instance numbersop_instance_uid
(string, optional): SOP Instance UIDattribute_preset
(string, optional): Preset level of detailadditional_attributes
(string[], optional): Additional DICOM attributes to includeexclude_attributes
(string[], optional): DICOM attributes to exclude
- Returns: Array of matching instance records
get_attribute_presets
- Lists available attribute presets for queries
- Inputs: None
- Returns: Dictionary of available presets and their attributes by level
retrieve_instance
- Retrieves a specific DICOM instance and saves it to the local filesystem
- Inputs:
study_instance_uid
(string): Study Instance UIDseries_instance_uid
(string): Series Instance UIDsop_instance_uid
(string): SOP Instance UIDoutput_directory
(string, optional): Directory to save the retrieved instance to (default: "./retrieved_files")
- Returns: Dictionary with information about the retrieval operation
extract_pdf_text_from_dicom
- Retrieves a DICOM instance containing an encapsulated PDF and extracts its text content
- Inputs:
study_instance_uid
(string): Study Instance UIDseries_instance_uid
(string): Series Instance UIDsop_instance_uid
(string): SOP Instance UID
- Returns: Dictionary with extracted text information and status
Installation
Prerequisites
- Python 3.12 or higher
- A DICOM server to connect to (e.g., Orthanc, dcm4chee, etc.)
Using pip
Install via pip:
Configuration
dicom-mcp requires a YAML configuration file that defines the DICOM nodes and calling AE titles. Create a configuration file with the following structure:
Usage
Command Line
Run the server using the script entry point:
If using uv:
Configuration with Claude Desktop
Add this to your claude_desktop_config.json
:
Usage with Zed
Add to your Zed settings.json:
Example Queries
List available DICOM nodes
Switch to a different node
Switch to a different calling AE title
Verify connection
Search for patients
Search for studies
Search for series in a study
Search for instances in a series
Retrieve a DICOM instance
Extract text from a DICOM encapsulated PDF
Debugging
You can use the MCP inspector to debug the server:
Development
Setup Development Environment
- Clone the repository:Copy
- Create a virtual environment:Copy
- Install dependencies:Copy
Running Tests
The tests require a running Orthanc server. You can start one using Docker:
Then run the tests:
To test PDF extraction functionality:
Project Structure
src/dicom_mcp/
: Main package__init__.py
: Package initialization__main__.py
: Entry pointserver.py
: MCP server implementationdicom_client.py
: DICOM client implementationattributes.py
: DICOM attribute presetsconfig.py
: Configuration management with Pydantic
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built on pynetdicom
- Follows the Model Context Protocol specification
- Uses PyPDF2 for PDF text extraction
This server cannot be installed
Enables AI assistants to query and analyze medical imaging metadata from DICOM servers, including patient information, studies, series, and instances, as well as extract text from encapsulated PDF documents.