Skip to main content
Glama

Fiji MCP Server

CI PyPI version License

An MCP server that lets an AI assistant work in Fiji/ImageJ: open and save images, find and run installed commands and plugins, run ImageJ macros or Groovy, read the Results table, and check its work with screenshots.

The ImageJ blobs sample before thresholding, the thresholded mask, and their difference

A recorded run on the ImageJ blobs sample: the assistant opened the image, thresholded it with a macro, counted 43 particles, and compared before and after screenshots.

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

get_state

Reports whether Fiji is running, which images are open, and the Results table size.

search_commands

Searches Fiji's installed commands and plugins and shows how each can be called.

run_command

Runs one installed command with its parameters.

run_script

Runs an ImageJ macro (IJM) or a Groovy script.

open_image

Opens a local image and makes it the active one.

save_image

Saves the active image to a new file.

get_results

Reads the Results table, a page at a time.

screenshot

Returns a PNG of the active image or the Results table.

compare_screenshots

Compares two saved screenshots, by eye and by pixel values.

The tool reference lists every argument, return field, and limit.

Related MCP server: Cellpose MCP Server

Install

Needs Python 3.10 or newer and a local Fiji installation.

python -m pip install fiji-mcp-server

Every client below needs two settings: FIJI_PATH, the Fiji folder that contains jars/ and plugins/ (for example /Applications/Fiji), and FIJI_MODE=headless. Fiji starts on the first tool call, which can take a minute.

Connect

Claude Code

claude mcp add fiji -e FIJI_PATH=/Applications/Fiji -e FIJI_MODE=headless -- fiji-mcp-server

Codex

codex mcp add fiji --env FIJI_PATH=/Applications/Fiji --env FIJI_MODE=headless -- fiji-mcp-server

Then set startup_timeout_sec = 120 and tool_timeout_sec = 300 under [mcp_servers.fiji] in ~/.codex/config.toml, so Codex waits for Fiji to start and for long operations.

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

{
  "mcpServers": {
    "fiji": {
      "command": "fiji-mcp-server",
      "env": { "FIJI_PATH": "/Applications/Fiji", "FIJI_MODE": "headless" }
    }
  }
}

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

If a client cannot find fiji-mcp-server, use the full path that which fiji-mcp-server prints (where on Windows).

Use

Open /data/cells.tif, threshold it with Otsu, measure the particles, and show me the Results table and a before-and-after screenshot.

Search the installed commands for "Gaussian Blur" and run it with sigma 2.

Evaluation

The figure above comes from a scripted run of the server on ImageJ's blobs sample: open the image, threshold it with Otsu, measure particles of at least 50 pixels that do not touch the edge, and compare before and after screenshots. Fiji found 43 particles, from 81 to 902 px². An independent count of the saved mask, written without Fiji, finds the same 43 particles with identical areas.

FIJI_PATH=/Applications/Fiji python examples/blobs/run_blobs.py --output my-run
python examples/blobs/check_blobs.py my-run

The recorded run is in examples/blobs/run: every tool call in order, Fiji's Results table, and the check. CI runs the unit and MCP contract tests on Python 3.10–3.12 for every push.

Limits

  • run_script runs any macro or Groovy code with your permissions. Use the server only with a client you trust on your own computer.

  • Headless mode cannot answer dialogs. Plugins that need a dialog, mouse, or keyboard may fail; set FIJI_MODE=gui only when you want Fiji's window.

  • An operation that runs longer than FIJI_OPERATION_TIMEOUT_SEC (default 240 s) stops the server, because Java work cannot be cancelled safely. Restart the client's connection, and keep the client's tool timeout above this value.

  • save_image will not overwrite an existing file; screenshot and compare_screenshots will, so give them new paths when you want to keep old ones.

Development

python -m pip install -e ".[test,dev]"
python -m pytest -m "not integration"

The integration tests need a local Fiji; see tests/test_integration_runtime.py. The changelog lists each release.

Credits and license

Built on Fiji, ImageJ, PyImageJ, and FastMCP. napari-mcp inspired the design. The example image is ImageJ's blobs sample.

The code is BSD-3-Clause; see LICENSE. Image credits and terms are in THIRD_PARTY_NOTICES.md.

Available Tools

19 tools
clear_session_traceA
Read-onlyIdempotent

Clear the in-process session trace (does not close Fiji images).

Inputs: no named parameters. Returns: ok, cleared

compare_screenshotsA
Read-onlyIdempotent

Compare two screenshot_fiji payloads (before/after). Returns mean absolute error and RMSE on aligned grayscale patches plus a side-by-side JPEG for quick visual diff.

Inputs: image_base64_before (required), image_base64_after (required). Returns: ok, mime_type, format, width, +10 more

describe_pluginA
Read-onlyIdempotent

Resolve one command by name and return SciJava input metadata when available. Legacy ImageJ1-only plugins may omit inputs; use run_macro in that case.

