Fiji MCP Server
This server is an MCP bridge that gives AI assistants hands inside Fiji/ImageJ for inspecting, driving, and verifying image-analysis work.
Inspect the environment: health check, Fiji path/mode/version, open image windows, image dimensions/ROI stats, command listings, and extension/update-site info.
Find and understand plugins: search commands by keyword, list all commands, and get detailed parameter metadata for SciJava plugins.
Run code: execute ImageJ1 macro code, run batches of macros, and orchestrate scripted workflows with optional per-step verification.
Work with images: open images from disk, save the active image with a format hint, list open images, and read detailed image metadata.
Verify visually: capture screenshots of the full screen, active image, or Results table, and compare before/after images using MAE, RMSE, and a side-by-side diff image.
Parse output: turn macro return text or Results snippets into structured JSON, key/value maps, tabular rows, or extracted numbers.
Use bundled templates: list and fetch reusable macro snippets for filtering, segmentation, channels, stacks, and other common tasks.
Track activity: view a session trace of recent tool calls and open-image state, and clear the trace when needed.
Allows AI agents to control Fiji/ImageJ for microscopy image analysis, including opening images, applying filters, thresholding, particle analysis, skeletonization, and running macros.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Fiji MCP Server Apply a Gaussian blur with sigma 4 and show me the result."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Fiji MCP Server
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.
Install the server:
python -m pip install "fiji-mcp-server==0.2.0"To test a source checkout instead:
python -m pip install .Locate the Fiji root directory. It must directly contain
jars/andplugins/; on this Mac, for example, it is/Applications/Fiji.Configure your MCP client with
FIJI_PATHandFIJI_MODE=headless; see the client-specific instructions below. The MCP client owns the stdio process and startsfiji-mcp-serverwhen 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 listOr 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 fijiFor 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 listSee 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-serverSave 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 |
| Read Fiji lifecycle, active/open images, and Results-table state. |
| Search registered SciJava and ImageJ1 commands and inspect their routes. |
| Run one resolved installed command with supported parameters or options. |
| Run one trusted IJM or Groovy script. |
| Open an existing local image and make it current. |
| Save the active image to a new exact lowercase supported path. |
| Read an ordered, paginated page from Fiji's live Results table. |
| Return and optionally save a PNG of the active plane or Results. |
| 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 pluginsFiji 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.
Project links and acknowledgments
README-structure inspiration: Cellpose MCP
Related minimal viewer bridge: napari-mcp
License
BSD-3-Clause. See LICENSE.
Available Tools
19 toolsclear_session_traceARead-onlyIdempotent
Clear the in-process session trace (does not close Fiji images).
Inputs: no named parameters. Returns: ok, cleared
compare_screenshotsARead-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_pluginARead-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_infoARead-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_templateARead-onlyIdempotent
Fetch one bundled macro template by id (from list_macro_templates).
Inputs: template_id (required). Returns: ok, template
get_session_traceARead-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_checkARead-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_commandsARead-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_extensionsARead-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_templatesARead-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_imagesARead-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_outputARead-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_fijiARead-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_commandsARead-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
Scored across 19 tools
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.
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.
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.
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
Related MCP Connectors
Image & PDF tools for AI agents: compress, convert, resize, PDF, AI vision, pipeline.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Build and run agents and automations across hundreds of apps using natural language.
Image and video AI tools and your own pipelines, run from any AI assistant.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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 npm105MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to perform cell segmentation through natural language commands, including 2D/3D segmentation, batch processing, image restoration, and custom model training.1221 PyPI2BSD 3-Clause
- AlicenseNot gradedqualityCmaintenanceEnables 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.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to control GIMP for image editing tasks such as opening, resizing, filtering, exporting, and batch processing images through Python-Fu scripting.33 npmMIT