3D Slicer

3D Slicer

zhaoyouj

Connects AI assistants to 3D Slicer for medical image analysis, enabling remote control and visualization of medical imaging workflows through natural language commands.

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.

26280 views5Local (stdio)

What it does

  • List and filter MRML nodes in 3D Slicer
  • Execute Python code directly in Slicer environment
  • Capture screenshots of slice views and 3D renderings
  • Control medical image processing workflows remotely
  • Manipulate 3D medical imaging scenes

Best for

Medical researchers analyzing imaging dataHealthcare professionals automating Slicer workflowsDevelopers building medical imaging applicationsAI-assisted medical image analysis
Direct 3D Slicer integrationReal-time visual feedback with screenshotsNatural language control of medical imaging

About 3D Slicer

3D Slicer is a community-built MCP server published by zhaoyouj that provides AI assistants with tools and capabilities via the Model Context Protocol. 3D Slicer bridges medical professionals with advanced image analysis and Python tools; a unique alternative to Prusa Sli It is categorized under developer tools. This server exposes 3 tools that AI clients can invoke during conversations and coding sessions.

How to install

You can install 3D Slicer in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.

License

3D Slicer is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.

Tools (3)

list_nodes

List MRML nodes via the Slicer Web Server API. The filter_type parameter specifies the type of node information to retrieve. Possible values include "names" (node names), "ids" (node IDs), and "properties" (node properties). The default value is "names". The class_name, name, and id parameters are optional and can be used to further filter nodes. The class_name parameter allows filtering nodes by class name. The name parameter allows filtering nodes by name. The id parameter allows filtering nodes by ID. Examples: - List the names of all nodes: {"tool": "list_nodes", "arguments": {"filter_type": "names"}} - List the IDs of nodes of a specific class: {"tool": "list_nodes", "arguments": {"filter_type": "ids", "class_name": "vtkMRMLModelNode"}} - List the properties of nodes with a specific name: {"tool": "list_nodes", "arguments": {"filter_type": "properties", "name": "MyModel"}} - List nodes with a specific ID: {"tool": "list_nodes", "arguments": {"filter_type": "ids", "id": "vtkMRMLModelNode123"}} Returns a dictionary containing node information. If filter_type is "names" or "ids", the returned dictionary contains a "nodes" key, whose value is a list containing node names or IDs. Example: {"nodes": ["node1", "node2", ...]} or {"nodes": ["id1", "id2", ...]} If filter_type is "properties", the returned dictionary contains a "nodes" key, whose value is a dictionary containing node properties. Example: {"nodes": {"node1": {"property1": "value1", "property2": "value2"}, ...}} If an error occurs, a dictionary containing an "error" key is returned, whose value is a string describing the error.

execute_python_code

Execute Python code in 3D Slicer. Parameters: code (str): The Python code to execute. The code parameter is a string containing the Python code to be executed in 3D Slicer's Python environment. The code should be executable by Python's `exec()` function. To get return values, the code should assign the result to a variable named `__execResult`. Examples: - Create a sphere model: {"tool": "execute_python_code", "arguments": {"code": "sphere = slicer.vtkMRMLModelNode(); slicer.mrmlScene.AddNode(sphere); sphere.SetName('MySphere'); __execResult = sphere.GetID()"}} - Get the number of nodes in the current scene: {"tool": "execute_python_code", "arguments": {"code": "__execResult = len(slicer.mrmlScene.GetNodes())"}} - Calculate 1+1: {"tool": "execute_python_code", "arguments": {"code": "__execResult = 1 + 1"}} Returns: dict: A dictionary containing the execution result. If the code execution is successful, the dictionary will contain the following key-value pairs: - "success": True - "message": The result of the code execution. If the code assigns the result to `__execResult`, the value of `__execResult` is returned, otherwise it returns empty. If the code execution fails, the dictionary will contain the following key-value pairs: - "success": False - "message": A string containing an error message indicating the cause of the failure. The error message may come from the Slicer Web Server or the Python interpreter. Examples: - Successful execution: {"success": True, "message": 2} # Assuming the result of 1+1 is 2 - Successful execution: {"success": True, "message": "vtkMRMLScene1"} # Assuming the created sphere id is vtkMRMLScene1 - Python execution error: {"success": False, "message": "Server error: name 'slicer' is not defined"} - Connection error: {"success": False, "message": "Connection error: ..."} - HTTP error: {"success": False, "message": "HTTP Error 404: Not Found"}

capture_screenshot

Capture a screenshot from 3D Slicer's views. This tool provides real-time visual feedback of the current state of Slicer, enabling AI to observe the GUI and make informed decisions in a complete REACT loop. Parameters: view_type (str): Type of screenshot to capture. Options: - "application" (default): Full application window including all panels and views - "slice": A specific slice view (Red/Yellow/Green) - "3d": The 3D rendering view view_name (str): For slice views, specify which view to capture. Options: "red", "yellow", "green" Only used when view_type="slice" slice_offset (float): For slice views, offset in mm relative to slice origin. Only used when view_type="slice" slice_orientation (str): For slice views, specify orientation. Options: "axial", "sagittal", "coronal" Only used when view_type="slice" camera_axis (str): For 3D views, specify camera view direction. Options: "L" (Left), "R" (Right), "A" (Anterior), "P" (Posterior), "I" (Inferior), "S" (Superior) Only used when view_type="3d" image_size (int): Pixel size of output image (for slice and 3D views). Only used when view_type="slice" or view_type="3d" Returns: A list containing text and/or image content. The image is returned in MCP's standard format for proper display in AI clients. Examples: - Capture full application: {"tool": "capture_screenshot", "arguments": {"view_type": "application"}} - Capture Red slice view: {"tool": "capture_screenshot", "arguments": {"view_type": "slice", "view_name": "red"}} - Capture 3D view from anterior: {"tool": "capture_screenshot", "arguments": {"view_type": "3d", "camera_axis": "A"}} - Capture axial slice: {"tool": "capture_screenshot", "arguments": {"view_type": "slice", "view_name": "red", "slice_orientation": "axial"}}

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.

Alternatives

Related Skills

Browse all skills
ui-design-system

UI design system toolkit for Senior UI Designer including design token generation, component documentation, responsive design calculations, and developer handoff tools. Use for creating design systems, maintaining visual consistency, and facilitating design-dev collaboration.

18
ai-sdk

Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".

6
api-documenter

Master API documentation with OpenAPI 3.1, AI-powered tools, and modern developer experience practices. Create interactive docs, generate SDKs, and build comprehensive developer portals. Use PROACTIVELY for API documentation or developer portal creation.

4
openai-knowledge

Use when working with the OpenAI API (Responses API) or OpenAI platform features (tools, streaming, Realtime API, auth, models, rate limits, MCP) and you need authoritative, up-to-date documentation (schemas, examples, limits, edge cases). Prefer the OpenAI Developer Documentation MCP server tools when available; otherwise guide the user to enable `openaiDeveloperDocs`.

4
cli-builder

Guide for building TypeScript CLIs with Bun. Use when creating command-line tools, adding subcommands to existing CLIs, or building developer tooling. Covers argument parsing, subcommand patterns, output formatting, and distribution.

3
ydc-ai-sdk-integration

Integrate Vercel AI SDK applications with You.com tools (web search, AI agent, content extraction). Use when developer mentions AI SDK, Vercel AI SDK, generateText, streamText, or You.com integration with AI SDK.

2