Repository navigation
Conversation
Unsloth Studio's MCP controls move to their own owner-only Settings > MCP tab:
the Agent access switch and per-agent setup snippet, plus a Tools list with
one switch per tool. A turned-off tool is hidden from tools/list and its calls
are refused with [tool_disabled]; prompts that read a turned-off tool are
hidden too. New tools start on. The Agents and API keys tabs show the access
status with a button that opens the MCP tab.
GET /api/settings/mcp-access gains tools[{name, area, enabled}]; PUT also
takes disabled_tools. The old {enabled} body still works, and
UNSLOTH_STUDIO_ENABLE_MCP now locks only the switch, not the tool list.
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. |
|
Ticking "Unsloth Studio" in the chat MCP dropdown now lets the chat model use Unsloth Studio's own tools, limited to the ones turned on in Settings > MCP. Six tools that would unload, restart, cancel or re-enter the chat show "Not in chat" and are never offered. What changed
The chat bridge, MCP and auth tests pass on
|
The chat's Unsloth Studio row revokes its per-call key when the tool call returns. export_model keeps working in a background job after that, so a chat-started export failed with 401; it also loads a checkpoint that can evict the chat's model, so it joins the chat denylist. The video queue posts a queued clip later with the caller's token, so a chat call that finds another video running is now told to retry instead of being queued.
…relative A chat request that a password reset revoked could still mint keys for its remaining Unsloth Studio tool calls. The request's credential generation now rides on its account context, and the per-call mint passes it as expect_gen, so a rotated credential refuses the call like any other new key. Chat tool media links were built on 127.0.0.1, which a browser on another machine (LAN, tunnel, proxy) cannot open. The chat's callers now get origin-relative links that resolve against the address the user reached Unsloth Studio on.
…o the MCP snippet A read of the MCP settings that overlapped a write was reported as every tool off, so agents briefly saw an empty tools/list and the Tools list could save that view back. The read now retries, and the settings API sends tools: null when it really cannot read, which hides the list instead of showing it all off. A key created on Settings > API fills the MCP tab's setup snippet again, kept in memory until the key card is dismissed or Settings closes. The Unsloth Studio MCP row moves to the end of the Agents tab.
…hat-unsloth-studio-mcp # Conflicts: # studio/backend/routes/settings.py
A chat call has no outer request, so its media links are origin-relative, and MCP's ResourceLink rejects a relative URI: every chat generate_image and generate_audio call reported an error after the work had already run. Those links now come back as text; external /mcp callers still get ResourceLinks. The bridge also deleted nothing: each chat tool call left an inactive key row in auth.db. The per-call key row and its account copy are now deleted when the call ends.
…cp-settings-tab # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
…unsloth into studio/chat-unsloth-studio-mcp # Conflicts: # studio/backend/auth/authentication.py # studio/backend/utils/account_context.py # studio/frontend/scripts/check-bundle-budget.ts
Behind a proxy that serves Unsloth Studio under a path such as /studio, chat media links came back as /api/... and missed the prefix. Each request's root_path is now remembered for the chat's tool calls, so their links read /studio/api/....
…cp-settings-tab # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
…unsloth into studio/chat-unsloth-studio-mcp # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
|
@codex security review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
…unsloth into r14349 # Conflicts: # studio/backend/auth/storage.py # studio/frontend/scripts/check-bundle-budget.ts
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts # studio/frontend/src/features/settings/tabs/api-keys-tab.tsx
…unsloth into r14349 # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
…unsloth into r14349 # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
…unsloth into r14349 # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
… dialog
Drops the separate Settings > MCP tab so the MCP name stays free for a
future tab that manages MCP servers. The Agent access (MCP) card now ends
the Agents page: the on/off switch, a Tools row ("20 of 23 on") that opens
a dialog, and the setup snippet. The dialog groups the tools (Models,
Generate, Training and export, Data and library, Jobs) with one-line rows
whose name toggles the switch, a switch per group, and Turn all on. Every
change sends only the tools it flips as tool_states, so the server keeps
merging concurrent toggles. The API tab keeps a one-line status row that
jumps to the card.
…io/mcp-settings-tab # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts # studio/frontend/src/features/settings/components/mcp-access-section.tsx # studio/frontend/src/features/settings/tabs/api-keys-tab.tsx # studio/frontend/tests/mcp-access-section.test.ts
…unsloth into studio/chat-unsloth-studio-mcp
Replaces #14349, with the same final code as one commit. It is stacked on #15629, so merge that first. Until then this diff also shows #15629's changes, and only the last commit is new. It includes the fixes Daniel and Nilay made on #14349, and both are credited as co-authors. ## Summary This PR adds an **Unsloth** preset at the top of the chat MCP dropdown. Ticking it lets the chat model call Unsloth Studio's own MCP tools in process, with no API key to paste and no network listener.  - **Which tools the chat gets:** only the tools the owner left on in Settings > Agents > Choose tools, minus the ones that would evict or re-enter the chat that calls them: `chat`, `load_model`, `unload_model`, `cancel`, `start_training`, `export_model` and `run_recipe` (`CHAT_DENYLIST` in `mcp_server.py`). The tools dialog names those once, in a note under the groups. - **Toggles apply right away:** the row's tools are re-listed on every send, so a change in Settings applies to the next message. - **External agent access is unaffected:** it works whether or not "Agent access (MCP)" is on, and `/mcp` still returns 404 while that is off.  ## Safety - **Per-call key:** each tool call runs as the chat's own account, with an internal API key minted for that call. The key is deleted when the call ends, including on Stop, timeout and error. - **No host files:** host file paths are refused for these calls, even for the owner. - **Who can turn it on:** only a signed-in UI session can add the row or point another row at it. API keys and keyless callers get 403, and keyless callers never see the row. - **Stop:** a chat Stop also stops the image, audio or video job a tool call started. - **Model switches:** a chat tool call never switches the loaded model. - **Media links:** links open through the user's session, so they work in the desktop app and behind a proxy path prefix. ## Testing ```bash cd studio/backend python -m pytest tests/test_studio_tools_chat.py tests/test_mcp_*.py tests/test_settings*.py tests/test_systemone_connections.py tests/test_research_internal_key_monitor.py tests/test_fine_tuned_model_serving.py tests/test_openai_tool_passthrough.py cd ../frontend npm run typecheck && npm run i18n:check:strict && npm test && npm run build && npm run bundle:check ``` - **Backend:** 2,237 passed, plus 499 in the model-switch and tool-passthrough files. The same 3 `test_mcp_images.py` tests fail here and on main. - **Frontend:** typecheck clean, `i18n:check:strict` passes, and the settings, MCP and chat-composer tests pass (871). - **Bundle:** within budget. The budget grows by +1,363 B raw / +366 B transfer over #15629, from the chat preset and the note. I also ran Unsloth Studio from this branch to check the dropdown and the dialog note. <!-- studio-regress:start --> ### Studio UI regression check Base `81dc73ac4` vs head `fe799ee49`. Functional: **NO_REGRESSION**, UI coverage 83%, 1 visual change(s), 5 text-only change(s). Only steps whose screenshots differ are shown. Note: in this run diffusion_video failed once on head inside the regression harness's own fixture copy (a temp-dir race between the two arms, fixed in the harness), before any request reached Unsloth. A rerun of that journey on both arms at the same head gave 6/6 identical steps; its results are used here. **settings/s06_tab_api**: | reproduced on confirm (VISUAL_DIFF)  | Step | Text / structure change | |---|---| | `settings/s10_tab_agents` | {'removed': [], 'added': ['Unsloth MCP', 'Agent access (MCP)', 'Let coding agents […] use Unsloth over MCP.', '23 of 23 on', 'Choose t | | `parallel/stop_training` | {'removed': ['65/4.1k', 'Three fruits are named:', '#ctrl button:Name three fruits.', '#ctrl button:Context usage: 65 of 4.1k tokens'], 'added': ['Name three an | | `crawl/r_projects` | | | `crawl/r_export` | | | `crawl/r_data_recipes` | | <!-- studio-regress:end --> ### Chat MCP preset: before and after this layer BEFORE is #15629's head (`069a35528`), AFTER is this PR's head (`fe799ee49`), so only this layer's change shows; this is not the PR's own merge base. The chat's MCP menu now offers **Unsloth** first, which answers with Unsloth's own tools in process:  The tools dialog in Settings > Agents ends with the tools a chat never gets ("The chat never gets Load model, Unload model, Plan a load, Chat, Run Data Recipe, Start training, Export model, and Cancel work."):  --------- Co-authored-by: Daniel Han <[email protected]> Co-authored-by: Nilay Yadav <[email protected]> Co-authored-by: Etherl <[email protected]> Co-authored-by: LeoBorcherding <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Stacked on #14348 ("Studio: add a Settings > MCP tab with per-tool switches"), so this branch includes it. Review only the changes on top of #14348, and merge #14348 first.
Summary
Adds Unsloth Studio's own MCP server to the chat MCP dropdown. "Unsloth Studio" is now the first preset in that dropdown. Ticking it lets the chat model call Unsloth Studio's MCP tools in process, with no network listener and no API key to paste.
chat,load_model,unload_model,cancel,start_trainingandexport_model, which would evict or re-enter the chat that calls them or outlive the call. Those six show "Not in chat" in Settings > MCP > Tools (CHAT_DENYLISTinmcp_server.py,chatfield on the tool settings response)./mcpgate is unchanged: it still returns 404 while off and still refuses internal keys.core/inference/studio_tools_mcp.py). A password reset since the chat request signed in stops new keys from being created.routes/mcp_servers.py)./api/...), so they open from whatever address the browser uses.studio_mcp/caller.pyfalls back to a caller bound in a ContextVar when there is no HTTP request. A real HTTP request always uses its own scope, so/mcpnever sees the bound caller.Known limits:
/v1chats can use the row once a UI session has turned it on (same as the stdio and Blender rows), and their inner tool calls do not show in the API monitor.Testing
Backend, from
studio/backend(on the final head the MCP, chat bridge and auth suites pass. The only failures, in files such astest_mcp_images.py, fail the same way on main in this environment):Frontend: typecheck clean,
i18n:check:strictpasses, the MCP and settings tests pass, build andbundle:checkwithin budget (+233 B raw / +15 B transfer, and the budget inscripts/check-bundle-budget.tsis raised by that).Negative control: on main the new tests fail (no
studio_tools_mcpmodule, API-key guard missing). Withcaller.pyreverted, 11 tests fail with "No active HTTP request found".Manual: ran Unsloth Studio from this branch with Qwen3-4B-Instruct-2507 GGUF on one GPU, ticked "Unsloth Studio" in the chat MCP dropdown and asked what is loaded. The chat called
studio_status("Used tool: Unsloth Studio · studio_status") and answered correctly. No key row was left after the call.Screenshots
Before is #14348's head (9a51d6d), since this PR is stacked on it; after is this branch at 801ae88. Both are separate installs. After, the seven tools the chat cannot call (chat, load_model, unload_model, cancel, start_training, export_model, run_recipe) read "Not in chat" in Settings > MCP, and the reserved Unsloth Studio row lists the other 16 tools in process. Before, the same row lists nothing.
Checked end to end on a Colab A100 with Qwen3-4B-Instruct-2507 GGUF: the chat called
studio_statusthrough the row and named the loaded model, turningstudio_statusoff in Settings > MCP removed it from the row, and no per-call key row was left after either call.Studio UI regression check
Base
9c30ea884vs headdb8548862. Functional: NO_REGRESSION, UI coverage 88%, 3 visual change(s), 2 text-only change(s). Only steps whose screenshots differ are shown.crawl/r_images

desktop/s05_route_images

desktop/s06_route_studio

Facts:
path: {'before': '/studio', 'after': '/chat'}crawl/r_data_recipesdesktop/s01_boot