Content
# mcp-nv-reason-cxr-3b
A [FastMCP](https://github.com/jlowin/fastmcp) server exposing
**NV-Reason-CXR-3B** — a chest X-ray reasoning model — as MCP tools, deployed
via Prefect Horizon. Image preprocessing runs locally on CPU; GPU inference is
dispatched to a **Modal** serverless endpoint, so the container needs no GPU or
model weights.
**Deployed MCP endpoint:** `https://mcp-nv-reason-cxr-3b.fastmcp.app/mcp`
Clients connect to that MCP endpoint; the server in turn calls the **Modal
endpoint** (`MODAL_ENDPOINT_URL`) for inference.
## Tools
| Tool | Description | Returns |
|------|-------------|---------|
| `analyze_cxr` | General radiological analysis with step-by-step reasoning (abnormalities, support devices, findings) | Thinking chain, answer, raw text |
| `reason_cxr` | Targeted reasoning for a specific clinical question | Thinking chain, answer, raw text |
| `health` | Liveness probe | Status |
Both analysis tools return a JSON object with a `thinking` chain, a concise
`answer`, the raw model output, and a research-use disclaimer. Failures report a
`reason` (validation) or `error` (runtime) instead.
### Arguments
- `image_b64` — base64 chest X-ray (JPEG or PNG), minimum 64×64. Resized to a
1280px longest edge before dispatch.
- `image_id` — identifier echoed back for tracing.
- `prompt` — the clinical question. `reason_cxr` requires one; `analyze_cxr`
defaults to general abnormality and support-device detection.
## Configuration
| Variable | Required | Description |
|----------|----------|-------------|
| `MODAL_ENDPOINT_URL` | yes | Modal base URL, e.g. `https://<workspace>--cxr-reasoning-fastapi-app.modal.run` |
| `FASTMCP_DOCKET_URL` | no | Redis URL (`rediss://…`) for background tasks |
## Connecting
Point any MCP client at the hosted endpoint:
```json
{
"mcpServers": {
"nv-reason-cxr-3b": {
"url": "https://mcp-nv-reason-cxr-3b.fastmcp.app/mcp"
}
}
}
```
## Running
To self-host:
```bash
# Docker
docker build -t cxr-mcp .
docker run -p 8080:8080 \
-e MODAL_ENDPOINT_URL=https://<your-modal-endpoint>.modal.run \
cxr-mcp
# Local
pip install -r requirements.txt
export MODAL_ENDPOINT_URL=https://<your-modal-endpoint>.modal.run
python server.py
```
Multi-stage `python:3.11-slim` build, runs as a non-root user, exposes port 8080.
Serves over stateless HTTP with JSON responses; request bodies up to 64 MB.
## Disclaimer
For research and educational use only. Not a medical device; outputs must not be
used for clinical diagnosis or treatment decisions.
## License
Apache License 2.0 — see [LICENSE](LICENSE).