mcp_dicom

JorisRoels/mcp_dicom

3.1

If you are the rightful owner of mcp_dicom and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This repository implements an MCP server for interactive browsing, visualization, and reporting of DICOM data using local LLM inference.

DICOM MCP

This repository implements an MCP server that allows for interactive browsing, visualization and reporting of DICOM data through local LLM inference.

Installation

To get started with this repository, make sure to follow these guidelines:

  1. Clone the repository
  2. Configure your environment. It is recommended to work with uv (more info here):
    uv venv <your_env_name>
    source .venv/bin/activate
    uv pip install -r pyproject.toml
    
    This will initialize your environment, activate it, and install all required dependencies.
  3. Download the required data into the data folder. You will need to install NBIA Data Retriever. To make sure you did this correctly, make sure the command ls data returns the following:
    metadata.csv    TCGA-LUAD
    
  4. Local LLM inference is provided through Ollama. You will need to install this, as well as download your favourite (tool-calling compatible) model (e.g. llama3.2:3b). This can be done by executing the following command:
    ollama run llama3.2:3b
    
    This will download the necessary model files, and allow you to test it through a query interface in the terminal. Make sure Ollama is running before calling this command.

You're good to go!

Getting started

You can boot the MCP server by simply running the server.py file:

python server.py

By default, this will setup an MCP server through stdio transport, but you can modify this to mcp.run(transport="sse") if you need e.g. sse transport. For our purposes, we always work with stdio transport because everything happens locally.

If you want to test the actual application, make sure MCP transport is set to stdio, and run the client.py file.

python client.py

You will be asked to provide a query. Here are some example queries you can test:

  • Load a DICOM sample of patient TCGA-17-Z011 and then visualize it in a sagittal view.
  • Load a DICOM sample of study CT BIOPSY LUNG OR MEDI and then visualize it in a coronal view.
  • Load a DICOM sample of series ABDOMEN and visualize this image.
  • Load a DICOM sample of September 5th, 1982 and then visualize slice 57 in an axial view.
  • Load a DICOM sample imaged through a PT modality and then visualize it in a sagittal view.
  • Load a DICOM sample of patient TCGA-17-Z015 and generate a report.

These queries will load the requested DICOM data and optionally visualize it and/or generate a report.