Skip to content

SKILLS.md style information for slicer programing and usage

Notifications You must be signed in to change notification settings

pieper/slicer-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slicer-skill

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.

Getting started

  1. Read SKILL.md for detailed information about the expected workflow and data sources.
  2. Run the helper script to fetch the required repositories:
    chmod +x setup.sh
    ./setup.sh
  3. Use the resulting local copies when answering questions by searching for code, files, and community discussions across the cloned repositories.

Using the skill from other projects

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/`

Claude Code

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-skill

This makes the skill and all its data available for searching without copying anything into your project.

MCP Server

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.

Quick start

  1. Open 3D Slicer and paste the contents of slicer-mcp-server.py into the Python console (or run it via execfile).
  2. Add the server to your MCP client configuration (.mcp.json, claude_desktop_config.json, etc.):
    {
      "mcpServers": {
        "slicer": {
          "type": "http",
          "url": "http://localhost:2026/mcp"
        }
      }
    }
  3. Your MCP client can now query the scene, execute code, and take screenshots in Slicer.

To stop the server from within Slicer: mcpLogic.stop()

Related projects

Security warning

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.

About

SKILLS.md style information for slicer programing and usage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages