MCP server: soup mcp serve (v0.71.28)
v0.71.28 ships a Model Context Protocol server, so you can drive Soup from any MCP client — Claude Code, Cursor, Cline, Continue — without leaving the chat. Your agent inspects a dataset, searches recipes, reads runs and gives a ship verdict as tool calls.
Start it
pip install "soup-cli[mcp]" # official mcp SDK (mcp>=1.10.0,<3), lazy-imported
soup mcp serve # stdio; read-only tools
soup mcp serve --allow-mutating # also run the 2 planning tools
soup mcp serve --allow-execute # planning + real execution (v0.73.3)Stdio is the default and is unchanged. v0.74.0 added two network transports for remote and multi-client setups, and they are covered in network transports below.
Execution (v0.73.3)
--allow-execute implies --allow-mutating, and its history is worth two sentences, because copy written about it ages badly. v0.73.2 added the flag as a reserved gate that opened nothing. v0.73.3 opened it.
soup mcp serve --allow-execute # planning + real execution, behind a tokenThe server now carries 18 tools, and a planned training or export can actually run. How that is gated is the whole design, and it is covered in the execution model below.
History:Through v0.77.1 the
--helpstrings were the part not to trust. At the v0.73.3 tag the help string for--allow-execute, the--allow-mutatinghelp, and the server's own startup banner were all left behind by the feature commit and still said execution is disabled. The changelog, the command reference and the running code agreed that it executes, which was the reverse of the usual rule, where the shipped binary settles a documentation disagreement. The banner was corrected in v0.74.0 (it readsexecution ENABLED); at v0.77.0 and v0.77.1 the two--helpstrings still said it never executes (--allow-mutating: "v1 never executes training or export";--allow-execute: "Reserve the execution gate for future MCP tools ... never execute in this version"), and upstream's generateddocs/cli-reference.mdrepeated them. (Since closed in v0.77.2, #2268:soup mcp serve --helpdescribes--allow-mutatingas the plan-only tools that "never execute training or export unless --allow-execute is also given", and--allow-executeas enablingtrain_execute/export_execute, which run a plan once the confirmation token is sent back, implied--allow-mutating, and "Refused with --transport sse or http: execution is stdio only". The generateddocs/cli-reference.mdcarries the new text. On a binary older than v0.77.2 the usual rule applies again: the help strings are the part not to trust.)
Nothing executes unless you pass the flag. --allow-mutating on its own can never trigger a subprocess, and that is asserted in the code rather than assumed.
Connect a client
Add Soup to your client's MCP config (.mcp.json for Claude Code, claude_desktop_config.json for Claude Desktop):
{
"mcpServers": {
"soup": { "command": "soup", "args": ["mcp", "serve"] }
}
}To expose the planning tools, add the flag:
{
"mcpServers": {
"soup": { "command": "soup", "args": ["mcp", "serve", "--allow-mutating"] }
}
}The tools
The server exposes 18 tools total: 14 read-only + 2 planning + 2 executing. It exposes MCP Tools only — no Resources, no Prompts. Every tool maps to a Soup command and returns JSON.
14 read-only tools (always available)
| Tool | Backing command | Returns |
|---|---|---|
advise | soup advise | PROMPT_ENG / RAG / SFT / DPO / GRPO verdict for a dataset |
data_inspect | soup data inspect | Row count, columns, length distribution, duplicates |
data_validate | soup data validate | Format-compliance report (issues + valid-row count) and the format that was checked. Omit format, or pass auto, to auto-detect; an unrecognised value is a tool error that lists the accepted ones |
data_score | soup data score | Quality scorecard: PII, an abuse-keyword triage count (abuse_keyword_flagged, with the old toxic_flagged kept beside it with the same value; a keyword heuristic, not a toxicity classifier), language mix, educational value |
data_doctor | soup data doctor | Chat-template compatibility vs a tokenizer (needs [train]). An unrecognised format is refused the same way as in data_validate |
recipes_search | soup recipes search | Search the catalog by keyword / task / size (no YAML body) |
recipes_show | soup recipes show | A full recipe including the ready-to-use soup.yaml |
runs_list | soup runs | Recent experiment runs from the local tracker. Since v0.78.0 each row's output_dir is relative to the server's working directory when it is inside it, and only its last path component otherwise (#2807); read the absolute path from your own records or from soup runs show on the host. loss, lr and speed can be null where v0.77.2 stored 0.0 |
runs_show | soup runs show | One run's full record (accepts an id prefix, with the same output_dir rule). Since v0.78.0 a prefix that matches several runs answers Run id prefix '<id>' matches N runs; give more characters, where it used to say run not found (#2752); a missing run still says run not found |
registry_list | soup registry list | Registry entries, filterable by name/tag/base/task |
registry_show | soup registry show | One entry by id / prefix / name:tag / registry:// ref |
profile | soup profile | Memory / speed / GPU-fit estimate from a soup.yaml (no model load), with gpu_memory_source saying whether the GPU size came from your gpu argument (flag), the machine (detected; on Apple Silicon, Metal's recommended working set, mlx working set, since v0.77.2) or an assumed default (assumed). An unknown gpu is a tool error that lists the valid names. Since v0.77.0 a full fine-tune (lora.r: 0, Spectrum, LISA, PRM, a classifier without LoRA) is budgeted with its gradients and optimizer state, as soup profile does (#2041). Since v0.77.1 it prices the run with the same peak-VRAM estimate as soup profile (see Experiments), reads the model's config.json from a local directory or the local cache only, so it never sends a request to the Hub for a model id the client chose, and returns fit and gradient_checkpointing_tier beside the older fields. Since v0.77.2 it also returns lora_r: the rank priced, or null for a full fine-tune (Spectrum and LISA included). Since v0.78.0 it also returns teacher_memory_gb, distill_memory_gb and teacher_generation_memory_gb, which are 0 outside task: distill. The tool takes config and gpu and no sequence length or shape argument: it prices a run at the config's data.max_length (the Python function profile_from_config takes seq_len and shape; the tool does not pass them). A config the estimate cannot price (a batch_size, a max_length or a model size outside its range) is a tool error, which since v0.78.0 carries the reason, naming the field and the limit and never a value from the config (#2306) |
diagnose_evidence | soup diagnose --evidence | Failure-mode report card from a pre-computed evidence JSON. overall is OK, MINOR, MAJOR or NOT_RUN (a requested probe produced no measurement); only OK or MINOR is a pass. An entry with verdict: NOT_RUN defaults to score 0.0. Since v0.78.0 it takes an optional boolean require_all_modes (default false): when true, a mode missing from the evidence is NOT_RUN instead of a neutral OK; a non-boolean value is a tool error |
ship_evidence | soup ship --evidence | SHIP / DON'T-SHIP verdict from a pre-computed evidence JSON. Since v0.76.0 it decodes the evidence through the same strict reader as the CLI, so one file gets one verdict on both surfaces. Since v0.78.0 that reader accepts schema_version 1 and 2 (absent means 1) and the version-2 blocks (see soup ship); soup-cli 0.77.x refuses a version-2 file with evidence has unsupported field(s): 'schema_version' (exit 3 on the CLI), so upgrade the MCP side before the CI gate hands it one |
2 planning tools (behind --allow-mutating)
| Tool | Backing command | Behaviour |
|---|---|---|
train_start | soup train | Validates a soup.yaml, returns {config_valid, task, base, would_run, note}. Never executes by itself |
export | soup export | Validates the format, returns {format, would_run, note}. Never executes by itself |
Both are always listed but refuse to run unless you started the server with --allow-mutating, and even then they only render the exact command that would run. Calling them while disabled returns a clean isError telling you to restart with the flag. The export tool's refusal of an unknown format now lists the accepted formats.
None of the commands v0.76.0 added (soup rewind, soup bench, soup adapters check and audit, soup data clean, soup recipes verify) is an MCP tool, and none of v0.77.0, v0.77.1, v0.77.2 and v0.78.0 adds any (soup loop set and soup loop rollback, soup docs search, soup prune-layer-cache, soup eval retention and soup data leakage, the new commands of v0.78.0, are not tools either); the registry still holds exactly the 18 tools above. Between v0.77.2 and v0.78.0 only mcp_server/registry.py changed in the MCP package: the changes are the run rows, the profile error text and the diagnose_evidence require_all_modes input above (the ship_evidence change is in the evidence reader it calls).
Running a tool without a server (v0.77.0)
Python code that runs the registry tools without an MCP server can call soup_cli.mcp_server.registry.call_tool(name, arguments, allow_mutating=False), the helper soup mcp serve itself now uses to dispatch (#1761, #1770). It diverts stray stdout to stderr while the tool runs, passes the result through the same sanitization, and turns every failure into a message with no path or traceback (internal error (<type>) for an unexpected exception). A mutating tool still needs allow_mutating=True on the call, and the two execution tools need a table built with build_registry(allow_mutating=True, allow_execute=True) and passed as registry=. Its stdout guard is process-wide, so prints from other threads in the process also go to stderr during a call. It is not promised as a stable in-process API (upstream's docstring: "This is not a supported in-process Python API; it describes what the helper does today"), so pin the Soup version if you build on it. soup mcp serve behaves as before.
Under --allow-execute they do one thing more: each returns a confirmation_token for the plan it just built. That token is the only way to reach the two tools below.
2 executing tools (behind --allow-execute, v0.73.3)
| Tool | Runs | Accepts |
|---|---|---|
train_execute | The training the matching train_start planned | confirmation_token and nothing else |
export_execute | The export the matching export planned | confirmation_token and nothing else |
Both are always listed, carry a destructive annotation, and refuse unless the server was started with --allow-execute. They return {run_id, status, pid, log_path}.
The execution model
The interesting property is what the client is not allowed to send. There is no command parameter, no argv, no shell string, and no environment: the argv was built server-side at plan time, and the only thing a caller can do is name a plan it already made.
- The token is server-generated, random, bound to both the plan and the execution kind, single-use, and expires after five minutes. A token from a
train_startcannot run an export. - The config is snapshotted at plan time and the run executes from that copy, so the file cannot be edited underneath a plan that was already approved.
- Every local input a plan reads is pinned, and from v0.75.1 that is twenty fields rather than five. Until then the digested list named seven paths, two of which are not schema fields at all, so in practice five were covered: a reward model, PRM, teacher model, reward-function file or unlearning set could be swapped between the moment you approved a plan and the moment it ran (0.73.3 to 0.75.0). An input outside the working directory was silently left unpinned; it is now refused at plan time. An input that did not exist at plan time must still not exist at execution, which is what lets a hub id or a built-in reward name be a legitimate pinned input. A test walks the schema and fails when a new path-shaped field is added without being classified either way.
- Protected inputs are re-validated by content, not by timestamp. The digest walks a directory tree by sorted relative path and per-file hash, refusing symlinks and bounded in both file count and bytes. Since v0.75.1 it also opens with
O_NOFOLLOWand reads the path as given rather than its resolved form, because resolving a symlink first is precisely what would stopO_NOFOLLOWfrom ever firing. Windows has no such flag, so through v0.75.2 there the earlier check remained the only symlink guard. (Since v0.76.0 the digest goes through the sharedopen_no_followhelper, which on Windows inspects the path for a symbolic link or reparse point before the open and compares the opened file's identity afterwards, so Windows is no longer unguarded.) The earlier mtime-and-size check did not change when a file inside a protected directory was rewritten, which meant a model could be swapped between planning and execution and still pass. - Plan and run directories refuse links (v0.76.0). Planning checks the run id (letters, digits,
_,.and-, starting with a letter or digit, at most 128 characters), refuses a symbolic link or junction at.soup,.soup/mcp-runsor the run directory, requires the run directory not to exist yet, creates it itself and writes the plan snapshotconfig.yamlexclusively, each failure a path-free refusal (#1211, #1492, #1553). Execution opens the run log through the same helper: it refuses a link at the log path or in any parent directory, and a pre-planted hard link (#1138, #1158, #1171). Upstream states the residual: a process with concurrent write access inside.soupcan still race these checks. - The process is spawned with
shell=Falseandstdinclosed, its working directory pinned to where the server started, and its output redirected to.soup/mcp-runs/<run_id>.log. - The token is consumed, and capacity taken, before the process is spawned. A failed spawn therefore requires a fresh plan rather than allowing a replay.
- One execution at a time, gated on a persisted run whose recorded process is still alive. That survives a restart: a live child from a previous server blocks a new run, while a stale record whose process is gone frees the slot instead of wedging it shut.
- The run goes through the normal experiment tracker, so
soup runssees what MCP started.
What it does not do: the snapshot freezes the configuration, not external filesystem assets, and a launch is fire-and-forget, so disconnecting your MCP client does not stop a subprocess that is already running.
Security model
Every point below is implemented and tested:
- No listener unless you ask for one — stdio is the default and opens no port. stdout is reserved for the JSON-RPC channel; all human-facing text goes to stderr, and handler stdout is redirected so a stray
print()can't corrupt the stream. A network transport is opt-in and carries its own mandatory bearer gate, below. - Path containment — every path argument re-enters cwd-containment + symlink rejection (
O_NOFOLLOW+ fstat TOCTOU defence on reads; on Windows, where that flag does not exist, anlstatcheck for symlinks and reparse points plus an identity comparison after the open, since v0.76.0). - Output sanitization — C0/ESC/DEL bytes, since v0.76.0 the C1 range U+0080 to U+009F, and since v0.77.0 the bidi controls and invisible separators (U+202A to U+202E, U+2066 to U+2069, U+061C, U+200E, U+200F, U+200B, U+2028, U+2029, U+FEFF; ZWJ and ZWNJ are kept, #1953), are recursively stripped from every returned string (tab/newline/CR kept), so a malicious dataset string can't smuggle ANSI/OSC terminal escapes into your client.
- Path-free errors — a failing handler becomes a clean
isErrorresult; no filesystem path or stack trace leaks, and the server survives. An unrecognised choice (aformat, agpu, an export format) echoes only the value you sent, escaped, with the accepted list. Becauseship_evidenceanddiagnose_evidencenow share a decoder with the CLI, which quotes the offending evidence value when it refuses, the MCP layer redacts every quoted run in that message to<redacted>and keeps the schema field names, so evidence-file content does not reach the client (v0.76.0, #768). - Bounds — string args ≤ 4096 chars, JSON args ≤ 16 MiB, dataset loads ≤ 1 GiB, int args range-checked (rejected, not silently clamped).
- Execution is default-off and separately gated —
--allow-mutatingalone can never spawn a process. With--allow-executeon, authorization is a server-issued one-time token: any client confirmation prompt you see is presentation, and the security lives entirely in the server-side token state.
Install note
The [mcp] extra pulls one dependency, mcp>=1.10.0,<3 (the official MCP Python SDK), and is lazy-imported — only the server module touches it, so the core CLI and the tool registry stay PyTorch-free and SDK-free. If you run soup mcp serve without the extra, you get a friendly one-line install hint and exit 1. The extra is also folded into [all] and [dev].
The bounds moved in v0.74.0. The floor rose from 1.2.0 to 1.10.0, measured against published wheels rather than a changelog: the transport-security module a listener depends on first appears there, and a listener whose origin checking silently disappears on an older SDK is worse than a resolver error. The <2 cap, added when the SDK's 2.0.0 removed two APIs the server round-trips through, is lifted: both majors are bridged, chosen by probing the server constructor rather than by reading a version string, with a test that walks the syntax tree to enforce that and another that fails if a second dispatch implementation appears.
Network transports (v0.74.0)
Until v0.74.0 the server was stdio only, which suits a client that spawns Soup as a subprocess and leaves remote or multi-client setups with nothing.
soup mcp serve --transport sse --host 127.0.0.1 --port 8765 --auth-token "$TOKEN"
soup mcp serve --transport http --host 127.0.0.1 --port 8765 --auth-token "$TOKEN"Both serve the same registry as stdio, and the end-to-end test compares advertised tool names against the registry rather than a hardcoded count, so a subset cannot creep in.
The defaults are --host 127.0.0.1 and --port 8765. sse serves GET /sse and POST /messages/; http serves /mcp. Leave --auth-token out and Soup generates a fresh urlsafe token on every start and prints it beside the URL; a token you supply must be 16 to 128 urlsafe characters (A-Z, a-z, 0-9, _, -), and since v0.77.2 the whole value is matched, so a trailing newline is refused here, in soup ui and in soup serve, which now share the rule (#2329). Whatever your client's config format is, it has to send Authorization: Bearer <token> on every request, the GET that opens the stream included.
One detail of the http transport, observed on a loopback instance of v0.75.2 (the transport code is unchanged through v0.78.0: v0.77.0's change to mcp_server/server.py is the tool dispatch, the file is identical between v0.77.0 and v0.78.0, as is commands/mcp.py between v0.77.2 and v0.78.0, and this was not re-tested): the URL the server prints ends in /mcp, and a POST to exactly that path is answered with a 307 redirect to /mcp/. A client that follows the redirect and keeps its Authorization header on the second request is unaffected. One that does not follow redirects, or drops the header when it does, should be configured with the trailing slash, /mcp/, which answers directly. A request to /mcp/ without a token is a 401. Which clients behave which way was not tested.
Adding a listener is the risky part, so it is gated three ways.
| Gate | What it does | Why it is not optional |
|---|---|---|
| Bearer token | Every request needs Authorization: Bearer <token>, compared in constant time. Header only, never a query string | A loopback port is reachable by every process on the box, so there is no opt-out. Header-only means it cannot land in an access log. The token format is validated by the same helper soup ui uses, rather than growing a second format |
| DNS-rebinding protection | 421 on a foreign Host, 403 on a foreign Origin | This is the gate a token cannot be: a page the operator merely visits sends no Authorization header, and its request still reaches the port |
| Bind warnings | Binding off loopback warns; a wildcard bind warns again | With a wildcard bind the Host check has nothing left to pin |
--allow-execute is refused with either network transport. The refusal is made twice on purpose, once in the command so the operator gets a readable message and once in the app factory so a direct caller cannot put an executing registry behind a listener either. The reasoning is stated rather than assumed: gated execution spawns real training and export processes, and behind a listener a leaked bearer token would mean process execution rather than plan disclosure, while stdio is a pipe to a client the operator already started.
--host, --port and --auth-token are refused under --transport stdio rather than silently ignored.
One operational addition rides along: a crash between spawning a training job and recording its process id used to let a restart double-book a second job, so an unresolved launch now counts as active, and soup mcp runs reconcile --expunge-launching recovers capacity from stale rows without editing the database by hand. It refuses the whole operation if any candidate records a process that is still alive. --older-than-seconds N (default 300, minimum 1) sets how old a launching row must be before it counts as stale.
See also
- v0.74.0: loaded in fp32 — the release that added the network transports.
- v0.73.3: four flags that did nothing — the release that opened the execution gate.
- Fine-tune Doctor —
data_doctoris one of the read-only tools here. - soup ship —
ship_evidencegives the SHIP / DON'T-SHIP verdict as a tool call. - advise / diagnose — the decide-and-report tools your agent can call directly.
Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.