Logo vun Napari MCP Server

Napari MCP Server

Organisatioun
royerlab

🔬 MCP server for AI-powered napari control. Connect Claude, ChatGPT, Cursor, and other LLMs to napari for interactive image analysis. Perfect for automating microscopy workflows and building intelligent image analysis tools.

Editeurroyerlab
Repositorynapari-mcp
SproochPython
Forks
7
StÀren
46
Disponibel Tools
0
Transporttypstdio
Kategorien
LizenzBSD-3-Clause
Linken
  • Tools mat KI-Workflows verbannen

    Napari MCP Server stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopĂ©ieren

    Benotzt d'Installatiounsbeispiller, fir dĂ«se Server an Ärem bevorzugte MCP-Client ze konfigurĂ©ieren.

  • Indicateure fir Open Source

    46 StÀren an 7 Forks aus dem verlinkte Repository.

Napari MCP Server

Tests codecov PyPI version Python 3.10+ License: BSD-3-Clause

MCP server for remote control of napari viewers via Model Context Protocol (MCP). Perfect for AI-assisted microscopy analysis with Claude Desktop and other LLM applications.

https://github.com/user-attachments/assets/d261674c-9875-4671-8c60-a7f49d6f1b84

🚀 Quick Start (3 Steps)

1. Install the Package

bash
pip install napari-mcp

2. Auto-Configure Your AI Application

bash
# For Claude Desktop
napari-mcp-install install claude-desktop

# Include a napari GUI backend in the uv environment
napari-mcp-install install claude-desktop --backend pyqt6

# For other applications (Claude Code, Cursor, Cline, etc.)
napari-mcp-install install --help  # See all options

3. Restart Your Application & Start Using

Restart your AI app and you're ready! Try asking:

"Can you call session_information() to show my napari session details?"

→ See Full Documentation for detailed guides

🔌 Using as a napari Plugin

napari-mcp can also be used as a napari plugin for direct integration with a running napari session:

  1. Start napari normally: napari
  2. Open the widget: Plugins → napari-mcp: MCP Server Control
  3. Click "Start Server" to expose your current session to AI assistants
  4. Connect your AI app using the standard installer: napari-mcp-install install <app>

This mode enables AI assistants to control your current napari session rather than starting a new viewer. Perfect for integrating with existing workflows!

→ See Plugin Guide for detailed instructions

🎯 What Can You Do?

Basic Image Analysis

"Load the image from ./data/sample.tif and apply a viridis colormap"
"Create point annotations at coordinates [[100,100], [200,200]]"
"Take a screenshot and save it"

Advanced Workflows

"Execute this code to create a filtered version:
from scipy import ndimage
filtered = ndimage.gaussian_filter(viewer.layers[0].data, sigma=2)
viewer.add_image(filtered, name='filtered')"

"Install scikit-image and segment the cells in this microscopy image"

3D/4D Navigation

"Switch to 3D display mode"
"Navigate to time point 5, Z-slice 10"
"Create a rotating animation of this volume"

Automated Workflows

Want to automate image processing with Python scripts? Use any LLM (OpenAI, Anthropic, etc.) with napari MCP:

→ See Python Integration Examples for batch processing and workflow automation

đŸ€– Supported AI Applications

ApplicationCommandStatus
Claude Desktopnapari-mcp-install install claude-desktop✅ Full Support
Claude Codenapari-mcp-install install claude-code✅ Full Support
Cursor IDEnapari-mcp-install install cursor✅ Full Support
Cline (VS Code)napari-mcp-install install cline-vscode✅ Full Support
Cline (Cursor)napari-mcp-install install cline-cursor✅ Full Support
Gemini CLInapari-mcp-install install gemini✅ Full Support
Codex CLInapari-mcp-install install codex✅ Full Support

→ See Integration Guides for application-specific instructions

🛠 Available MCP Tools

The server exposes 16 tools for complete napari control:

Core Functions

  • Session Management: init_viewer, close_viewer, session_information
  • Layer Operations: add_layer, list_layers, get_layer, remove_layer, set_layer_properties, reorder_layer, apply_to_layers, save_layer_data
  • Viewer Controls: configure_viewer
  • Utilities: screenshot, execute_code, install_packages, read_output

⚠ Security Notice

!!! warning "Code Execution Capabilities" This server includes powerful tools that allow arbitrary code execution:

- **`execute_code()`** - Runs Python code in the server environment
- **`install_packages()`** - Installs packages via pip

The bridge server binds to `127.0.0.1` (localhost only) with no authentication.
Any local process can invoke these tools.

**Use only with trusted AI assistants on local networks.**
Never expose to public internet without proper sandboxing.

