Skip to content

Studio: move to mcp 2 and fastmcp 4 - #16475

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:mcp-2-upgrade
Nov 4, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:mcp-2-upgrade

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Newer MCP servers such as MangaBaka failed to connect in Studio with a 400 Bad Request, because the old mcp client only knew the older connection handshake.

This moves Studio to mcp 2 and fastmcp 4. Chat and Test connection now work with newer servers, and older servers still work.

data-designer uses a function mcp 2 removed, so a small import hook adds it back. The same hook makes data-designer's MCP session negotiate the protocol version, so recipes reach both older servers and servers that only accept the new protocol (checked against MangaBaka and a fastmcp 3 server).

Before / after

Chat > MCP servers > Add server > Test connection on https://api.mangabaka.org/mcp (a server that only speaks protocol 2026-07-28). Base 3d9b1cd on the left, this PR (0caf584) on the right.

MCP Test connection before and after

Before: "Connection failed: Client error '400 Bad Request'". After: "Connected (18 tools)".

@NilayYadav NilayYadav self-assigned this Nov 2, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Reached Codex review convergence at NilayYadav#1082 on 5d6c499.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Reached Codex review convergence at NilayYadav#1082 on ce4ef21.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T09:53:22.484310Z 0caf584 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: ce4ef2147a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen danielhanchen self-assigned this Nov 4, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 0caf584e15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 4, 2026
@danielhanchen
danielhanchen merged commit 38fa6c1 into unslothai:main Nov 4, 2026
danielhanchen added a commit to NilayYadav/unsloth that referenced this pull request Nov 6, 2026
Fixes unslothai#16878

Enabling Blender MCP fails with "Could not connect to Blender MCP" since
Studio moved to mcp 2 (unslothai#16475). The pinned Blender MCP runtime imports
`mcp.server.fastmcp`, which mcp 2 removed (it was renamed to
`mcp.server.mcpserver.MCPServer`), so the server process dies on import:

```
ModuleNotFoundError: No module named 'mcp.server.fastmcp'. This is mcp 2.x, where FastMCP was renamed to MCPServer ...
```

Upstream Blender MCP has no mcp 2 revision to move the pin to (it
constrains `mcp<2`), and Studio cannot go back to mcp 1 because
data-designer and the newer MCP connection handshake need mcp 2.

This change makes the launcher register `mcp.server.fastmcp` as an alias
of `mcp.server.mcpserver` when the installed mcp has no such module,
before the runtime is imported. The runtime only uses `FastMCP(name,
instructions=...)`, `@tool(annotations=...)`, `Image(data=...,
format=...)` and `run(transport="stdio")`, all of which keep the same
signature on `MCPServer`.

One behaviour differs: mcp 2 hides the text of any exception a tool
raises, so the model would only see `Error executing tool
execute_blender_code_for_cli` instead of the Blender traceback, or
`Error executing tool get_objects_summary` instead of "Cannot connect to
Blender ... Ensure Blender is running with the MCP addon enabled". The
aliased `FastMCP` re-raises tool exceptions as `ToolError`, which mcp 2
reports with the same `Error executing tool <name>: <message>` text mcp
1 produced.

With mcp 1 installed the alias is never added, so nothing changes there.
The Blender MCP setup flow and UI are unchanged.

### Testing

Pinned runtime (`4309a39`, checksum-verified archive) launched through
`launcher.py` over stdio, listed and called through a fastmcp client
against a fake Blender bridge socket:

| Environment | Before | After |
|---|---|---|
| mcp 2.3.0, fastmcp 4.1.6 (current Studio) | `ModuleNotFoundError: No
module named 'mcp.server.fastmcp'`, connection closed | 23 tools listed,
`get_screenshot_of_window_as_json` returns JSON,
`get_screenshot_of_window_as_image` returns an `image/png` ImageContent
with the exact bytes |
| mcp 1.30.0, fastmcp 2.14.7 | 23 tools, both calls work | same, alias
not used |

Parity: the same harness on mcp 1.30.0 and on mcp 2.3.0 with this change
gives byte-identical output (17709 bytes) for all 23 tool input / output
schemas, annotations and descriptions, successful JSON, image and
`execute_blender_code` calls, bridge errors, invalid arguments, and
Blender not running.

New test `test_launcher_runs_v1_fastmcp_runtime_on_installed_mcp` runs
the launcher on a stub runtime written against the v1 API and checks a
failing tool's error text. It fails on main with mcp 2
(`ModuleNotFoundError`), fails with only the plain alias (`'Error
executing tool fail'`), and passes with this change on both mcp 1 and
mcp 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants