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.
MCP-Slicer provides two main capabilities:
Before installing MCP-Slicer, ensure you have:
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.
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"]
}
}
}
Add the same configuration to your Cline configuration file:
{
"mcpServers": {
"slicer": {
"command": "uvx",
"args": ["mcp-slicer"]
}
}
}
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.
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"
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."
MCP-Slicer works by utilizing the existing Slicer Web Server interfaces to communicate between the model client and 3D Slicer.
Please note the following important security limitations:
execute_python_code
tool allows running arbitrary Python code in 3D Slicer, which is powerful but potentially dangerous.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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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