fix(deps): require mcp>=1.19 for CallToolResult passthrough#855
Open
jujumilk3 wants to merge 1 commit intoanthropics:mainfrom
Open
fix(deps): require mcp>=1.19 for CallToolResult passthrough#855jujumilk3 wants to merge 1 commit intoanthropics:mainfrom
jujumilk3 wants to merge 1 commit intoanthropics:mainfrom
Conversation
Since anthropics#717, create_sdk_mcp_server() returns a CallToolResult from its @server.call_tool() handler. The mcp low-level server only has the isinstance(results, CallToolResult) passthrough branch starting at mcp==1.19.0. On mcp<=1.18.x, CallToolResult (a pydantic BaseModel) falls into the iterable branch, yielding (field, value) tuples that fail ContentBlock union validation with 20 errors (4 fields x 5 union members). Bump the minimum mcp constraint so every install has the passthrough branch anthropics#717 relies on. Refs anthropics#717
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.
Since #717, create_sdk_mcp_server() returns a CallToolResult from its @server.call_tool() handler. The mcp low-level server only has the isinstance(results, CallToolResult) passthrough branch starting at mcp==1.19.0. On mcp<=1.18.x, CallToolResult (a pydantic BaseModel) falls into the iterable branch, yielding (field, value) tuples that fail ContentBlock union validation with 20 errors (4 fields x 5 union members).
Bump the minimum mcp constraint so every install has the passthrough branch #717 relies on.
mcp<1.19.0makes every SDK MCP tool call fail with:The four tuples are exactly the four fields of
CallToolResultin declaration order (meta,content,structuredContent,isError) — the fingerprint of a pydanticBaseModelbeing iterated as a list.Root cause
The
mcplow-level server's result-normalization dispatch lives inmcp/server/lowlevel/server.py::call_tool. Frommcp>=1.19.0it starts with:In
mcp<=1.18.xthe firstisinstance(results, CallToolResult)branch does not exist. ACallToolResultis a pydanticBaseModel, which:isinstance(_, tuple)✗isinstance(_, dict)✗hasattr(_, "__iter__")✓ (pydantic models yield(field, value)tuples)So
mcp<=1.18falls into the iterable branch, doescontent=list(unstructured_content)→[('meta', None), ('content', [TextContent(...)]), ('structuredContent', None), ('isError', False)], and re-wraps those tuples inCallToolResult(content=...), triggering 20ContentBlockunion errors (4 tuples × 5 union members).#717's description said "The MCP framework already checks
isinstance(results, CallToolResult)and passes it through as-is (confirmed in MCP server source)" — which is correct, but only frommcp==1.19.0onward. The min-version bump was missed.mcpversions checkedDownloaded each sdist from PyPI and grepped
src/mcp/server/lowlevel/server.pyfor theisinstance(results, types.CallToolResult)branch: