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.
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.
Project links and acknowledgments
- Fiji and ImageJ
- PyImageJ
- FastMCP
- README-structure inspiration: Cellpose MCP
- Related minimal viewer bridge: napari-mcp
- Changelog
License
BSD-3-Clause. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fiji_mcp_server-0.2.0.tar.gz.
File metadata
- Download URL: fiji_mcp_server-0.2.0.tar.gz
- Upload date:
- Size: 39.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1ac3bc968969acfda89287092740cfb0c658b01f00e90e9a88a899fcbec3956
|
|
| MD5 |
42601c9a8eb54a59905fe02246c01299
|
|
| BLAKE2b-256 |
4ea1d31bedffb3c2124182f818187925dd710e7f754b66538a84e8c1d90beb1d
|
Provenance
The following attestation bundles were made for fiji_mcp_server-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on surajinacademia/Fiji_imageJ_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fiji_mcp_server-0.2.0.tar.gz -
Subject digest:
c1ac3bc968969acfda89287092740cfb0c658b01f00e90e9a88a899fcbec3956 - Sigstore transparency entry: 2614644193
- Sigstore integration time:
-
Permalink:
surajinacademia/Fiji_imageJ_mcp@1ec06a3f24e382237c39eef233a045f89f6eb850 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/surajinacademia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1ec06a3f24e382237c39eef233a045f89f6eb850 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fiji_mcp_server-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fiji_mcp_server-0.2.0-py3-none-any.whl
- Upload date:
- Size: 30.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec4f48aa1cf6951f185a8e1fe0ae21ccd13fbb40515bc1a4a5974f5ae012494f
|
|
| MD5 |
4d0a18bc70e4f01d1ce3779b22a3aa65
|
|
| BLAKE2b-256 |
7c3b26680c1cdd34abf30bf4bdccd73b7c82e624f59150390f7ee99fdf9b9721
|
Provenance
The following attestation bundles were made for fiji_mcp_server-0.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on surajinacademia/Fiji_imageJ_mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fiji_mcp_server-0.2.0-py3-none-any.whl -
Subject digest:
ec4f48aa1cf6951f185a8e1fe0ae21ccd13fbb40515bc1a4a5974f5ae012494f - Sigstore transparency entry: 2614644234
- Sigstore integration time:
-
Permalink:
surajinacademia/Fiji_imageJ_mcp@1ec06a3f24e382237c39eef233a045f89f6eb850 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/surajinacademia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@1ec06a3f24e382237c39eef233a045f89f6eb850 -
Trigger Event:
release
-
Statement type: