Skip to content

fix: preserve FastMCP tool error results#2735

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
he-yufeng:fix/v1x-tool-error-result-schema
Open

fix: preserve FastMCP tool error results#2735
he-yufeng wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
he-yufeng:fix/v1x-tool-error-result-schema

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • skip structured-output validation for CallToolResult(isError=True) in FastMCP's v1.x result conversion path
  • keep validation unchanged for successful CallToolResult values with annotated output schemas
  • add a regression test for annotated tool error results without structuredContent

Fixes #2429.

To verify

  • python -m pytest tests\server\fastmcp\test_func_metadata.py -q -k "tool_call_result"
  • python -m pytest tests\server\fastmcp\test_func_metadata.py -q
  • python -m py_compile src\mcp\server\fastmcp\utilities\func_metadata.py tests\server\fastmcp\test_func_metadata.py
  • python -m ruff check src\mcp\server\fastmcp\utilities\func_metadata.py tests\server\fastmcp\test_func_metadata.py
  • git diff --check

@he-yufeng he-yufeng force-pushed the fix/v1x-tool-error-result-schema branch from b6029c4 to bbac5ca Compare May 31, 2026 08:18
@he-yufeng
Copy link
Copy Markdown
Author

Updated the test assertion to narrow the tool result content before accessing text, which fixes the pyright failure from the first CI run.

Additional local verification:

  • uv run pyright tests/server/fastmcp/test_func_metadata.py
  • uv run python -m pytest tests/server/fastmcp/test_func_metadata.py -q
  • .venv\Scripts\python.exe -m ruff check src/mcp/server/fastmcp/utilities/func_metadata.py tests/server/fastmcp/test_func_metadata.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.

1 participant