mltree-mcp
This MCP server lets a coding assistant build, run, track, inspect, and share ML/QSAR/GNN workflows as a node DAG with experiment-tree runs.
Initialize a project and register/update pipeline steps with scripts, inputs, outputs, params, and descriptions.
Connect steps into a DAG and retrieve the full pipeline with topological order.
Log runs with params, metrics, artifacts, notes, tags, parent runs, metric history, and data versions.
Check which step inputs changed or are missing, and compare runs by params, metrics, data versions, and script diffs.
Statically scan existing projects to build maps and import existing results as runs.
Execute steps and grid sweeps, stream/follow logs, and cancel runs or sweeps.
Start/finish manual sweeps for trials run outside mltree.
Add notes/tags to steps and runs, and find the best succeeded run by metric.
Summarize GNN model architectures and optionally inspect dataset/checkpoint stats.
Open the browser map viewer and export a self-contained offline HTML map.
Imports PyTorch Lightning lightning_logs/version_* runs, capturing hparams and the last values from each run's metrics.csv so prior training runs appear in the experiment tree.
Imports existing MLflow experiment runs from a project's mlruns/ directory into the experiment tree, capturing each run's params, latest metric values, and status so prior experiments appear as runs alongside new ones.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mltree-mcp scan this project and show me the workflow map"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mltree-mcp
Your ML workflow as a node map, your experiments as a tree — filled in by your coding assistant as it works.
mltree-mcp is an MCP server for Codex, Claude Code and any other MCP client.
While the assistant writes and runs your ML / QSAR / GNN code, it calls mltree tools to:
register each pipeline step (load → clean → featurize / graph-build → split → HPO → train → evaluate) as a node, with its own
.pyscript, inputs, outputs and default params;wire the steps into a DAG;
log every execution as a run with params, metrics and artifacts, branching from a parent run (HPO trials, GNN variants…), so experiments form a mind-map tree instead of being scattered down a notebook.
Everything lives as plain files in your repo under .mltree/, and mltree-mcp view opens a KNIME-style map of it in your browser.



Status: 0.8.0. MCP core, map viewer,
scan_projectfor existing projects, shareable HTML export, running steps and grid sweeps from the map (opt-in), data versions, compare with param changes / curves / code diffs, notes and tags, GNN views, and now PyPI packaging, CI and a multi-project viewer. See the changelog.
Install
Requires Python 3.11+. Works with the MCP Python SDK 1.x (FastMCP) and 2.x (MCPServer).
pip install mltree-mcp # or: uv tool install mltree-mcp
mltree-mcp --version
# or run it without installing
uvx mltree-mcp --versionThe wheel ships the prebuilt viewer, so Node is not needed. From source:
git clone https://github.com/yboulaamane/mltree-mcp
cd mltree-mcp
pip install -e . # or: uv pip install -e ".[dev]"
# straight from the git repo
uvx --from git+https://github.com/yboulaamane/mltree-mcp mltree-mcp --versionThe mltree-mcp command starts a stdio MCP server (that is what Claude Code and Codex expect). Clients launch it for you; you don't run it by hand.
Which project does it use?
The project root is resolved on every call, in this order:
--project <dir>flag /MLTREE_PROJECTenvironment variableCLAUDE_PROJECT_DIR(Claude Code sets this for stdio servers automatically)the server's current working directory
Related MCP server: mlops-mcp-server
Add it to Claude Code
# once on PyPI
claude mcp add mltree -- uvx mltree-mcp
# before that, from your clone
claude mcp add mltree -- uvx --from /path/to/mltree-mcp mltree-mcp
# make it available in every project, or share it with the repo via .mcp.json
claude mcp add --scope user mltree -- uvx mltree-mcp
claude mcp add --scope project mltree -- uvx mltree-mcp
claude mcp list # should show: mltree ... ✔ ConnectedInside Claude Code, /mcp shows the server and its tools. Claude Code passes CLAUDE_PROJECT_DIR, so the store lands in the project you opened.
Add it to Codex
Either use the CLI:
codex mcp add mltree -- uvx mltree-mcp
codex mcp listor edit ~/.codex/config.toml (or a project-scoped .codex/config.toml in a trusted project):
[mcp_servers.mltree]
command = "uvx"
args = ["mltree-mcp"]
# before PyPI: args = ["--from", "/path/to/mltree-mcp", "mltree-mcp"]
startup_timeout_sec = 20 # first uvx run downloads dependencies
# Optional: pin the project instead of using the directory Codex starts in
# [mcp_servers.mltree.env]
# MLTREE_PROJECT = "/home/you/projects/qsar-gnn"In the Codex TUI, /mcp lists active servers. Codex also reads the server's built-in instructions, which tell it when to call each tool.
Use it on an existing project over SSH with Codex
You already have a project on a GPU server: numbered scripts, a utils.py, a notebook or two, some metrics.json
files, maybe mlruns/ or an Optuna study. scan_project builds the map from that code without running any of it.
It parses scripts with Python's ast and reads notebooks as JSON.
1. Install on the server (once):
ssh you@server
pip install --user "git+https://github.com/yboulaamane/mltree-mcp" # or: uv tool install git+https://github.com/yboulaamane/mltree-mcp
mltree-mcp --version2. Register it with Codex on the server, pinned to the project:
codex mcp add mltree -- mltree-mcp --project /path/to/your/project3. Ask Codex to scan it. Start codex in the project and say:
Scan this project with mltree and show me the map. Fix anything the scan got wrong.
Codex calls scan_project (the server instructions tell it to do this first on an existing project). It reviews
the summary and corrects edges or kinds with connect_steps / add_step. You can also scan from the shell:
mltree-mcp scan --project /path/to/your/project --dry-run # preview, writes nothing
mltree-mcp scan --project /path/to/your/project # write .mltree/4. Look at it from your laptop. On the server:
mltree-mcp view --project /path/to/your/project # serves on localhost:8765 on the serverOn your laptop:
ssh -L 8765:localhost:8765 you@server
# then open http://localhost:8765What the scan detects
Signal | How |
Data reads / writes |
|
Params | argparse |
Description | The module docstring, or the notebook's first markdown heading. |
Kind |
|
Utilities | A helper module such as |
Edges | 1) one step's output path matches another's input (exact, glob, or folder); 2) imports of other step modules; 3) notebook section order; 4) file numbering ( |
Notebooks | One step per notebook, or one step per markdown-headed section with |
Existing results → runs tagged |
|
Re-scanning is safe. Steps the scanner owns are refreshed, new scripts become new steps, and nothing is deleted.
A step you or the assistant edited with add_step keeps its description, kind and param values; the scan only adds
new inputs, outputs and param keys. Results are imported once (they are keyed by source). The summary lists new,
updated, merged and unchanged steps, edges, inputs no step produces, outputs no step consumes, skipped files, and
imported runs. Default excludes: virtualenvs, .git, tests/, test_*.py, __pycache__, .mltree,
node_modules, build/, dist/.
The map viewer
mltree-mcp view # project = $MLTREE_PROJECT / cwd
mltree-mcp view --project ~/projects/qsar-gnn --port 8765
# then open http://localhost:8765Or ask the assistant: it calls open_map, which starts the viewer in the background if needed and returns the URL.
Workflow map. Your steps form a DAG, coloured by each step's latest run (grey not run, blue running, green done, red failed). Nodes are laid out automatically (dagre). If you drag them, their positions are saved to the store (
pos_x/pos_y), and Auto layout resets them.Step panel. Click a node to see its inputs, outputs and params, and a read-only editor (Monaco, the VS Code editor) showing the script. A dropdown switches between the current file and the snapshot saved with each run, marked "same as current" or "changed". Below it is the step's runs table.
Experiment tree. All runs form a mind-map built from
parent_run_id. Pick a metric and "lower/higher is better" to highlight the best run (★). You can filter by step.Compare. Tick 2 or more runs anywhere to get a params/metrics table (rows that differ are marked) and a grouped Plotly bar chart.
Live. The page updates by itself as the assistant logs runs, using Server-Sent Events with polling as a fallback. Dark and light themes follow your OS and can be toggled.
The built frontend ships inside the Python package (src/mltree_mcp/static/), so pip install needs no Node. Monaco is bundled too, with no CDN, so it works offline and on air-gapped clusters.

