Skip to content

fix(server): align call_tool result shapes#2830

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/mcpserver-call-tool-result-types
Open

fix(server): align call_tool result shapes#2830
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/mcpserver-call-tool-result-types

Conversation

@he-yufeng

Copy link
Copy Markdown

Summary

  • remove the unreachable raw-dict branch in MCPServer._handle_call_tool
  • align MCPServer.call_tool with the result shapes actually returned by the tool manager
  • add regression coverage for direct CallToolResult returns and unstructured content-block returns

Fixes #2695

To verify

  • uv run --frozen pytest tests\interaction\mcpserver\test_tools.py::test_tool_returning_call_tool_result_passes_through tests\interaction\mcpserver\test_tools.py::test_tool_without_output_schema_returns_unstructured_content tests\interaction\mcpserver\test_tools.py::test_call_tool_model_return_becomes_structured_content tests\server\mcpserver\test_server.py::TestServer::test_call_tool_return_annotation_lists_reachable_shapes -q
  • uv run --frozen pytest tests\interaction\test_coverage.py -q
  • uv run --frozen ruff check src\mcp\server\mcpserver\server.py tests\interaction\mcpserver\test_tools.py tests\interaction\_requirements.py tests\server\mcpserver\test_server.py
  • uv run --frozen pyright src\mcp\server\mcpserver\server.py tests\interaction\mcpserver\test_tools.py tests\interaction\_requirements.py tests\server\mcpserver\test_server.py
  • git diff --check

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