Skip to content

fix: align MCPServer tool result shapes#2833

Open
Epochex wants to merge 1 commit into
modelcontextprotocol:mainfrom
Epochex:codex/mcpserver-tool-result-shapes
Open

fix: align MCPServer tool result shapes#2833
Epochex wants to merge 1 commit into
modelcontextprotocol:mainfrom
Epochex:codex/mcpserver-tool-result-shapes

Conversation

@Epochex

@Epochex Epochex commented Jun 11, 2026

Copy link
Copy Markdown

Closes #2695.

Summary

This removes the unreachable raw-dict branch from MCPServer._handle_call_tool() and aligns MCPServer.call_tool() with the shapes that convert_result=True can actually return:

  • CallToolResult returned directly by a tool
  • a bare Sequence[ContentBlock] for unstructured content
  • (Sequence[ContentBlock], dict[str, Any]) when structured output is available

The shared ToolResult alias keeps the public annotation and handler expectations from drifting again.

Validation

uv run pytest tests/server/mcpserver/test_server.py -q
uv run ruff check src/mcp/server/mcpserver/server.py tests/server/mcpserver/test_server.py
uv run ruff format --check src/mcp/server/mcpserver/server.py tests/server/mcpserver/test_server.py
uv run pyright src/mcp/server/mcpserver/server.py tests/server/mcpserver/test_server.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead code path in MCPServer._handle_call_tool and incorrect call_tool return type

1 participant