Repository navigation
Studio: move to mcp 2 and fastmcp 4 - #16475
Conversation
|
Reached Codex review convergence at NilayYadav#1082 on 5d6c499. |
|
Reached Codex review convergence at NilayYadav#1082 on ce4ef21. |
|
@codex review |
|
@codex security review |
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. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ 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". |
…nly servers [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ 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". |
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.
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). Base3d9b1cdon the left, this PR (0caf584) on the right.Before: "Connection failed: Client error '400 Bad Request'". After: "Connected (18 tools)".