Skip to main content
logo

MCP-Slicer - 3D Slicer Model Context Protocol Integration

English | 简体中文

Python Version License: MIT PyPI version PyPI - Downloads

MCP-Slicer connects 3D Slicer with model clients like Claude Desktop or Cline through the Model Context Protocol (MCP), enabling direct interaction and control of 3D Slicer. This integration allows for medical image processing, scene creation, and manipulation using natural language.

Features

  1. list_nodes: List and filter Slicer MRML nodes and view their properties

  2. execute_python_code: Execute Python code in the Slicer environment

  3. capture_screenshot: Capture real-time screenshots of Slicer views

    • Full application window (including module panels)
    • Individual slice views (Red/Yellow/Green)
    • 3D rendering view
    • Enables complete REACT loop with visual feedback

Installation

Prerequisites

  • 3D Slicer 5.8 or newer
  • Python 3.13 or newer
  • uv package manager

If you're on Mac, please install uv as

brew install uv

On Windows

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

and then

set Path=C:\Users\nntra\.local\bin;%Path%

Otherwise installation instructions are on their website: Install uv

⚠️ Please install UV first

Claude for Desktop Integration

Go to Claude > Settings > Developer > Edit Config > claude_desktop_config.json to include the following:

{
  "mcpServers": {
    "slicer": {
      "command": "uvx",
      "args": ["mcp-slicer"]
    }
  }
}

Cline Intergration

{
  "mcpServers": {
    "slicer": {
      "command": "uvx",
      "args": ["mcp-slicer"]
    }
  }
}

Usage

Check Claude Settings

Image Make sure you see the corresponding slicer tools added to the Claude Desktop App Image Image

Open Slicer Web Server

  1. Open the Slicer Web Server module,
  2. ensure the required interfaces are checked,
  3. then start the server
Image

Examples

- list_nodes

What Markups nodes are in the Slicer scene now, list their names, what is their length if it is a line, and what is its angle if it is an angle

Image

- execute python code

Draw a translucent green cube of 8 cm in the Slicer scene, mark its vertices, and then draw a red sphere inscribed in it.

example_code_execute_en

- capture_screenshot

Capture the current state of Slicer to provide visual feedback to AI

Usage examples:

  • capture_screenshot() - Capture full application window
  • capture_screenshot(view_type="slice", view_name="red") - Capture Red slice view
  • capture_screenshot(view_type="3d", camera_axis="A") - Capture 3D view from anterior

This enables a complete REACT loop where AI can:

  1. Reason about what to do
  2. Act using execute_python_code
  3. Observe the result using capture_screenshot

Technical Details

Utilizes existing Slicer Web Server interfaces. For technical details, please see Slicer web server user guide

Limitations & Security Considerations

  • The execute_python_code tool allows running arbitrary Python code in 3D Slicer, which is powerful but potentially dangerous.

    ⚠️ Not recommended for production use.

  • Complex operations may need to be broken down into smaller steps.

Contributing

Contributions are welcome! Feel free to submit Pull Requests.

Disclaimer

This is a third-party integration project, not developed by the 3D Slicer team.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_slicer-0.3.1.tar.gz (3.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_slicer-0.3.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mcp_slicer-0.3.1.tar.gz.

File metadata

  • Download URL: mcp_slicer-0.3.1.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mcp_slicer-0.3.1.tar.gz
Algorithm Hash digest
SHA256 55f628201e15699b4eda409047b8d6d589166a73836a6f2399bf56931f8e8a5d
MD5 171d16a872bae980e695509964e8fd1a
BLAKE2b-256 8c475569666f7afebbb09342420590772696dbc0c4d0a0b9911db8bce154f553

See more details on using hashes here.

File details

Details for the file mcp_slicer-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: mcp_slicer-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mcp_slicer-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2d40029035f65a822aeb51546f231e31c0536e7e14a693b5f95bfcedd4b20dc
MD5 b3a6c748083e449cef0c9764771f088d
BLAKE2b-256 b2316287583a4166d34e77596509df91e88151db1a43c9e8f3da26d9f564140c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page