MCP-Slicer - 3D Slicer Model Context Protocol Integration

MCP-Slicer - 3D Slicer Model Context Protocol Integration

site icon
2025.03.24 6
Python3D Slicer集成医学图像处理自然语言控制开发效率
MCP-Slicer是一个将3D Slicer与模型客户端(如Claude Desktop或Cline)通过Model Context Protocol (MCP)集成的工具,支持通过自然语言直接交互和控制3D Slicer。该工具主要用于医学图像处理、场景创建和操作。
View on GitHub

Overview

基本能力

产品定位

MCP-Slicer是一个用于3D Slicer的集成工具,通过MCP协议实现与模型客户端的交互,支持自然语言控制3D Slicer进行医学图像处理和场景操作。

核心功能

  1. list_nodes:列出并过滤Slicer MRML节点,查看其属性。
  2. execute_python_code:在Slicer环境中执行Python代码。

适用场景

  • 医学图像处理
  • 3D场景创建与操作
  • 通过自然语言控制3D Slicer

工具列表

  1. list_nodes:用于查看和过滤Slicer中的节点及其属性。
  2. execute_python_code:用于在Slicer中执行Python代码,实现复杂操作。

常见问题解答

  • 安全性问题execute_python_code工具允许在3D Slicer中执行任意Python代码,具有潜在危险,不建议在生产环境中使用。
  • 复杂操作:可能需要将复杂操作分解为多个小步骤。

使用教程

使用依赖

  • 3D Slicer 5.8或更高版本
  • Python 3.13或更高版本
  • uv包管理器

安装uv

  • Macbash brew install uv
  • Windowsbash powershell -c "irm https://astral.sh/uv/install.ps1 | iex" set Path=C:\Users\nntra\.local\bin;%Path%

安装教程

  1. Claude Desktop集成: 在Claude > Settings > Developer > Edit Config > claude_desktop_config.json中添加以下内容: json { "mcpServers": { "slicer": { "command": "uvx", "args": ["mcp-slicer"] } } }
  2. Cline集成: 在配置文件中添加与Claude Desktop相同的内容。

调试方式

  1. 检查Claude设置:确保在Claude Desktop App中看到相应的slicer工具。
  2. 启动Slicer Web Server
  3. 打开Slicer Web Server模块。
  4. 确保所需的接口已勾选。
  5. 启动服务器。

示例

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

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.

许可证

该项目遵循 MIT 开源许可条款。