3D Slicer MCP server

Bridges medical professionals with 3D Slicer's medical imaging platform, enabling MRML node listing and direct Python code execution for advanced image analysis and visualization tasks.
Back to servers
Setup instructions
Provider
zhaoyouj
Release date
Mar 21, 2025
Language
Python
Package
Stats
1.1K downloads
13 stars

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

MCP-Slicer provides two main capabilities:

  • list_nodes: List and filter Slicer MRML nodes and view their properties
  • execute_python_code: Execute Python code in the Slicer environment

Installation Requirements

Prerequisites

Before installing MCP-Slicer, ensure you have:

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

Installing uv Package Manager

On macOS:

brew install uv

On Windows:

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

After installation on Windows, add uv to your PATH:

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

For other platforms, follow the instructions at the uv installation page.

Client Configuration

Claude for Desktop Integration

Configure Claude by navigating to: Claude > Settings > Developer > Edit Config > claude_desktop_config.json

Add the following configuration:

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

Cline Integration

Add the same configuration to your Cline configuration file:

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

Using MCP-Slicer

Verify Claude Settings

After configuration, check Claude Desktop to ensure that the Slicer tools appear in the tools menu. You should see the Slicer tools added to the Claude interface.

Starting the Slicer Web Server

  1. Open 3D Slicer
  2. Navigate to the Slicer Web Server module
  3. Ensure all required interfaces are checked
  4. Click the button to start the server

Usage Examples

Using list_nodes Tool

You can ask Claude to list specific nodes in the Slicer scene. For example:

"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"

Using execute_python_code Tool

You can instruct Claude to execute Python code in Slicer. For example:

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

Technical Information

MCP-Slicer works by utilizing the existing Slicer Web Server interfaces to communicate between the model client and 3D Slicer.

Security Considerations

Please note the following important security limitations:

  • The execute_python_code tool allows running arbitrary Python code in 3D Slicer, which is powerful but potentially dangerous.
  • This tool is not recommended for production use due to security concerns.
  • Complex operations may need to be broken down into smaller steps for better execution.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "slicer" '{"command":"uvx","args":["mcp-slicer"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

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

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

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

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later