Skip to main content
Glama

Cellpose MCP Server

CI PyPI License: BSD-3-Clause

An MCP server that lets an AI assistant segment cells and nuclei with Cellpose: in 2D or 3D, one image or a folder, with optional denoising, deblurring, or upsampling first, and with your own trained models.

Raw image

Segmented by the assistant

Fluorescence image with green cytoplasm and blue nuclei

The same image with each cell outlined and its centre marked

A one-page walkthrough poster (PDF) walks you step by step from setup to your first results, for people who use AI apps but do not code.

Tools

Tool

What it does

load_image_info

Reports an image's shape, data type, and channels.

list_available_models

Lists the Cellpose models you can use.

estimate_cell_diameter

Estimates the typical cell diameter, in pixels.

segment_cells_2d

Segments cells in one 2D image.

segment_cells_3d

Segments cells in a 3D volume.

segment_cells_batch

Segments every image in a folder.

denoise_image, deblur_image, upsample_image

Restore an image before segmenting it.

restore_and_segment

Restores and segments in one step.

save_masks

Saves masks (TIFF, PNG, or NumPy) with an outline PNG and an overlay PNG.

train_segmentation_model

Trains a model on your own images and masks.

For images with more than one channel, say which axis holds the channels (channel_axis) and which channels are the cell and the nuclear signal (channels, counted from 1). The server does not guess.

Related MCP server: cloudcompare-mcp

Install

Needs Python 3.10, 3.11, or 3.12. It installs Cellpose 3.1.1.2; Cellpose 4 lacks the restoration tools.

pip install cellpose-mcp

Connect

Claude Code

claude mcp add cellpose -e KMP_DUPLICATE_LIB_OK=TRUE -e OMP_NUM_THREADS=1 -- cellpose-mcp

Codex

codex mcp add cellpose --env KMP_DUPLICATE_LIB_OK=TRUE --env OMP_NUM_THREADS=1 -- cellpose-mcp

Claude Desktop, Cursor, Gemini CLI, and Antigravity use the same entry:

{
  "mcpServers": {
    "cellpose": {
      "command": "cellpose-mcp",
      "env": { "KMP_DUPLICATE_LIB_OK": "TRUE", "OMP_NUM_THREADS": "1" }
    }
  }
}

Client

Where the entry goes

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows), then restart the app

Cursor

~/.cursor/mcp.json, or .cursor/mcp.json in a project

Gemini CLI

~/.gemini/settings.json, or .gemini/settings.json in a project

Antigravity

Agent panel … menu → MCP Servers → Manage MCP Servers → View raw config

cellpose-mcp-install cursor (or claude-desktop, antigravity, claude-code, vscode) writes the entry for you. If a client cannot find cellpose-mcp, use the full path that which cellpose-mcp prints.

Use

List the available Cellpose models, then segment the cells in /data/sample.tif with cyto2 and save the masks next to it.

Denoise /data/noisy.tif, segment it, and tell me how many cells you found.

Evaluation

A Codex agent ran 12 segmentation tasks through this server on six annotated nuclei images from the public BBBC039 dataset, three times each, alongside a direct Cellpose script that does not use the server. The agent completed all 36 workflows, its masks were pixel-identical to the direct script's in all 30 paired outputs, and it asked for clarification or refused correctly whenever a task required it. Against the annotations, Cellpose reached an object F1 of 0.93–0.97 on five images and 0.44 on one sparse image, in both arms. The evaluation has the design, the per-run and per-image scores, and the limits.

Development

git clone https://github.com/surajinacademia/cellpose_mcp && cd cellpose_mcp
pip install -e '.[test,dev]'
pytest -m 'not slow'

The changelog lists each release.

Credits and license

Built on Cellpose by Carsen Stringer, Marius Pachitariu, and colleagues; please cite Cellpose when you publish results. napari-mcp by the Royer lab inspired the design, and the server uses FastMCP. Written by Suraj Sahu, University of California, Merced.

The code is BSD-3-Clause; see LICENSE. The example images are Cellpose's and are for non-commercial use; see THIRD_PARTY_NOTICES.md.

Available Tools

12 tools
deblur_imageB

Deblur a microscopy image using Cellpose restoration models.

Args: image_path: Path to input image model_type: Restoration model type (deblur_cyto2, deblur_cyto3, etc.) channels: Channel specification diameter: Expected object diameter for scaling gpu: Whether to use GPU acceleration output_path: Optional path to save deblurred image

Returns

Dictionary with deblurring results

Inputs: image_path (required), gpu, channels, diameter, +2 more. Returns: object

denoise_imageA

Denoise a microscopy image using Cellpose restoration models.

Args: image_path: Path to input image model_type: Restoration model type (denoise_cyto2, denoise_cyto3, etc.) channels: Channel specification diameter: Expected object diameter for scaling gpu: Whether to use GPU acceleration output_path: Optional path to save denoised image

Returns

Dictionary with denoising results

Inputs: image_path (required), gpu, channels, diameter, +2 more. Returns: object

estimate_cell_diameterC

Estimate cell diameter from an image using Cellpose size model.

Args: image_path: Path to input image model_type: Model type to use for estimation channels: Channel specification gpu: Whether to use GPU acceleration

Returns

Dictionary with estimated diameter and confidence

Inputs: image_path (required), gpu, channels, model_type. Returns: object

list_available_modelsA

List all available pretrained Cellpose models.

Returns

Dictionary with lists of available models by category

Inputs: no named parameters. Returns: object

load_image_infoB

Get information about an image file.

Args: image_path: Path to image file

Returns

