Skip to content

About

SKILLS.md style information for slicer programing and usage

Resources

Stars

35 stars

Watchers

1 watching

Forks

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.

Search Slicer in your browser

https://pieper.github.io/slicer-skill/ searches the Slicer forum, the Slicer source and its CTK, vtkAddon and SlicerExecutionModel dependencies, by words and by meaning. Forum results show the matching post (with its images) and link to it on the forum; code results show the matching lines and link to them on GitHub at the commit that was indexed. The index is rebuilt every day by a GitHub Action in this repository, and the search runs entirely in the browser: no server, nothing to install.

AI agents can use the same index without any local setup, through the MCP server in static-index/js (see Static search index below).

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, dependency repositories, and NA-MIC Project Week materials.

**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/`
  - `/path/to/slicer-skill/slicer-projectweek/`

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.

Static search index (no local clones)

static-index/ publishes the same ranked search (BM25 + embeddings over the Slicer source, the Discourse archive and the dependencies) as plain files, rebuilt daily and published with its search page at https://pieper.github.io/slicer-skill/. A browser tab, or static-index/js/bin/slicer-skill-search-mcp.mjs as an MCP server, searches it with HTTP Range requests and caches what it fetches. Nothing has to be cloned or indexed locally:

cd /path/to/slicer-skill/static-index/js && npm install
claude mcp add slicer-skill-static -- node /path/to/slicer-skill/static-index/js/bin/slicer-skill-search-mcp.mjs

See static-index/README.md.

Chat with Slicer in the browser: Slicerdome

Slicerdome (try it) is built on this repository: a chat panel next to SlicerWeb (3D Slicer in the browser) whose model searches the static index made here (scripts/build_static_index.py, read in the browser by static-index/js) and runs Python in the live Slicer. It is its own repository, with a copy of the search client and the index published as a release.

License

This project is licensed under the Apache License 2.0.

About

SKILLS.md style information for slicer programing and usage

Resources

Stars

35 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages