You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fuse_examples/imaging/oai_example/README.md
+118Lines changed: 118 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,3 +122,121 @@ You can track the progress of your training/testing using one of the following m
122
122
If ClearML is installed and enabled in your config file (`clearml : True`), you can use it to monitor your results.
123
123
124
124
Choose the method that best suits your workflow and preferences.
125
+
126
+
## MCP Inference for Segmentation and Classification
127
+
128
+
The current inference workflow supports downstream segmentation, downstream classification, or both in one run. It can be used as:
129
+
130
+
- a persistent interactive CLI session backed by a background MCP HTTP server
131
+
- a protocol-level MCP server using the official MCP Python SDK
132
+
133
+
In this example, the workflow is organized as a set of callable tools with clear inputs and outputs:
134
+
135
+
- preprocessing
136
+
- segmentation
137
+
- classification
138
+
- QC visualization
139
+
- result logging
140
+
141
+
The workflow uses the official MCP Python SDK and serves tool-based inference over Streamable HTTP.
142
+
143
+
### Code Organization
144
+
145
+
The inference functionality has been modularized into three main components for better maintainability:
146
+
147
+
-`inference_utils.py`: Contains utilities, data models, configuration handling, and helper functions
148
+
-`inference_tools.py`: Implements the core inference tools (preprocessing, segmentation, classification, visualization) and the MCP inference engine
149
+
-`inference_cli.py`: Main entry point, MCP server setup, and interactive CLI interface
150
+
151
+
### Required Packages
152
+
153
+
Python 3.10 or newer is required for this MCP workflow because `mcp[cli]` does not support Python 3.9.
154
+
155
+
From the repository root, install the project and example dependencies with:
156
+
157
+
```bash
158
+
pip install -e .[examples]
159
+
pip install "mcp[cli]"
160
+
```
161
+
162
+
For this workflow specifically:
163
+
164
+
-`pip install -e .[examples]` makes the local `fuse-med-ml` package importable and installs the example runtime dependencies used here, including `torch`, `numpy`, `pandas`, `matplotlib`, `nibabel`, and `monai`
165
+
-`pip install "mcp[cli]"` adds the MCP server/client SDK used by the interactive CLI and Streamable HTTP server
166
+
-`pydicom` is only needed when your input is a DICOM folder instead of a `.nii` / `.nii.gz` volume, and it is already included in `.[examples]`
By default, this starts a background MCP server and then opens the interactive terminal workflow against that same server. While the session is open, other MCP clients can connect to the same host, port, and path.
175
+
176
+
The default output root is `fuse_examples/imaging/oai_example/outputs/mcp_inference/`. Each run creates a `session_<timestamp>/` folder, and cases are written to neutral subfolders such as `case_0001/`, `case_0002/`, and so on. The original input-derived `case_id` is still preserved inside the CSV/JSON metadata for traceability. A typical session contains per-case NIfTI/PNG/JSON outputs together with a session-level `inference_log.csv`, as summarized below.
177
+
178
+
You can optionally point to a different config or device:
0 commit comments