Skip to main content
Glama

MCP-Slicer - 3Dスライサーモデルコンテキストプロトコル統合

英語|简体中文

Pythonバージョン ライセンス: MIT PyPIバージョン

MCP-Slicerは、モデルコンテキストプロトコル(MCP)を介して3D SlicerをClaude DesktopやClineなどのモデルクライアントに接続し、3D Slicerとの直接的な対話と制御を可能にします。この統合により、医用画像処理、シーン作成、そして自然言語を用いた操作が可能になります。

特徴

  1. list_nodes: スライサーMRMLノードを一覧表示およびフィルタリングし、そのプロパティを表示します。

  2. execute_python_code: スライサー環境でPythonコードを実行する

Related MCP server: QGIS MCP

インストール

前提条件

  • 3Dスライサー5.8以降

  • Python 3.13以降

  • UVパッケージマネージャー

Macをお使いの場合は、uvをインストールしてください。

brew install uv

Windowsの場合

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

その後

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

それ以外の場合、インストール手順はウェブサイトに掲載されています: Install uv

⚠️まずUVをインストールしてください

デスクトップ統合のクロード

Claude > 設定 > 開発者 > 構成の編集 > claude_desktop_config.json に移動して、以下を追加します。

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

クライン積分

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

使用法

クロードの設定を確認する

オープンスライサーウェブサーバー

  1. スライサーウェブサーバーモジュールを開き、

  2. 必要なインターフェースがチェックされていることを確認する

  3. サーバーを起動します

例

- list_nodes

スライサーシーンに現在存在するマークアップノードの名前、長さ(線の場合)、角度(角度の場合)をリストします。

- Pythonコードを実行する

スライサー シーンで 8 cm の半透明の緑色の立方体を描画し、その頂点をマークしてから、その中に内接する赤い球体を描画します。

技術的な詳細

既存のSlicer Web Serverインターフェースを活用します。技術的な詳細については、 Slicer Web Serverユーザーガイドをご覧ください。

制限事項とセキュリティに関する考慮事項

  • execute_python_codeツールを使用すると、3D Slicer で任意の Python コードを実行できます。これは強力ですが、潜在的に危険です。

    ⚠️ 本番環境での使用は推奨されません。

  • 複雑な操作は、小さなステップに分割する必要がある場合があります。

貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

免責事項

これはサードパーティの統合プロジェクトであり、3D Slicer チームによって開発されたものではありません。

Available Tools

3 tools
capture_screenshotA

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

Inputs: view_type, view_name, slice_offset, slice_orientation, +2 more.

execute_python_codeA

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

Inputs: code (required).

list_nodesA

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.

Inputs: filter_type, class_name, name, id.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool serves a distinct, non-overlapping purpose: capture_screenshot provides visual feedback, execute_python_code runs arbitrary code, and list_nodes retrieves node information. Their descriptions clearly differentiate their functions, eliminating any confusion about which tool to use for a given task.

    Naming Consistency4/5

    The tools follow a consistent verb_noun pattern (capture_screenshot, execute_python_code, list_nodes), making them predictable and readable. The minor deviation is that 'execute_python_code' uses a verb-object structure instead of a simple verb like 'run', but this is still clear and fits the overall naming style.

    Tool Count3/5

    With only 3 tools, the set feels thin for interacting with a complex application like 3D Slicer. While the tools cover core functionalities (visualization, code execution, and data listing), essential operations like creating, updating, or deleting nodes are missing, limiting the server's scope and utility.

    Completeness2/5

    The toolset is severely incomplete for the domain of 3D Slicer interaction. It lacks basic CRUD operations for nodes (e.g., create_node, update_node, delete_node) and other common actions like loading/saving data or manipulating views. This will cause significant agent failures when trying to perform typical workflows in the application.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      Connects Blender to AI through the Model Context Protocol to enable prompt-assisted 3D modeling and scene manipulation. It supports object creation, material control, and arbitrary Python code execution directly within the Blender environment.
      22
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects Blender to AI assistants through the Model Context Protocol, enabling direct AI control of 3D modeling, scene creation, and manipulation via natural language.
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Connects Blender 3D to AI assistants via the Model Context Protocol, enabling natural language driven 3D scene creation, manipulation, and rendering.
      15
      MIT