| name | fiji-mcp-workflow |
| description | Run Fiji/ImageJ analysis through the Fiji MCP stdio server—env vars (FIJI_PATH, FIJI_MODE, FIJI_MCP_PYTHON, FIJI_DATA_ROOTS), headless MCP, stdio-safe macros without print(), health_check and tool sequencing, optional batch report script from a fiji-mcp-server checkout. Use for Fiji MCP workflows, microscopy batch reports, or MCP/macro config. |
Fiji MCP workflow
When this applies
Use when driving Fiji/ImageJ through the FastMCP stdio server (python -m fiji_mcp), writing macros for run_macro, or configuring Cursor MCP for image analysis.
Environment (host)
FIJI_PATH: absolute path to the Fiji root (folder with jars/ and plugins/), e.g. /path/to/Fiji.
FIJI_MODE: prefer headless for IDE-hosted MCP; use gui only when you need desktop/Robot capture and have a display.
FIJI_MCP_PYTHON: if a driver (batch script, CI) uses a minimal interpreter, set this to the Python that has pyimagej / scyjava so subprocesses spawn the right env.
FIJI_DATA_ROOTS: optional allowlist (os.pathsep-separated roots). Paths for open_image / save_image must resolve under one root when set.
PYTHONUNBUFFERED=1 on the MCP subprocess so stdio RPC lines flush promptly.
Other useful toggles (see upstream package docs): operation timeouts, screenshot limits, FIJI_LOG_LEVEL (logs on stderr), macro size cap.
Path A — Batch report via MCP only (optional)
If your fiji-mcp-server repository checkout includes the batch driver (often scripts/generate_image_analysis_report.py):
- Activate the same env that runs the server (fastmcp, pyimagej).
- Export
FIJI_PATH, FIJI_MODE=headless, and optionally FIJI_MCP_PYTHON.
- From that repository’s root, run the script with
python (see that script’s CLI for image dirs and outputs).
Use a longer client timeout if cold JVM or large stacks need it (see env docs in the server package).
Path B — Agent-driven session (attached MCP)
Suggested order for a characterization-style pass:
health_check — confirm the bridge before heavy work.
list_extensions, list_all_commands (bounded limit), list_open_images.
search_commands for a small keyword set (e.g. network, particle, segment, threshold) with a low limit.
describe_plugin on an interesting hit when command_name is stable.
- Per image:
open_image → get_image_info → run_macro with a macro that returns one parseable string (do not rely on log scraping for primary metrics).
- Optional:
screenshot_fiji (capture_mode as needed); may fail in headless/display-limited setups.
- Demonstrate
run_batch_macros / run_workflow with trivial return-only steps if useful.
Hard rules (stdio MCP)
- Do not use ImageJ
print() in macros while the server uses stdio: stdout is reserved for JSON-RPC; print() corrupts the session.
- Prefer
return "..."; or tool-native structured results. Same for batch and workflow steps.
- With
FIJI_DATA_ROOTS set, keep open_image / save_image paths under an allowed root.
Extending
- Keep
run_macro return strings bounded and machine-parseable (e.g. delimited fields).
- For wrong interpreter errors (
ModuleNotFoundError: scyjava), fix the MCP command / env so the server starts with the PyImageJ-capable Python.
For install CLIs (fiji-mcp-install), full env reference, and production hardening, use the fiji-mcp-server project README.