Skip to main content
Glama

Fiji MCP Server

PyPI version Python versions License

Give your AI assistant hands inside Fiji/ImageJ. Fiji MCP Server is a small stdio Model Context Protocol bridge that can open and save images, discover and run installed commands, execute IJM or Groovy, read Results, and verify changes with screenshots.

This README documents v0.2.0. The public surface is deliberately limited to nine tools; Fiji's live command registries and scripting APIs provide the plugin reach without a large custom framework.

Quick start

You need Python 3.10 or newer and a local Fiji installation.

  1. Install the server:

    python -m pip install "fiji-mcp-server==0.2.0"

    To test a source checkout instead:

    python -m pip install .
  2. Locate the Fiji root directory. It must directly contain jars/ and plugins/; on this Mac, for example, it is /Applications/Fiji.

  3. Configure your MCP client with FIJI_PATH and FIJI_MODE=headless; see the client-specific instructions below. The MCP client owns the stdio process and starts fiji-mcp-server when needed.

Fiji starts lazily on the first Fiji-backed tool call. The bridge prefers one compatible JVM bundled inside the selected Fiji installation.

Related MCP server: Cellpose MCP Server

Connect Codex

The official Codex CLI, IDE extension, and ChatGPT desktop app share MCP configuration on the same Codex host. Add this stdio server from a terminal:

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

Or add the equivalent entry to ~/.codex/config.toml (or a trusted project's .codex/config.toml):

[mcp_servers.fiji]
command = "fiji-mcp-server"
startup_timeout_sec = 120
tool_timeout_sec = 300

[mcp_servers.fiji.env]
FIJI_PATH = "/Applications/Fiji"
FIJI_MODE = "headless"

In ChatGPT desktop, you can also open Settings → MCP servers → Add server, choose STDIO, and then restart after saving. See the official Codex MCP documentation for current client controls.

Connect Claude

For Claude Code, use the absolute path reported by which fiji-mcp-server:

claude mcp add \
  --scope user \
  --transport stdio \
  fiji \
  --env FIJI_PATH=/Applications/Fiji \
  --env FIJI_MODE=headless \
  -- /absolute/path/to/fiji-mcp-server
claude mcp get fiji

For Claude Desktop, add this entry to claude_desktop_config.json. On macOS, the file is in ~/Library/Application Support/Claude/. On Windows, it is in %APPDATA%\Claude\. Fully quit and reopen Claude Desktop after saving.

{
  "mcpServers": {
    "fiji": {
      "command": "/absolute/path/to/fiji-mcp-server",
      "args": [],
      "env": {
        "FIJI_PATH": "/Applications/Fiji",
        "FIJI_MODE": "headless"
      }
    }
  }
}

See the official Claude Code MCP guide and Claude Desktop host guide.

Connect Gemini CLI

Gemini CLI supports the same local stdio server. User scope makes it available in all trusted projects:

gemini mcp add \
  --scope user \
  --transport stdio \
  -e FIJI_PATH=/Applications/Fiji \
  -e FIJI_MODE=headless \
  fiji /absolute/path/to/fiji-mcp-server
gemini mcp list

See the official Gemini CLI MCP guide.

Connect Perplexity

Local MCP is currently documented for the Perplexity macOS app from the Mac App Store. The feature is rolling out to paid subscribers. Open Settings → Connectors, install the PerplexityXPC helper, then select Add Connector → Simple. Use Fiji as the server name and this command:

/usr/bin/env FIJI_PATH=/Applications/Fiji FIJI_MODE=headless /absolute/path/to/fiji-mcp-server

Save the connector, wait for Running, and enable it under Sources. Perplexity does not currently document local MCP setup for Windows or standalone Comet. See the official Perplexity local MCP guide.

Try these prompts

Prompt: Open /data/cells.tif, inspect its dimensions and current C/Z/T position, and show me an active-image screenshot.

Prompt: Search the installed Fiji commands for “Gaussian Blur”. Show the best matching command's invocation route and accepted inputs, then run it with sigma 2 only if that parameter is supported.

Prompt: Run an ImageJ macro that thresholds the active image and measures it, then return the Results table in pages of 200 rows.

Prompt: Save a screenshot to /tmp/before.png, apply the chosen threshold, save /tmp/after.png, and compare them. If the expected change is absent, inspect state and logs before adjusting the threshold once; do not blindly repeat a mutation whose outcome is unknown.

Prompt: Use Groovy to call an installed scriptable plugin that is not representable as a structured command, then summarize its bounded result and the active-image state.

Prompt: Save the active image as /data/output/processed.tiff. Do not overwrite an existing file, and report the exact path Fiji created.

What can it do?

  • Inspect and move data: read live state, open a local image, save the active image, and page through the Results table.

  • Use installed commands: search Fiji's SciJava and ImageJ1 registries, then invoke a selected command through structured parameters or legacy options when that route is supported.

  • Reach scriptable plugins: use trusted IJM or Groovy for ROIs, unusual Java inputs, and installed plugins that do not fit the registered command route.

  • Verify visually: render the active plane or Results table, save before and after PNGs, and compare dimensions and same-size pixel metrics.

The server does not install plugins, click dialogs, drive menus, or promise structured parameters for every plugin.

The nine tools

Tool

Purpose

get_state

Read Fiji lifecycle, active/open images, and Results-table state.

search_commands

Search registered SciJava and ImageJ1 commands and inspect their routes.

run_command

Run one resolved installed command with supported parameters or options.

run_script

Run one trusted IJM or Groovy script.

open_image

Open an existing local image and make it current.

save_image

Save the active image to a new exact lowercase supported path.

get_results

Read an ordered, paginated page from Fiji's live Results table.

screenshot

Return and optionally save a PNG of the active plane or Results.

compare_screenshots

Compare two saved raster paths visually and, when sizes match, numerically.

See the complete nine-tool reference for signatures, return fields, limits, and failure behavior.

How it works

AI client ── stdio JSON-RPC ──▶ FastMCP ── serialized bridge ──▶ PyImageJ ──▶ Fiji + installed plugins

Fiji operations share one process-wide lock. Read-only operations receive at most one retry for a small allowlist of transient failures. Commands, scripts, image opens, and saves are never automatically repeated after dispatch.

Safety and limitations

run_script executes trusted arbitrary local code. IJM and Groovy can read or modify anything available to the MCP process, so run this server only for a trusted local client. It is not a remote multi-user service or a sandbox.

Python diagnostics and ordinary Java output are redirected to stderr to protect stdio JSON-RPC. Plugins that require GUI dialogs, mouse/keyboard automation, or unscriptable interaction may fail in headless mode. Use FIJI_MODE=gui only for an intentional local desktop workflow supported by that plugin.

save_image is strict within this MCP server process: its requested suffix must be one of the exact lowercase formats documented in the tool reference, and an output that exists when the serialized save begins is rejected. It is not a cross-process atomic publisher, so another local process can still race that check; use a dedicated output directory when other writers are active. screenshot and compare_screenshots overwrite an existing save_path; use a new path when preserving an existing PNG is required. After any mutation with an unknown outcome, inspect state or take a screenshot before deciding whether to retry.

License

BSD-3-Clause. See LICENSE.

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

    ActivityStale
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to create, modify, and manage Figma designs through natural language commands via a specialized MCP server and plugin bridge. It supports a wide range of operations including element creation, property modification, component management, and accessibility checks.
      4 npm
      105
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to control RELION 5.x cryo-EM structure determination software through natural language, providing 23 tools for the complete single-particle analysis pipeline.
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to control GIMP for image editing tasks such as opening, resizing, filtering, exporting, and batch processing images through Python-Fu scripting.
      33 npm
      MIT