Data versions
Each step's inputs and outputs that are files or folders inside the project are fingerprinted. The fingerprint is
the SHA-256 of the content (a folder hashes its sorted relative path + file hash list) and the version shown is
its first 12 hex characters. Hashes are cached in mltree.db by path, size and mtime, so unchanged files are not
re-read. Files over 4 GiB and folders over 5000 files get a quick digest (size + mtime only, marked ~) instead.
Runs record the versions they used:
log_runrecords inputs and outputs, a run started from the map or byrun_steprecords inputs at start and outputs when it succeeds. Runs imported byscan_projectrecord none (it never runs or reads your data beyond the scan).The step panel's Data versions table compares the files now with the latest run. The node shows ⚠ data changed when an input changed since that run and input missing when one is gone, so you know which steps to re-run.
Compare has a Data versions row group, and the
data_status(step?)tool gives the assistant the same view.Only paths are hashed, never executed or parsed. Paths outside the project are shown by name only in the export.

Compare: param changes, curves and code diff
Tick 2 or more runs (or use the Runs table's Compare):
Param changes: for each run, the params that differ from the first one (
alpha: 1 → 0.5).Params / metrics / data versions table, rows that differ marked, and a grouped bar chart of the ticked metrics.
Curves: step-wise metrics (
MLTREE_METRIClines, orlog_run(history=[{"epoch": 1, "loss": 0.9}, ...])) overlaid per run, with a metric picker and log-y.Code diff of two runs' script snapshots, unified or side by side, hunks or the whole file. It is computed in the browser, so it also works in the HTML export.


Notes and tags
Click + Add note / Edit in a step's panel or a run's panel to write free-text notes (Ctrl+Enter saves, Esc
cancels). Runs also get tags: type one or more (comma-separated) in the run panel's tag box, × removes one. Notes
show as ✎ on map nodes, tree cards and the runs table; the experiment tree's Tag filter dims every run without
that tag. The assistant uses add_note and tag_run, and get_pipeline returns each step's notes and the tags in
use. Notes and tags are in the HTML export (read-only there).
Editing notes doesn't need --allow-run, but the same request checks apply as for runs: an X-MLTree: 1 header,
a loopback Host and, if present, a loopback Origin.

GNN views
For graph-learning steps the step panel gets a Graph model & data section, and the node a chip like
GCNConv ×3 · hidden 64 · global_mean_pool or 20 graphs.
Architecture summary (static). mltree parses the step's script and the project modules it imports (it never imports or runs them). For
torch.nn.Modulesubclasses that use PyTorch Geometric or DGL layers it lists the layers in__init__(type, library, in → out channels, heads, repeats fromfor _ in range(num_layers)/ModuleListcomprehensions), the readout / pooling and the order the layers are called inforward. Prebuilt models (GCN(in, hidden, num_layers),GAT,GIN, …) and literal / default / module-constant dimensions are resolved; anything else is shown as the source text.Dataset stats (opt-in introspection). The section lists dataset classes the script uses (
TUDataset,MoleculeNet,DGLDataset, …) and.pt/.bingraph files among the step's outputs. Inspect dataset… loads the file in a separate Python process (--python/$MLTREE_PYTHONwith torch installed) without importing your code, and caches: number of graphs, nodes / edges min/mean/max, node and edge feature sizes, self loops, isolated nodes, average degree, labels (classes and counts, or the regression range) and train/val/test masks. Astate_dictcheckpoint gives tensor shapes and the parameter count. Stats are marked stale when the file changes. This loads data withtorch.load(which can run code embedded in a pickle ifweights_only=Truefails), so it needsview --allow-run,MLTREE_ALLOW_RUN(MCPgnn_summary(introspect=true)) or the explicit CLI:
mltree-mcp gnn --project . --step featurize # static summary + cached stats (JSON)
mltree-mcp gnn --project . --step featurize --introspect --python ~/envs/pyg/bin/pythonBroken or unusual scripts never break the map; the section just shows less. The export keeps the summaries and cached stats (not the source fragments when scripts are left out) and never offers introspection.


On a remote server or HPC cluster
The viewer binds to 127.0.0.1 by default. Run it on the server and tunnel the port from your laptop:
# on the server (or let the assistant call open_map there)
mltree-mcp view --project ~/projects/qsar-gnn
# on your laptop
ssh -L 8765:localhost:8765 you@server
# open http://localhost:8765Use --host 0.0.0.0 only on a network you trust. The viewer has no authentication; without --allow-run its only
writes are node positions and notes/tags, and notes/tags are refused unless the request comes through a loopback
Host (an SSH tunnel). --allow-run refuses any bind other than 127.0.0.1, so run steps through the SSH tunnel.
Several projects in one viewer
One viewer can serve several projects, with a switcher in the header. Each project gets its own URL prefix
(/p/<slug>/), API, live stream and run manager, so tabs on different projects work side by side.
mltree-mcp view --projects ~/projects/qsar-egfr ~/projects/tox21-gnn
# or register them once (stored in ~/.mltree/projects.json, or $MLTREE_HOME/projects.json)
mltree-mcp projects add ~/projects/qsar-egfr --name "QSAR EGFR"
mltree-mcp projects add ~/projects/tox21-gnn
mltree-mcp projects list
mltree-mcp projects remove tox21-gnn # by folder or by name
mltree-mcp view --projects # serves everything in the registryhttp://localhost:8765/ redirects to the first project, GET /api/projects lists them all (name, steps, runs), and
every route in the HTTP API is available under /p/<slug>/. --allow-run and the edit guards apply
per project exactly as in single-project mode. When the assistant calls open_map and a multi-project viewer is
already running on the port, it links to that project's page (or warns if the project isn't in the viewer).
The registry file is plain JSON:
{"projects": [{"path": "/home/you/projects/qsar-egfr", "name": "QSAR EGFR"}, {"path": "/home/you/projects/tox21-gnn"}]}
Run steps from the map
Start the viewer with --allow-run and each node gets a ▶ button, and the step panel gets ▶ Run… and Grid sweep…:
mltree-mcp view --project ~/projects/qsar-gnn --allow-run # Python: see "Which interpreter" below
mltree-mcp view --project ~/projects/qsar-gnn --allow-run --python ~/miniconda3/envs/gnn/bin/python
Run dialog. The params are prefilled from the step's last run, or from its scanned / declared params. You can edit them, add extra CLI arguments and see the exact command before you launch. A checkbox confirms that you know it executes the script on this machine (remembered for the browser tab).
Live log. stdout and stderr stream into a panel at the bottom, over Server-Sent Events, with stderr in red. Cancel sends SIGTERM, then SIGKILL after 5 s. Closing the page doesn't stop the run, and reopening it re-attaches.
Automatic record. Every run is logged by itself: params, the script snapshot (SHA-256 and git commit), the exact command, exit code, duration, the full log (
.mltree/runs/<id>/log.txt) and metrics. A failed exit code marks the run failed, and its last stderr lines go into the notes. A run branches in the experiment tree from the newest succeeded run of an upstream step, soevaluatehangs under thetrainrun that made its model.

How params reach your script. mltree reads the script (it doesn't run it) to choose a style:
Script uses | Params passed as |
|
|
| positional values, in that order |
|
|
none of these | environment only |
Every run also gets the following environment variables, so params the CLI doesn't declare still arrive and the dialog warns about them:
Variable | Value |
| all params as JSON |
| one param, with the name upper-cased |
| the run, the step, the project root |
|
|
Runs use the project root as the working directory, with python -u (unbuffered output).
Which interpreter. --python, else $MLTREE_PYTHON, else the project's .venv/ or venv/, else the active
$VIRTUAL_ENV / $CONDA_PREFIX, else python3 on PATH.
Reporting metrics. Print lines like these. Nested JSON is flattened to val.rmse.
print(f"MLTREE_METRIC epoch={epoch} train_loss={loss:.4f} val_rmse={rmse:.4f}") # key=value pairs
print("MLTREE_METRIC " + json.dumps({"val": {"rmse": rmse, "r2": r2}})) # or a JSON objectAlternatively, write a JSON dict to $MLTREE_METRICS_FILE (or to a metrics*.json file the step declares as an output).
The last value of each metric becomes the run's metric; a file overrides printed values. Every MLTREE_METRIC line is
also kept as one point of a step-wise history (.mltree/runs/<id>/metrics_history.jsonl, GET /api/runs/{id}/history),
which will feed the loss-curve overlays. Lines without the prefix are just log, so the script still works without mltree.
Sweeps
Grid sweep… takes comma-separated values per param (0.05, 0.2, 0.5), a metric to rank by, and lower or higher
is better. It shows how many runs the grid makes (64 at most by default) and then runs them one after another as
children of a sweep run. The log panel shows the progress, a child table with the best one starred, and each
child's log. Cancel stops the current child and skips the rest.

In the experiment tree a sweep is one card: its label, the number of runs, ✓/✗ counts and the best value. The children fan out below it with the best child highlighted (★ sweep best). Sweeps with more than 8 children start folded to the best one. ▸ unfold shows them all.

Sweeps also come from:
scan_project: an Optuna study becomes a sweep with its trials as children, ranked by the study's direction. A scikit-learnGridSearchCV/RandomizedSearchCVcv_results_CSV becomes a sweep over itsparam_*columns, ranked bymean_test_score.The assistant:
run_sweepruns a grid for you. For trials it runs itself (Optuna, a manual loop), it callsstart_sweep, thenlog_run(..., sweep_id=...)per trial, thenfinish_sweep.
Safety model
Running code from a browser page is the one dangerous thing the viewer can do, so it takes several locks:
Off by default. Without
--allow-runevery run/sweep/cancelPOSTreturns 403 and the buttons are greyed out. The shareable HTML export never has them.Loopback only. With
--allow-runthe viewer won't bind anything but127.0.0.1. Use an SSH tunnel for remote machines.No cross-site requests. Each
POSTneeds anX-MLTree: 1header, which a plain form or a cross-origin page can't send without a CORS preflight that mltree never approves. It also needs a loopbackHost(this defeats DNS rebinding) and, if anOriginheader is present, a loopbackOrigin.Only the project's own scripts. A step's
.pyscript_pathmust resolve inside the project. Nothing is run through a shell, and params become separate argv entries.An explicit confirm in the dialog for each tab session.
scan_project still never executes anything.
The MCP tools run_step / run_sweep are allowed by default, because the assistant can already run commands in your
shell. Set MLTREE_ALLOW_RUN=0 in the server's environment to turn them off, for example on a shared machine.
HTTP API
Route | Returns |
| project, root, |
| nodes (params, script, position, latest run status), edges, order |
| body |
| one node |
| current script, or the snapshot stored with a run |
| runs of the step that carry a script snapshot |
| runs, newest first |
| one run |
| run forest (runs, edges, roots) and the best run |
| runs, param/metric keys and which ones differ |
| numeric metric names |
| the shareable single-file HTML (as a download) |
|
|
| command preview, param-passing style, form defaults, warnings |
|
|
|
|
| cancel a run or a whole sweep |
| runs and sweeps in progress in this viewer |
| log lines |
|
|
| step-wise metrics ( |
| data versions of every step (or one): each input/output now vs the latest run, |
|
|
|
|
| static model summary, dataset candidates, cached stats |
| load the step's graph file(s) in a subprocess and cache stats (needs |
With view --projects, every route above lives under /p/<slug>/ and the root has GET /api/projects (slug, name,
root, url, steps, runs) and GET /api/health (multi: true, the project roots).
The POST and PUT routes need the X-MLTree: 1 header (see Safety model).
Share the map
Export ▾ in the viewer header gives you:
Shareable HTML: one self-contained
<project>-mltree.htmlfile. It opens offline in any browser by double-click, with no server, no install and no network requests. It is read-only and includes the workflow map, the step panel with each script (current file and the snapshot stored with every run), the experiment tree and the compare view. It inlines a lighter build of the viewer: a small highlighted code view instead of Monaco and SVG bar charts instead of Plotly. The bundled demo exports to about 530 KB: ~500 KB of app and the rest data, with scripts deduplicated by SHA-256.docs/example-export.htmlis a sample.Shareable HTML without scripts: the same file with the code left out.
Map as PNG / SVG: an image of the current map view (pan and zoom first), for slides and papers.
From the shell or through the assistant:
mltree-mcp export --project /path/to/project # -> ./<project>-mltree.html
mltree-mcp export --project /path/to/project -o share/map.html --no-scriptsexport_map(path=None, include_scripts=True) # MCP tool; returns {"path", "bytes", "size", ...}The MCP tool writes to <project root>/<project>-mltree.html by default. On a remote server, copy the file to
your machine with scp you@server:/path/to/project/<project>-mltree.html .
Ways to send it
Email or Slack. Attach the
.htmlfile. The recipient downloads it and opens it in a browser. (Previews inside Slack or a mail client won't run it; it has to be opened in a browser.)GitHub Pages. Commit it as
docs/index.html(or any.htmlin a Pages-enabled repo) and share the URL.Gist.
gh gist create --secret myproj-mltree.html, then open it through a raw-HTML viewer such ashttps://gist.githack.com/(gist.github.com itself shows HTML as source).
Warning: the export contains your scripts. The default file embeds the full source of every step script and every run's script snapshot, plus params, notes, tags and artifact paths. If any of that is private (unpublished methods, internal paths, credentials someone hard-coded), use Shareable HTML without scripts, or
--no-scripts/include_scripts=false, and don't publish the file on a public Pages site or a public gist. The absolute project path on the server is never included.*-mltree.htmlis in this repo's.gitignore; add it to yours too so an export isn't committed by accident.
Tools
Tool | What the assistant uses it for |
| Write the single-file, offline, read-only HTML of the map and return its path and size. It includes the scripts unless |
| Build the map of an existing project by static analysis (never runs your code): steps, params, edges, utilities, and existing results imported as runs. Idempotent; |
| Create |
| Register a node, or update it if the name exists. Script paths are relative to the project and may not escape it. |
| Add an edge. Both steps must exist; self-loops and cycles are rejected; warns when outputs and inputs don't match. |
| Nodes (script, params, latest run status, run count), edges and a topological order. |
| Execute the step's script and record the run by itself: params, snapshot, command, exit code, duration, log and metrics. Returns the run and the log tail. Off with |
| Run every grid combination one after another as children of a sweep run, and return the best one. |
| Follow or stop a run or sweep started with |
| Group trials that the assistant runs itself: |
| Record a run. Metrics must be numbers. Artifacts ≤ 50 MB are copied into |
| Data versions now vs each step's latest run: which inputs changed or are missing, so the assistant knows what to re-run. |
| Param changes, differing metrics and data versions of 2+ runs, and a unified diff of the first two runs' scripts. |
| Runs, newest first. |
| Append to (or replace) the notes of a step or a run. |
| Add / remove tags on a run, or set the whole list. |
| GNN architecture summary (static) and dataset stats of one step or all; |
| Best succeeded run by a metric. |
| URL of the map viewer. It starts |
Resource: mltree://pipeline — the same JSON as get_pipeline.
Errors come back as normal MCP tool errors with a message the assistant can act on (e.g. "Unknown step 'trian'. Known steps: split, train").
Project layout
your-project/
├── steps/ # one script per node (your code)
│ ├── featurize.py
│ └── train_gcn.py
└── .mltree/
├── pipeline.yaml # nodes, edges, default params — commit this
├── mltree.db # SQLite: steps, edges, runs, file-hash cache
└── runs/<run_id>/
├── run.json # params, metrics, parent, status, timestamps
├── script.py # snapshot of the step script for this run
├── log.txt # stdout/stderr of runs started by mltree (stderr lines prefixed)
├── metrics.json # $MLTREE_METRICS_FILE, if the script wrote it
├── metrics_history.jsonl # one line per MLTREE_METRIC print (or log_run history point)
└── artifacts/ # copied outputs (plots, small models…)mltree.db is the source of truth; pipeline.yaml is rewritten on every change so it diffs well in git. If you commit only pipeline.yaml, a fresh clone rebuilds the steps and edges from it. Whether you commit mltree.db and runs/ is up to you.
Tell your assistant to use it (AGENTS.md / CLAUDE.md)
Codex reads AGENTS.md, Claude Code reads CLAUDE.md. Paste this into either:
## Experiment tracking with mltree (MCP)
This repo tracks its ML workflow with the `mltree` MCP server. Keep the map up to date as you work:
- At the start, call `get_pipeline`. If the project is not initialized and already has code, call `scan_project`
(`dry_run=true` first to preview) and fix its proposals; for a brand-new project call `init_project`.
- Put each pipeline stage in its own script under `steps/` (e.g. `steps/split.py`, `steps/train_gcn.py`).
Whenever you create or materially change one, call `add_step` with its name, `script_path`,
`inputs`, `outputs`, default `params` and a one-line `description`.
- Call `connect_steps` for every data dependency (upstream → downstream).
- After every execution of a step, call `log_run` with the exact `params` used, numeric `metrics`,
produced `artifacts` (plots, model files) and `status` ("failed" if it crashed, with the error in `notes`).
- When a run is a variation of an earlier one (HPO trial, new architecture, different split seed),
pass that run's id as `parent_run_id` so the experiment tree branches correctly.
- Prefer `run_step` over running a step script yourself: it records the run (params, script, log, metrics) by
itself. Make scripts print `MLTREE_METRIC name=value` lines. For a grid search use `run_sweep`. For trials you
run yourself (Optuna), use `start_sweep`, then `log_run(..., sweep_id=...)`, then `finish_sweep`.
- Before re-running, call `data_status` to see which steps have changed inputs; to explain how two runs differ,
call `compare_runs`.
- To answer "which model was best?" use `best_run` (mode "min" for losses/RMSE, "max" for AUC/R²)
and `list_runs`; don't guess from memory.
- Record decisions with `add_note` (on the step or run) and label runs with `tag_run` ("baseline", "paper").
- When the user wants to see the workflow, call `open_map` and give them the URL. When they want to send it to
someone, call `export_map` (warn them that it includes the scripts unless `include_scripts=false`).Demo: a tiny GNN pipeline
examples/gnn_demo/ is a toy molecular-property pipeline: load SMILES → featurize to graphs → split → train a toy GCN (mean aggregation + ridge, stdlib only) → evaluate. It runs without torch; featurize.py uses RDKit if installed.
cd examples/gnn_demo
python steps/load_smiles.py && python steps/featurize.py && python steps/split.py 0.2 42 \
&& python steps/train.py 1.0 && python steps/evaluate.py
# register the steps and log a few FAKE runs (tagged "demo") to see the tree
python register_demo.py --reset
mltree-mcp view --project . # http://localhost:8765
mltree-mcp view --project . --allow-run # same, with Run / Grid sweep buttons (the demo needs only the stdlib)With --allow-run, run load_smiles → featurize → split → train → evaluate from the map, then try Grid sweep…
on train with alpha = 0.05, 0.2, 0.5, 1, 2 and rank by train_rmse (lower is better).
The values in data/molecules.csv and the metrics logged by register_demo.py are illustrative demo data, not real measurements.
Development
uv venv && uv pip install -e ".[dev]"
pytest -qThe tests cover:
the store, and every tool called in-process through the MCP server
the
mltree://pipelineresource and the demoa smoke test that launches the stdio server and talks to it with the MCP client SDK
every viewer API route, the SPA fallback, the live event stream and
open_mapthe runner (CLI detection, param passing, metric parsing, logs, cancel, grid sweeps, schema migration) and the run safety guard (403 without
--allow-run, withoutX-MLTree, with a foreignOriginorHost)data versions, compare/diffs, notes/tags, GNN summaries (static and introspected) and the HTML export (with a headless-Chrome render check when Playwright is installed)
the multi-project registry,
/p/<slug>/routing, theprojectsCLI andopen_mapagainst a multi-project viewer
Frontend (React + TypeScript + Vite + React Flow + Monaco + Plotly) lives in frontend/:
cd frontend && npm install
npm run dev # http://localhost:5173, proxies /api to a running `mltree-mcp view`
npm run build # type-checks and writes the bundle into src/mltree_mcp/static/ (commit it)CI (.github/workflows/test.yml) runs pytest on Python 3.11–3.13 (plus macOS and the 1.x MCP SDK), checks that the
committed static/ bundle matches npm run build, and builds the sdist and wheel, runs twine check and installs
the wheel in a clean venv.
Screenshots: pip install -e ".[screenshots]" && playwright install chromium, start the viewer on the demo, then python scripts/screenshots.py. For the run screenshots, start it on a fresh copy of the demo with --allow-run and run python scripts/screenshots_run.py (this really runs the demo scripts); for the data-version / curves / diff screenshots run python scripts/screenshots_data.py --project <copy> the same way; for the notes / GNN screenshots start it with --allow-run --python <python with torch_geometric> and run python scripts/screenshots_gnn.py; for the project switcher and docs/demo.gif, register two copies of the demo, start view --projects and run python scripts/screenshots_projects.py (needs ffmpeg). If you have a local Chrome, use --chrome /usr/bin/google-chrome instead of installing Playwright's browser.
Roadmap
MCP core ✅
Map viewer ✅ (map, script panel with run snapshots, experiment tree, compare, live refresh)
scan_project✅ (static import of existing projects and their MLflow / Optuna / Lightning / wandb results)Run steps and sweeps ✅ (0.5.0: Run button, live logs, auto-recorded runs, grid sweeps, sweep fans,
run_step)Data versioning and compare ✅ (0.6.0: input/output hashes per run, changed-input flags, param changes, code diff, metric curves)
Notes, tags and GNN views ✅ (0.7.0: editable notes/tags, static architecture summary, opt-in dataset stats)
PyPI packaging, CI, multi-project viewer ✅ (0.8.0)
Releasing
Releases go to PyPI from .github/workflows/release.yml with trusted publishing
(no API token). One-time setup:
On PyPI, under Your projects → Publishing → Add a new pending publisher, enter: project
mltree-mcp, owneryboulaamane, repositorymltree-mcp, workflowrelease.yml, environmentpypi. (Optional: the same on TestPyPI with environmenttestpypi.)On GitHub, Settings → Environments: create
pypi(andtestpypi); adding yourself as a required reviewer makes every upload wait for your click.
To release: bump version in pyproject.toml, src/mltree_mcp/__init__.py and frontend/package.json, rebuild the
frontend, commit, then publish a GitHub release with tag vX.Y.Z (gh release create v0.8.0 --generate-notes).
The workflow checks the tag matches the version, builds, runs twine check and uploads. Actions → release → Run
workflow uploads to TestPyPI instead. Locally: python -m build && twine check --strict dist/*.
Changelog
0.8.0
Multi-project viewer:
mltree-mcp view --projects DIR ...or a registry (~/.mltree/projects.json, managed withmltree-mcp projects add|list|remove); each project under/p/<slug>/, a project switcher in the header,GET /api/projects;open_maplinks into a running multi-project viewer.PyPI-ready packaging: classifiers, project URLs,
py.typed, a lean sdist; the wheel ships the viewer and export bundles.python -m build+twine check --strictpass.CI: GitHub Actions test matrix (3.11–3.13, macOS, MCP SDK 1.x), frontend bundle freshness check, wheel smoke test; release workflow with PyPI trusted publishing.
README: demo GIF, badges, refreshed screenshots.
0.7.0
Notes on steps and runs and tags on runs, editable in the viewer (loopback +
X-MLTreeonly), shown on nodes, tree cards and the runs table, with a Tag filter in the experiment tree; MCP toolsadd_note,tag_run;get_pipelinereturns notes and tags; both are in the export.GNN views: static
nn.Modulearchitecture summary for PyG / DGL models (layers, dims, repeats, pooling, forward order) and opt-in dataset / checkpoint stats loaded in a subprocess; MCP toolgnn_summary, CLImltree-mcp gnn,GET /api/steps/{step}/gnn,POST …/gnn/introspect. The demo gets a PyGMolGCNmodel file.Store schema v4 (step
notes,gnn_statscache).
0.6.0
Data versions: inputs/outputs are fingerprinted (SHA-256, cached by size + mtime) and recorded with each run; the step panel, the node badge (⚠ data changed / input missing), Compare and the export show them.
Compare: param changes per run, a data-versions row group, overlaid step-wise curves (SVG, works offline) and a unified / side-by-side code diff of the script snapshots (computed in the browser, works in the export).
MCP tools
data_statusandcompare_runs;log_run(history=, record_data=);GET /api/data.Store schema v3 (run
data,file_hashescache); older databases migrate on open.The viewer runs file hashing off the event loop, so live updates keep flowing on big data folders.
0.5.0
Run steps from the map (
view --allow-run): Run dialog with prefilled params and a command preview, live stdout/stderr panel (SSE), Cancel, and automatic run records (params, snapshot, command, exit code, duration, log, metrics fromMLTREE_METRIClines or$MLTREE_METRICS_FILE, step-wise history).Grid sweeps: sweep runs that group their children, a sweep launcher in the viewer, collapsible sweep fans with the best child highlighted in the tree, and sweep cards in the HTML export.
MCP tools
run_step,run_sweep,run_log,cancel_run,start_sweep,finish_sweep, andlog_run(sweep_id=).scan_projectimports Optuna studies andGridSearchCVcv_results_CSVs as sweeps.Store schema v2 (run
kind,sweep_id,sweep,command,exit_code); v1 databases migrate on open.Export: commands are made portable (interpreter basename, project-relative paths).
0.4.0 shareable single-file HTML export · 0.3.0 scan_project · 0.2.0 map viewer · 0.1.0 MCP core
License
MIT © Yassir Boulaamane
Available Tools
21 toolsadd_noteA
Add a note to a step or a run, e.g. why a run failed, what a step assumes, or a conclusion from a comparison. Notes show in the viewer (where the user can edit them), in get_pipeline / list_runs and in the HTML export.
Inputs: text (required), step, run_id, replace. Returns: object
add_stepB
Register a pipeline step (a node on the map), or update it if the name already exists.
Inputs: name (required), inputs, params, outputs, +2 more. Returns: object
best_runB
Find the best succeeded run by a metric.
Inputs: metric (required), mode, step. Returns: object
cancel_runB
Stop a run (SIGTERM, then SIGKILL after 5 s) or a whole sweep started from this session.
Inputs: run_id (required). Returns: object
compare_runsA
Compare runs: params that differ (baseline -> each run), metrics side by side, data versions used, and a unified diff of the script snapshots of the first two runs.
Inputs: run_ids (required), code_diff. Returns: object
connect_stepsA
Draw a directed edge source -> target. Both steps must exist; cycles are rejected.
Inputs: source (required), target (required), label. Returns: object
data_statusA
Data versions: the current SHA-256 of every step's input and output files, what the step's latest run used, and which inputs changed since (so the step is stale and should be re-run). Reads files only; runs nothing.
Inputs: step. Returns: object
export_mapA
Write a single self-contained HTML file of the map (steps, code, runs, experiment tree, compare).
It opens offline in any browser, read-only, with no server, so the user can email it, post it in Slack or host it on GitHub Pages / a gist. Returns the file path and size. It contains the scripts unless include_scripts=false: tell the user that before they share it.
Inputs: path, include_scripts. Returns: object
finish_sweepB
Mark a sweep finished and return its summary (trial counts and the best trial).
Inputs: sweep_id (required), status. Returns: object
get_pipelineB
Return the whole map: nodes (with params, script and latest run status), edges and a topological order.
Inputs: no named parameters. Returns: object
gnn_summaryA
GNN view of a step: the model architecture read statically from its script and imported project modules (conv layer types and counts, hidden sizes, heads, pooling, head, forward order; nothing is imported or run), dataset classes it constructs (TUDataset, MoleculeNet, QM9, OGB, DGL ...), and cached dataset stats (graphs, nodes/edges per graph, feature dims, classes or target range, self loops, isolated nodes).
Inputs: step, introspect. Returns: object
init_projectA
Create the .mltree/ store (pipeline.yaml, mltree.db, runs/) in the project root. Safe to call again.
Inputs: name. Returns: object
list_runsB
List runs, newest first.
Inputs: step, limit, status, parent_run_id. Returns: object
log_runB
Record one execution of a step: params, metrics, artifacts and its parent run in the experiment tree. The versions (SHA-256) of the step's input and output files are recorded too, so later runs can tell when the data changed.
Inputs: step (required), tags, notes, params, +7 more. Returns: object
open_mapA
Return the URL of the mltree map viewer (and start it if needed). Give the URL to the user.
Inputs: port, start, allow_run. Returns: object
run_logA
Return the status and the last lines of a run's log (live while it runs).
Inputs: run_id (required), tail. Returns: object
run_stepA
Execute a step's script as a subprocess and record it as a run automatically.
Params are passed as CLI flags when the script uses argparse/click (or positionally for sys.argv scripts, or
key=value for hydra), and always as $MLTREE_PARAMS (JSON). Records params, script snapshot, command, exit status,
duration, log (.mltree/runs//log.txt) and metrics from MLTREE_METRIC name=value stdout lines or a JSON file
written to $MLTREE_METRICS_FILE / a declared metrics*.json output. Returns the run and the end of its log.
Inputs: step (required), wait, params, timeout_s, +2 more. Returns: object
run_sweepB
Run a grid search: one sweep run plus one child run per combination, executed one after another.
Inputs: grid (required), step (required), mode, wait, +5 more. Returns: object
scan_projectA
Build the map of an EXISTING project by static analysis (ast only; user code is never executed).
Detects data reads/writes, argparse/click params, local imports, docstrings and step kinds, links steps whose output paths match other steps' inputs (falling back to file numbering and imports), and imports existing results as runs tagged 'imported'. Idempotent: re-scans update scanner-owned fields, add new steps, never delete, and keep edits made with add_step. Review the returned summary and fix it with connect_steps / add_step.
Inputs: path, dry_run, exclude, include, +2 more. Returns: object
start_sweepA
Create a sweep (an HPO study / grid search) that groups trial runs. Pass its sweep_id to log_run for each trial; the map shows the sweep as one collapsible fan with the best trial highlighted. Use run_sweep instead to have mltree launch a grid itself.
Inputs: step (required), mode, name, metric, +2 more. Returns: object
tag_runA
Add or remove tags on a run (e.g. 'baseline', 'best', 'final'). The tree can highlight runs by tag.
Inputs: run_id (required), add, remove. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
Most tools target a distinct resource+action: steps (add_step, connect_steps, scan_project), runs (log_run, run_step, list_runs, best_run, run_log, cancel_run), sweeps (start_sweep, finish_sweep, run_sweep), and outputs (get_pipeline, open_map, export_map). The closest overlaps are start_sweep vs run_sweep (explicitly cross-referenced in the descriptions) and add_step vs scan_project (manual upsert vs static analysis), both of which are clarified in text. gnn_summary is a narrowly scoped inspection tool that stands clearly apart.
Nearly all names are snake_case verb_noun (add_step, connect_steps, list_runs, log_run, compare_runs, run_step, cancel_run, export_map). A few deviate from that pattern—best_run (adjective_noun), data_status (noun_noun) and gnn_summary (noun_verb)—but they remain readable and unambiguous. No mixing of camelCase or inconsistent delimiters.
At 21 tools the surface sits in the heavy band, spread across pipeline modeling, run logging/execution, sweeps, data versioning, notes/tags, and three output mechanisms (viewer, pipeline read, HTML export). Each tool maps to a recognizable capability, so nothing is obviously redundant, but the set is larger than the core job strictly requires.
Lifecycle coverage is broad (init_project, scan_project, add/connect steps, run/log/compare/tag/note, sweeps, export), but there is no way to delete a step, run, or note, and no tool to remove or edit an edge once created with connect_steps. Those omissions are notable in a mutable graph store, since mistakes require editing underlying files by hand. Agents can work around gaps but cannot fully clean up the model.
Maintenance
Related MCP Connectors
Build, validate, test-run and publish AIOS workflows from Claude Code, Codex, Cursor or VS Code.
Discover, run, inspect, build, test, and privately reuse AI workflows.
Turn any LLM into your lab assistant: search samples, track experiments, analyze data with AI.
Durable, shareable and governed project memory with smart triage and explicit project composition.
Related MCP Servers
FlicenseNot gradedqualityNot gradedmaintenanceEnables building and querying code knowledge graphs for project analysis, with tools for exploring code relationships, managing workflows, and automating development tasks. Integrates with Git and GitHub for branch management and pull request creation.42 npm6-- AlicenseDqualityDmaintenanceEnables AI assistants to perform MLOps workflows such as experiment tracking, model registry, dataset management, pipeline orchestration, and data lineage by wrapping DVC, MLflow, and Git.1001MIT
- AlicenseNot gradedqualityCmaintenanceEnables building, running, and optimizing cheminformatics pipelines via composable blocks, with an MCP agent interface for natural language interaction.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to store, query, and update persistent project knowledge as a local, Git-friendly knowledge graph, providing structured memory across sessions.9Apache 2.0