Napari MCP Server
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
pip install napari-mcp
2. Auto-Configure Your AI Application
# 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:
- Start napari normally:
napari - Open the widget: Plugins → napari-mcp: MCP Server Control
- Click "Start Server" to expose your current session to AI assistants
- 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
| Application | Command | Status |
|---|---|---|
| Claude Desktop | napari-mcp-install install claude-desktop |
✅ Full Support |
| Claude Code | napari-mcp-install install claude-code |
✅ Full Support |
| Cursor IDE | napari-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 CLI | napari-mcp-install install gemini |
✅ Full Support |
| Codex CLI | napari-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
- Quick Start Guide - Get running in 3 minutes
- Installation Options - Advanced installation methods
- Integration Guides - Setup for specific AI applications
- Python Examples - Automate workflows with custom scripts
- Troubleshooting - Common issues and solutions
- API Reference - Complete tool documentation
🧪 Development Setup
# 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:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with tests
- Run pre-commit hooks:
pre-commit run --all-files - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
📋 Architecture
state.py—ServerStateholding all mutable state (viewer, locks, execution namespace)server.py—create_server(state)factory; tools defined as closures over stateqt_helpers.py— Qt application and viewer lifecycle managementoutput.py— Output truncation utilitybridge_server.py— Plugin bridge server (overrides 3 tools for Qt thread safety)viewer_protocol.py—ViewerProtocolfor typed viewer backendscli/—napari-mcp-installCLI 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
- napari - Multi-dimensional image viewer
- Model Context Protocol - MCP specification
- FastMCP - Python MCP framework
- Claude Desktop - AI assistant with MCP support
📄 License
BSD-3-Clause License - see LICENSE file for details.
🙏 Acknowledgments
- napari team for the excellent imaging platform
- FastMCP for the MCP framework
- Anthropic for Claude and MCP development
- astral-sh for uv dependency management
Built with ❤️ for the microscopy and AI communities
Metadata
Release files for napari-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| napari_mcp-0.1.0.tar.gz | 346.0 kB | With provenance | Details for napari_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| napari_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for napari_mcp-0.1.0-py3-none-any.whl |
Total release size: 403.4 kB
Release files / napari_mcp-0.1.0.tar.gz
| Download URL | napari_mcp-0.1.0.tar.gz |
|---|---|
| Size | 346.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8ca249122ab0bc378b5270f9146d1d427984e4d25567c5b5c54986c21aefc02
|
|
BLAKE2b-256 checksum How to use checksums |
bf042376efbdd79b7526ff7725724c3ab8e98c224022a4126bfb2f8f80402cf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 25, 2026.
Transparency logRelease files / napari_mcp-0.1.0-py3-none-any.whl
| Download URL | napari_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 57.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f91d94084769ef0e16cbc50b5b2afe87a699fa4fd2f22bd59a33a34af8297ae
|
|
BLAKE2b-256 checksum How to use checksums |
621e2581eb097e9968ad284a6aa85a94ec1bda24d1d3d6a9e8e9dc6922785adf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 25, 2026.
Transparency logSecurity for napari-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for napari_mcp-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.