feat(mcp): add konfai-mcp, an agent-facing MCP server for KonfAI - #36
Merged
Conversation
…ridge
Reorganise builtin models under konfai/models/{python,yaml} and ship a declarative YAML model
catalog resolved via 'classpath: default|<Name>.yml' and packaged in the wheel: UNet, NestedUNet,
ResNet (weight-exact vs the KonfAI classes), SegResNet/VNet/DynUNet/ResNet18/VGG16/PlainConvUNet
(weight-exact vs MONAI/torchvision/nnU-Net, real pretrained weights load through the new
konfai.utils.pretrained execution-order bridge), a parametric PlainConvUNet for any nnU-Net topology,
an SMP encoder-backed wrapper, the MIND descriptor, and the ClipNormalize block. The model-builder
registry grows curated primitives (norms, activations, transformer blocks); the classpath resolver is
re-rooted to konfai.models.python (short form unchanged). Also folds the mixed-accumulation
double-backward fix and the point-of-use SimpleITK guard that touch network.py/blocks.py.
BREAKING CHANGE: fully-qualified references 'konfai.models.<task>.<Module>:<Class>' become
'konfai.models.python.<task>.<Module>:<Class>' (no compatibility alias).
FocalLoss batch>1 broadcast, BEST-checkpoint optimisation direction, OneHot.inverse batched argmax, Literal defaults, SLURM rendezvous host, ConvNeXt LayerScaler, DDP shard tail, load_state_dict shrink, and a --resubmit warning instead of a silently dropped flag. SimpleITK is guarded at point-of-use so the package imports without the itk extra. Comments unified in English and SPDX headers completed (incl. the app CLI wrappers); the Slicer-facing core API surface is locked by contract tests.
A runnable synthetic-data registration example (train/predict/evaluate on the builtin VoxelMorph), and the Segmentation and Synthesis examples now ship their model in both a declarative YAML and an equivalent Python form (verified weight-identical), with READMEs explaining when each form applies.
Surface task/finetunable/optional-input defaults on app repositories (relayed over the remote server), so an agent can route to a published app, fine-tune it, or run it from its declared inputs; the get_parameters values/constraints contract is locked by tests.
A FastMCP server exposing the full KonfAI loop to LLM agents: dataset discovery/inspection, config authoring with static review and side-effect-free semantic validation in a spawn subprocess, tracked train/predict/evaluate jobs with process-group cancel and traceback-faithful logs, run comparison and leaderboards, published-app integration (describe/infer/fine-tune), and a first-class model catalog (list/inspect a default|<Name>.yml or session model; guidance that prefers the proven catalog and explains what the KonfAI contract buys). Independent package with its own pyproject and CI.
Unit and integration tests for the MCP tools (dataset, config authoring/validation, jobs, apps, catalog discovery) plus a segmentation end-to-end pipeline and a tool-index anti-drift check.
A problem-led MCP usage page, the konfai-experiments agent skill (canonical loop + generated tool reference), and the AGENTS.md guidance for working on the MCP server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds konfai-mcp, an independent FastMCP server that exposes the whole KonfAI loop to LLM agents, plus the app-repository capabilities it drives.
What an agent can do through it
inspect_object_signatureexplains any of them (hyperparameters, loss-attachable outputs, how to adapt); the modeling guidance prefers the proven catalog and states what the KonfAI contract buys over a black-box import.Structure
konfai-mcp/— the independent package (ownpyproject, CI, tests).konfai-appsgains task / finetunable / declared-default surfacing (relayed over the remote server) so an agent can route to, fine-tune, or run an app from its declared inputs.konfai-experimentsagent skill (canonical loop + generated tool reference).Verification
The konfai-mcp suite (unit + integration incl. a segmentation end-to-end pipeline and a tool-index anti-drift check) is green; the app-capability contract is locked by tests.