📖 Documentation

đŸ§Ș Development Setup

bash

# Clone repository
git clone https://github.com/royerlab/napari-mcp.git
cd napari-mcp

# Install with development dependencies
pip install -e ".[dev]"

# Run tests
pytest -m "not realgui"  # Skip GUI tests
pytest --cov=src --cov-report=html  # With coverage

đŸ€ Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Run pre-commit hooks: pre-commit run --all-files
  5. Commit changes (git commit -m 'Add amazing feature')
  6. Push to branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

📋 Architecture

  • state.py — ServerState holding all mutable state (viewer, locks, execution namespace)
  • server.py — create_server(state) factory; tools defined as closures over state
  • qt_helpers.py — Qt application and viewer lifecycle management
  • output.py — Output truncation utility
  • bridge_server.py — Plugin bridge server (overrides 3 tools for Qt thread safety)
  • viewer_protocol.py — ViewerProtocol for typed viewer backends
  • cli/ — napari-mcp-install CLI for configuring AI applications

Key features:

  • Thread-safe: All napari operations are serialized
  • Non-blocking: Qt event loop runs asynchronously
  • Stateful: Maintains viewer state across tool calls
  • Extensible: Easy to add new tools

📚 Resources

📄 License

BSD-3-Clause License - see LICENSE file for details.

🙏 Acknowledgments


Built with ❀ for the microscopy and AI communities

Installatioun

TypingMind
{
  "mcpServers": {
    "napari-mcp": {
      "command": "napari-mcp",
      "args": []
    }
  }
}

Napari MCP Server MCP mat verschiddene KI-Modeller benotzen

TypingMind verbĂ«nnt MCP-Tools um Niveau vum AarbechtsberĂ€ich. Soubal Napari MCP Server verbonnen ass, kĂ«nnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. DĂ«s MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dĂ«s Optioun, wann den MCP-Server ZougrĂ«ff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „DĂ«sen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „DĂ«sen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „DĂ«sen Apparat“, kopĂ©iert de Befeel aus TypingMind a fĂ©iert en am Terminal aus. Loosst de Prozess lafen, wĂ€rend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. BestÀtegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wÀrend Dir MCP-Tools benotzt.
3

Napari MCP Server als Server derbÀisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren Ă€nneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren Ă€nneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu Napari MCP Server an.
  4. SpÀichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem KnĂ€ppchen „Serveren Ă€nneren“
{
  "mcpServers": {
    "napari-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

SpĂ€ichert d'ServerlĂ«scht, maacht „Plugins“ op an aktivĂ©iert d'MCP-Tools vu Napari MCP Server. Wielt dann e belibegen Ă«nnerstĂ«tzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'SĂ€it „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu Napari MCP Server.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat Napari MCP Server?
Napari MCP Server
Jo. Ech hunn et gelies.
Dat hunn ech mat Napari MCP Server fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server Napari MCP Server benotzt?

Napari MCP Server ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kĂ«nnt Dir dĂ«se MCP-Server eemol derbĂ€isetzen a seng Tools an Ärem KI-AarbechtsberĂ€ich zur VerfĂŒgung stellen.

Kann ech Napari MCP Server MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum AarbechtsberÀich. Sou kënnt Dir Napari MCP Server mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat Napari MCP Server MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte BenotzeruewerflĂ€che fir LLM-Chat, well et mĂ©i KI-Modeller, Prompts, Plugins, KI-Agenten, API-SchlĂ«sselen a MCP-Tools an engem AarbechtsberĂ€ich zesummebrĂ©ngt. Wann Napari MCP Server verbonnen ass, kĂ«nnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a glĂ€ichzĂ€iteg Är Chataarbecht an TypingMind organisĂ©ieren.

Wéi verbannen ech Napari MCP Server MCP mat TypingMind?

Napari MCP Server leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server ZougrĂ«ff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

WĂ©i eng Tools stellt Napari MCP Server MCP an TypingMind zur VerfĂŒgung?

Napari MCP Server stellt MCP-Funktiounen zur VerfĂŒgung, dĂ©i Dir op der Plugins-SĂ€it vun TypingMind aktivĂ©iere kĂ«nnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir Napari MCP Server MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a lĂ©isst Iech d'Kontroll iwwer Är Modellubidder, API-SchlĂ«sselen, Prompts a MCP-Konfiguratioun. Wann Napari MCP Server eng AuthentifizĂ©ierung verlaangt, setzt dĂ©i nĂ©ideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbĂ€i, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

AbonnĂ©iert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukĂŒnfteg GewĂ«nnspiller informĂ©iert ze ginn 👇