Dictionary with image metadata (shape, dtype, channels, dimensions)

Inputs: image_path (required). Returns: object

restore_and_segmentC

Restore (denoise/deblur) and segment an image in one pipeline.

Args: image_path: Path to input image restoration_model: Restoration model type (oneclick_cyto3, etc.) segmentation_model: Segmentation model type (cyto3, etc.) diameter: Expected cell diameter in pixels channels: Channel specification gpu: Whether to use GPU acceleration output_path_mask: Optional path to save masks output_path_restored: Optional path to save restored image

Returns

Dictionary with combined restoration and segmentation results

Inputs: image_path (required), gpu, channels, diameter, +4 more. Returns: object

save_masksA

Save masks plus outlines and overlay visualizations.

Always writes three outputs: (1) masks in the chosen format, (2) outlines as a binary PNG, (3) overlay PNG (colored masks on image or black).

Args: mask_path: Path to existing mask file output_format: Output format for masks (tif, png, npy) output_path: Optional custom output path for the masks file image_path: Optional path to original image; if provided, overlay is drawn on it save_flows: Reserved for future use (flow fields not saved)

Returns

Dictionary with mask_path, outlines_path, overlay_path, and files_created

Inputs: mask_path (required), image_path, save_flows, output_path, +1 more. Returns: object

segment_cells_2dA

Segment cells in a 2D microscopy image using Cellpose.

Args: image_path: Path to input image file (TIFF, PNG, etc.) model_type: Cellpose model type (cyto, cyto2, cyto3, nuclei, etc.) diameter: Expected cell diameter in pixels (0 = model default) channels: Channel specification [cyto, nuclei] or None for grayscale flow_threshold: Flow error threshold (lower = more masks, may be worse quality) cellprob_threshold: Cell probability threshold (higher = fewer masks) min_size: Minimum cell size in pixels gpu: Whether to use GPU acceleration augment: Use test-time augmentation (flip/rotate) normalize: Normalize image intensities invert: Invert image intensities (for bright background) output_path: Optional path to save masks (default: image_path with _masks suffix)

Returns

Dictionary with segmentation results including cells_detected, output_path, diameter, mask_shape

Inputs: image_path (required), gpu, invert, augment, +8 more. Returns: object

segment_cells_3dB

Segment cells in a 3D volume using Cellpose.

Args: image_path: Path to input 3D image stack (TIFF, etc.) model_type: Cellpose model type diameter: Expected cell diameter in pixels do_3d: Use full 3D segmentation (True) or slice + stitch (False) anisotropy: Z-axis anisotropy factor (z_pixel_size / xy_pixel_size) stitch_threshold: Threshold for stitching masks across slices (if do_3d=False) flow3d_smooth: Smoothing factor for 3D flows channels: Channel specification [cyto, nuclei] or None gpu: Whether to use GPU acceleration output_path: Optional path to save masks

Returns

Dictionary with 3D segmentation results

Inputs: image_path (required), gpu, do_3d, channels, +6 more. Returns: object

segment_cells_batchB

Segment cells in multiple images in batch.

Args: image_paths: List of paths to input images model_type: Cellpose model type diameter: Expected cell diameter in pixels output_dir: Directory to save masks (default: same as input images) gpu: Whether to use GPU acceleration batch_size: Number of images to process in parallel

Returns

Dictionary with batch processing results

Inputs: image_paths (required), gpu, diameter, batch_size, +2 more. Returns: object

train_segmentation_modelA

Train a custom Cellpose segmentation model.

Args: train_dir: Directory containing training images train_labels_dir: Directory containing training masks/labels model_name: Name for the trained model model_type: Base model type (cyto, nuclei, etc.) n_epochs: Number of training epochs learning_rate: Learning rate for training batch_size: Batch size for training test_dir: Optional directory with test images test_labels_dir: Optional directory with test labels gpu: Whether to use GPU acceleration output_dir: Directory to save trained model (default: current directory)

Returns

Dictionary with training results

Inputs: train_dir (required), model_name (required), train_labels_dir (required), gpu, +7 more. Returns: object

upsample_imageB

Upsample a microscopy image using Cellpose restoration models.

Args: image_path: Path to input image model_type: Upsampling model type (upsample_cyto2, upsample_cyto3, etc.) scale_factor: Upsampling factor (typically 2 or 4) channels: Channel specification gpu: Whether to use GPU acceleration output_path: Optional path to save upsampled image

Returns

Dictionary with upsampling results

Inputs: image_path (required), gpu, channels, model_type, +2 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 12 tools

    Disambiguation5/5

    Each tool targets a distinct operation: 2D/3D/batch segmentation are clearly separated by dimension and scope, restoration tools (denoise, deblur, upsample) use distinct model types, and utilities like save_masks and load_image_info are independent. There is no overlapping purpose that would cause an agent to misselect.

    Naming Consistency5/5

    All tool names follow consistent snake_case with a verb_noun pattern (segment_cells_2d, denoise_image, train_segmentation_model, etc.). Naming is uniform and predictable, with clear singular verbs and no mixing of conventions.

    Tool Count5/5

    12 tools is a well-scoped set for a cell analysis server, covering segmentation, restoration, training, model listing, estimation, and utility functions. Each tool serves a clear purpose and the count is within the ideal 3-15 range.

    Completeness3/5

    The surface covers core workflows (segment, restore, train, estimate, save, inspect), but there is a notable gap: after training a custom model, there is no tool to apply that model for segmentation—the segmentation tools only accept pretrained model types. This creates a dead-end in the lifecycle and limits practical use.

    Maintenance

    ActivityMaintained
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers