Repository navigation
Studio: one-command MCP setup, recipe prompts, a model catalog and tool annotations - #14077
Merged
danielhanchen merged 49 commits intoOct 19, 2026
Merged
Conversation
A model family that Unsloth Studio's tables don't list now lands on every Audio page its runtime spec allows, not just the first task: a spec with tts and clone shows on Text to Speech and Clone (fish_drama3, kitten_tts2), sep on Separate, asr on Transcribe, music/sfx on Music with a conservative music setup. Voice conversion stays limited to the families Unsloth Studio already configures. mira_tts and sopro_tts are Clone only, since they need a reference on every run. The default variant follows the spec's recommended_package, and K/IQ quants rank after the established order. GET /api/inference/audio/catalog lists every umbrella folder (300 s TTL, saved last-good listing, HF-cache fallback) plus Community repos named by the runtime's model specs. The Audio pages use one pageModels() resolver and show a "More models" group in the existing picker, with the pages, languages and status in the row tooltip and the size in the size column. The nightly catalog check warns on a new folder instead of failing. MCP: list_models takes a workflow filter, generate_audio takes model, and the switch guard names the pages a model runs on.
…tor --mcp checks the connection
unsloth mcp add {claude-code,codex,cursor,generic} points the agent at the
Unsloth Studio MCP server with an Authorization header that names an env var;
the key itself is never read, printed or written. Created files are 0600,
re-runs change nothing, and --dry-run prints the diff.
unsloth doctor --mcp checks that Unsloth Studio answers, the key works, MCP is
on, and advises when an agent's tool timeout is under 240 s.
…dels an agent can download Audio rows come from the audio.cpp catalog route; image and video rows from a new account-filtered /api/inference/media/catalog built from the family registries. Rows carry size_bytes, low_vram and fits_now (one GPU's free memory, decimal GB). LLM rows are not in the catalog.
Each prompt reads the live GPU memory, loaded models and catalog rows that fit, then lays out the tool calls for the job. They fall back to plain steps when Unsloth Studio can't be read.
…rompts in MCP.md
The hand-written Claude Code command now keeps ${UNSLOTH_API_KEY} unexpanded,
so the key no longer lands in ~/.claude.json.
…undtrack The audio catalog also holds detectors and separators, and the smallest of those crowded out music and speech models in the film recipe's candidates.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
- A catalog entry the backend could not place no longer hides a model the bundled seed already knows, so a degraded catalog (no runtime specs, late header probes) leaves every page as it was. - A build whose family probe missed the deadline is cached for 30 s, not 300 s; concurrent cold requests share one build; a spec package with an empty file list no longer fails the whole catalog. - More models rows follow the picker's format and fit filters, show when the Recommended list is empty, and appear on Transcribe for catalog ASR models.
A More models row has no Hub pipeline tag, so a catalog ASR model picked on Transcribe was treated as a speech model and loaded on Text to Speech. The pick now carries the catalog's speech-recognition task.
…and film recipe to the device Dry-run diffs and claude errors mask any literal key already in a config; the Codex splice keeps comments about the next table; a non-object mcpServers or a non-JSON --output is refused instead of overwritten; a failed claude add after remove says the old entry is gone; doctor --mcp takes --env-var and only reads timeouts for this Unsloth Studio's URL. The media catalog drops video families the device can't run, and the film recipe asks for music and speak rows.
The picker's loading spinner and Hub failure hint replaced the whole list, so catalog rows that were already available stayed hidden until the Hub answered. Those states now apply only when neither list has rows.
…secrets masked A whole-file diff could print any other server's token, and pattern masking missed keys spelled differently. The dry run now diffs just the entry it would write, masking every header, token and env value in the old one.
Masking an old hand-written entry kept missing keys in args, multi-line TOML strings and unusual header names. The dry run now shows only the new entry, which names an env var, and says when it replaces an existing one.
Collaborator
Author
|
Status at What changed since the PR opened:
Checks on this head:
Not in this PR:
|
…catalog rows - More models rows now join the picker's roving option list after the recommended rows, in the order they are drawn. Before, each got the shared fallback option id and arrow keys could not reach them. - When the backend read the installed runtime's own model specs, its catalog verdict decides which umbrella folders appear under More models, so a folder the static unoffered list holds back shows up once the runtime supports it. Without runtime specs the static list still applies.
… folder's spec The audio catalog guessed a folder's family from its name when no runtime spec placed it. Voxtral-4B-TTS reads as voxtral_realtime, whose spec places the Voxtral Realtime folder, so on a runtime without voxtral_tts the TTS folder was offered on Transcribe. A hint whose runtime spec places other folders but not this one is now ignored, and the GGUF header decides.
…mcp verdicts Without tomllib or tomli the Codex config splice is line based, so refuse files with multi-line strings or non-header lines starting with '[' instead of cutting them. doctor --mcp now reports any non-2xx MCP answer other than 404/405/401 as an error, scrubs the key from every probe error (http.client quotes a refused header value), and sends the CLI User-Agent like the health probe.
…r families offline
…munity package needs sidecars [skip ci]
…always-singing music models [skip ci]
…cpp format [skip ci]
…fore they are downloaded [skip ci]
shimmyshimmer
pushed a commit
to shimmyshimmer/unsloth-staging-4
that referenced
this pull request
Oct 19, 2026
…identity (unslothai#14178) Hardening from the latest security scan, in `unsloth doctor --mcp` (added in unslothai#14077). **Problem.** When `UNSLOTH_STUDIO_URL` is not set, the MCP doctor finds Unsloth Studio by probing local ports for the public `/api/health` answer, then sends `UNSLOTH_API_KEY` as a bearer token to `/api/inference/loaded-models` and `/mcp/`. `/api/health` is public, so anything listening on that loopback port can answer it. On a shared machine, another local user listening on 127.0.0.1:8888 while Studio is stopped would receive the owner's API key. `unsloth chat` and `unsloth start` already guard against this with `verify_studio_identity` (an HMAC challenge only this machine's Studio can answer) before sending a secret; the doctor skipped it. **Change** (`unsloth_cli/commands/mcp.py`). For an auto-discovered loopback server, the doctor calls `verify_studio_identity` first. If it fails, the key is not sent to either endpoint and the doctor reports `API key: set, not sent` with a hint to set `UNSLOTH_STUDIO_URL`. - A normal local Studio passes the check, so the doctor's output is unchanged. - An explicit `UNSLOTH_STUDIO_URL` is still trusted as before (the user named the server), which keeps SSH-tunnel setups working. - Read-only and idempotent; no other command changes. Tests (`unsloth_cli/tests/test_doctor_mcp.py`): a new case where the found server fails the identity check asserts no `Authorization` header reaches it, and that `UNSLOTH_STUDIO_URL` still sends the key; plus the new hint. Both fail on main and pass here. The full `unsloth_cli/tests` suite passes (2095 passed).
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.
Includes #14072 (Studio: audio.cpp models land on the right pages); review this PR's own commits from 4d58b31 on.
git diff e1d6db49bc HEAD(the #14072 head) shows only this PR's changes; the merge commit just brings #14072 up to date.Summary
Connecting an agent to the Unsloth Studio MCP server meant copying a per-agent command from
MCP.md, and the documented Claude Code command expanded$UNSLOTH_API_KEYin the shell, so the key itself was written into~/.claude.json. Agents also had no way to see which image, video or audio models they could download, or whether one would fit on the GPU. This adds a setup command, a connection check, a download catalog inlist_models, and two recipe prompts.Changes
unsloth mcp add {claude-code,codex,cursor,generic}writes the agent's MCP entry. The entry names an environment variable (UNSLOTH_API_KEYby default,--env-varto change it) in theAuthorizationheader, and the command never reads, prints or writes the key.--url, thenUNSLOTH_STUDIO_URL, then a running Unsloth Studio on this machine, thenhttp://127.0.0.1:8888.claude mcp add --scope userwhenclaudeis on PATH, otherwise it edits~/.claude.jsondirectly. Codex gets a[mcp_servers.unsloth-studio]table withtool_timeout_sec = 300, and the edit is refused if any other TOML setting would change. Cursor gets~/.cursor/mcp.jsonwith${env:UNSLOTH_API_KEY}.genericprints a JSON snippet, or merges it into--output.--dry-runprints just the entry it would write and writes nothing. It never prints the old entry it would replace, since one written by hand may hold a key. Re-running with the same arguments reports "unchanged". New config files are created with mode 0600, and existing files keep their mode.unsloth doctor --mcp [--env-var NAME]checks that Unsloth Studio answers, that the key is accepted, and that/mcp/is on (it tells "turned off" apart from "this Unsloth Studio predates MCP"). It warns, without failing, when a configured Codex or Claude Code tool timeout is under 240 s. Plain--mcpskips the GPU checks;--mcp --gpusruns both.list_models(source="catalog")lists image, video and audio models Unsloth Studio can download. Audio rows are forwarded from the audio.cpp catalog route in #14072 (/api/inference/audio/catalog), rather than importing its builder, so they stay filtered per account like every other MCP call. Image and video rows come from a newGET /api/inference/media/catalog, built from the diffusion and video family registries, filtered to what the calling account may load, and limited to the video families this device can run (as on the Video page). Catalog rows carrysize_bytes(decimal bytes),low_vram(a video family's GGUF repo) andfits_now, which compares the size against the free memory of the single GPU with the most free memory, or is null when either value is unknown. The defaultsource="local"output is unchanged.LLM rows in
list_models(source="catalog")are a possible follow-up pending a maintainer decision. For now the docstring tells agents to list downloaded LLMs with the default source or load a Hugging Face id.The MCP server now offers two prompts, which Claude Code shows as slash commands:
make_short_film(idea, length_seconds)reads free GPU memory, loaded models and the video, music and voice catalog rows that fit now, then lists the calls fromload_modelthroughgenerate_video,get_jobandgenerate_audio.build_dataset_and_train(goal, base_model)reads the downloaded LLMs and lists the dataset, Data Recipe,start_trainingandexport_modelcalls.Both fall back to plain steps when Unsloth Studio can't be read, and the rendered text is capped at 4000 characters.
MCP.mdgets a "One command" section formcp addanddoctor --mcp, the catalog in thelist_modelsrow, and a Prompts section. The hand-written Claude Code commands now single-quote${UNSLOTH_API_KEY}and use--scope user, so the key stays out of~/.claude.json.Tool annotations (titles,
idempotentHint,destructiveHintonload_model) will land as a final commit after the other MCP PRs merge.Testing
New tests:
unsloth_cli/tests/test_mcp_add.py,unsloth_cli/tests/test_doctor_mcp.py,studio/backend/tests/test_mcp_prompts.py,studio/backend/tests/test_media_catalog.py, and catalog cases instudio/backend/tests/test_mcp_tools_models.py.test_mcp_no_host_paths.pyalso runslist_models(source="catalog"), and thelist_modelsschema row intest_mcp_server.pyis now a superset check, so it acceptssource.unsloth_cli/tests/: 2084 passed, 4 skipped. The 1 failure,test_studio_update_verify.py::test_a_no_torch_install_keeps_that_mode_in_the_reinstall, fails the same way on the Studio: audio.cpp models land on the right pages #14072 head.studio/backend/tests/test_mcp_*.pyplus the media and audio.cpp catalog tests: 1708 passed, 3 skipped (fastmcp 3.4.8). The MCP, catalog and prompt files also pass on fastmcp 3.2.4.FastMCP.prompt(title=)exists back to the 3.0.2 floor.Bearerspelling, other headers,args, TOMLbearer_tokenin any quoting, multi-line strings, another server's token) prints none of them, across 56 probe cases. Another test setsUNSLOTH_API_KEYto a canary and checks stdout, every written file and theclaudeargv for all four agents, with and without--dry-run.fits_nowis covered for a stubbed 24 GB and 12 GB card (Wan2.2-TI2V-5B, 24.2 GB, fits only the first), the GiB/GB boundary, and two GPUs (the max counts, not the sum).unsloth doctor --no-gpusoutput is byte-identical to the Studio: audio.cpp models land on the right pages #14072 head, anddoctor --helponly gains the--mcpline. Dumping every MCP tool's schema, description and annotations before and after shows onlylist_modelschanged.Against a running Unsloth Studio (no model loaded):
unsloth doctor --mcpwith a valid key printed "API key: set, accepted", "MCP endpoint: on" and "Verdict: OK", exit 0. With a wrong key it printed "set, refused" and exit 1. The key appeared in neither output.mcp add claude-code,codexandcursor, each run twice in a sandboxed home, wrote once and then reported "unchanged".--dry-runprinted the diff and wrote nothing, and every created file was mode 600.claude mcp getandcodex mcp getread the entries back with the env var name, not a key.${UNSLOTH_API_KEY}in a user-scope header when it connects, so the entrymcp add claude-codewrites authenticates.studio_status, thenlist_models(source="catalog")for video, audio and TTS. It pickedunsloth/Wan2.2-TI2V-5B-GGUF(alow_vramrow), Stable-Audio-3-Medium-GGUF (3.6 GB) and Qwen3-TTS-12Hz-1.7B-VoiceDesign-GGUF (2.8 GB). That took 6 tool calls with no errors. The full catalog is 130 rows (33 KB) and returns in 0.09 s.prompts/listandprompts/getfor both prompts work over HTTP with live GPU and catalog data.