This repository provides the groundwork for an AI coding skill that assists with
programming questions related to 3D Slicer. The primary piece of
content is SKILL.md which describes how an agent can prepare its environment and what
resources are available for search.
- Read
SKILL.mdfor detailed information about the expected workflow and data sources. - Run the helper script to fetch the required repositories:
chmod +x setup.sh ./setup.sh
- Use the resulting local copies when answering questions by searching for code, files, and community discussions across the cloned repositories.
The slicer-skill directory is intended to be a shared, standalone resource that multiple projects can reference. You should not clone Slicer repositories into your own project directory.
To point your AI agent at the skill, add a section like the following to your
project's configuration file (e.g. CLAUDE.md, AGENTS.md, or equivalent).
Replace /path/to/slicer-skill with the absolute path where you cloned this
repository:
## Slicer Programming Reference
For help answering 3D Slicer programming questions, use the slicer skill located at:
/path/to/slicer-skill
That directory contains `SKILL.md` with instructions for searching Slicer source
code, extensions, discourse archives, and dependency repositories.
**Important:** All slicer-skill data lives in that single shared directory.
Do NOT clone repositories into this project directory.
- If the repos are not yet set up, run `setup.sh` **from within the slicer-skill
directory**:
```sh
cd /path/to/slicer-skill && ./setup.sh
```
- All searches should target paths under `/path/to/slicer-skill/`:
- `/path/to/slicer-skill/slicer-source/`
- `/path/to/slicer-skill/slicer-extensions/`
- `/path/to/slicer-skill/slicer-discourse/`
- `/path/to/slicer-skill/slicer-dependencies/`When using Claude Code, you can
also add the slicer-skill directory to your session with the --add-dir flag:
claude --add-dir /path/to/slicer-skillThis makes the skill and all its data available for searching without copying anything into your project.
This repository includes slicer-mcp-server.py, a self-contained
Model Context Protocol (MCP) server that
runs inside 3D Slicer. It exposes tools such as list_nodes,
execute_python, screenshot, and load_sample_data over HTTP so that MCP
clients (Claude Code, Claude Desktop, Cline, etc.) can interact with a live
Slicer session.
- Open 3D Slicer and paste the contents of
slicer-mcp-server.pyinto the Python console (or run it viaexecfile). - Add the server to your MCP client configuration (
.mcp.json,claude_desktop_config.json, etc.):{ "mcpServers": { "slicer": { "type": "http", "url": "http://localhost:2026/mcp" } } } - Your MCP client can now query the scene, execute code, and take screenshots in Slicer.
To stop the server from within Slicer: mcpLogic.stop()
- mcp-slicer — a standalone
MCP server for 3D Slicer by @zhaoyouj, installable via
pip/uvx. It uses Slicer's built-in WebServer API as a bridge and can be launched outside of Slicer. - SlicerDeveloperAgent — a Slicer extension by Murat Maga that embeds an AI coding agent directly inside 3D Slicer using Gemini, letting users prompt, run, and iterate on scripts and modules without leaving the application. See the Discourse discussion for background.
- NA-MIC Project Week 44 — Claude Scientific Skill for Imaging Data Commons — a project that developed a Claude skill for the Imaging Data Commons (IDC), published at ImagingDataCommons/idc-claude-skill.
- SlicerChat: Building a Local Chatbot for 3D Slicer (Barr, 2024) — explores integrating a locally-run LLM (Code-Llama Instruct) into 3D Slicer to assist users with the software's steep learning curve, investigating the effects of fine-tuning, model size, and domain knowledge (Python samples, Markdown docs, Discourse forums) on answer quality.
The MCP server grants any connected client the ability to execute arbitrary Python code inside your Slicer process. This is powerful but carries significant risk:
- Code execution — A compromised or malicious MCP client can run any code with the full privileges of the Slicer process, including reading and writing files, accessing the network, and installing software.
- Protected Health Information (PHI) — If you are working with patient data or other confidential information, be aware that an MCP client (and the remote AI model behind it) may send and receive data that includes PHI. Ensure you comply with your institution's data-handling policies, HIPAA, and any other applicable regulations.
- Third-party models — Prompts and tool responses may be transmitted to cloud-hosted AI services. Do not assume that data shared through the MCP connection stays local.
We strongly recommend running the MCP server inside a contained environment rather than on your everyday workstation:
- Docker — Use a containerised Slicer such as SlicerDockers or the official Slicer/SlicerDocker.
- Virtual machines — Provision a VM through Jetstream2, vast.ai, AWS, GCP, Azure, or any other cloud provider. This isolates the Slicer process (and any data it loads) from your local machine.
By keeping Slicer and the MCP server in an isolated environment you limit the blast radius of any unintended or malicious actions and reduce the chance of accidentally exposing sensitive data.