Inputs: command_name (required). Returns: ok, command, inputs, inputs_available, +1 more

get_image_infoA
Read-onlyIdempotent

Read dimensions, channel/frame/slice counts, bit depth, and ROI statistics for one image. Uses the front image when image_title is omitted.

Inputs: image_title. Returns: ok, title, width, height, +8 more

get_macro_templateA
Read-onlyIdempotent

Fetch one bundled macro template by id (from list_macro_templates).

Inputs: template_id (required). Returns: ok, template

get_session_traceA
Read-onlyIdempotent

Return recent tool invocations (run_macro, open_image, …) in order plus optional live open-image list. Trace is in-process only (resets when the MCP server restarts).

Inputs: limit, include_open_images. Returns: ok, returned_events, events, open_images, +1 more

health_checkA
Read-onlyIdempotent

Return runtime health: Fiji path, headless/GUI mode, ImageJ version, and configured operation timeout. Use before long jobs to confirm the bridge is alive.

Inputs: no named parameters. Returns: ok, initialized, fiji_path, mode, +2 more

list_all_commandsA
Read-onlyIdempotent

Enumerate Fiji/ImageJ commands from SciJava CommandService and legacy ij.Menus. Large installs return thousands of entries; lower limit for faster responses.

Inputs: limit. Returns: ok, total, returned, commands

list_extensionsA
Read-onlyIdempotent

List configured ImageJ update sites (name and URL) when the updater classes are present. May return an empty list on minimal installs; see note field.

Inputs: no named parameters. Returns: ok, extensions, count, note

list_macro_templatesA
Read-onlyIdempotent

List bundled macro snippets (filters, segmentation, Z-project, channels, optional Fiji plugins) with stable ids. Filter by category: filters, process, segment, analyze, image, annotate, channels, stack, plugins.

Inputs: category. Returns: ok, count, templates

list_open_imagesA
Read-onlyIdempotent

List open image windows with id, title, dimensions, and ImageJ type constant.

Inputs: no named parameters. Returns: ok, count, images

open_imageA

Open an image from disk in Fiji and show it as the active window. Verify the path exists on the MCP host before calling.

Inputs: path (required). Returns: ok, title, width, height, +1 more

parse_macro_outputA
Read-onlyIdempotent

Turn macro return text or a pasted Results snippet into structured JSON: detected format, key/value map, tabular rows, and/or extracted numbers. Prefer macros that return a small JSON or key=value string for best results.

Inputs: text (required), format_hint. Returns: ok, format_detected, parsed_json, values, +2 more

run_batch_macrosA

Run several macros in sequence. On failure, behavior depends on continue_on_error: either stop or record the error and continue. Each successful step returns the same shape as run_macro.

Inputs: macros (required), continue_on_error, retries_per_step. Returns: ok, total_steps, completed_steps, failed_steps, +1 more

run_macroA

Execute ImageJ1 macro text in the current Fiji session. Returns macro return value and a tail of the ImageJ log. Prefer small, focused macros; increase timeout for heavy I/O.

Inputs: macro_code (required), retries. Returns: ok, result, log_tail

run_workflowA

Run a scripted pipeline: each step runs a macro, optionally followed by a screenshot. Supports MCP progress when the client requests it. Use verify_each_step=false for faster runs.

Inputs: steps (required), verify_each_step, continue_on_error. Returns: ok, results, total_steps, failed_steps, +2 more

save_imageA

Save the currently active image to disk using ImageJ's saveAs. Requires an image window to be frontmost in Fiji.

Inputs: path (required), format_hint. Returns: ok, path, title, format

screenshot_fijiA
Read-only

Capture pixels for verification: full_screen (primary monitor via Robot), active_image (current ImagePlus), or results_table (render Measure/Results data). Use active_image or results_table when running headless without a display.

Inputs: capture_mode. Returns: ok, capture_mode, mime_type, format, +4 more

search_commandsA
Read-onlyIdempotent

Search installed commands by substring on name/class, plus fuzzy title matching. Use before describe_plugin to find the exact menu label.

Inputs: query (required), limit. Returns: ok, query, total_matches, matches

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools have distinct purposes, e.g., run_macro vs run_batch_macros vs run_workflow are clearly differentiated by descriptions. Some related tools like describe_plugin and search_commands could cause slight confusion but are still separable.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using snake_case (e.g., clear_session_trace, compare_screenshots, list_open_images). No mixing of styles or ambiguous verbs.

    Tool Count5/5

    With 19 tools, the set is well-scoped for an image processing MCP server covering session management, macro execution, image I/O, and metadata. No signs of bloat or insufficiency.

    Completeness4/5

    The tool surface covers core workflows: image management, macro execution, command discovery, and session tracing. Minor gaps like missing direct close_image or ROI manipulation exist but are manageable via macros.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers