Skip to content

Empty mcp tool result error #1142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2025
Merged

Conversation

thoo
Copy link
Contributor

@thoo thoo commented Jul 16, 2025

Summary

Fixed MCPUtil.invoke_mcp_tool() to return "[]" instead of logging an error when MCP tools return empty content. Empty results (None, []) are valid outputs and should be treated consistently with
function tools. The None -> "[]" and [] -> "[]" behavior comes from the MCP Python SDK's FastMCP implementation.

Test plan

  • Added comprehensive test coverage in test_mcp_fastmcp_behavior_verification() that verifies all FastMCP edge cases
  • Enhanced FakeMCPServer to support custom content testing scenarios
  • Ran full test suite - all tests pass
  • Verified the fix handles None, [], {}, [{}], [[]] cases correctly

Issue number

Closes #1035

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@seratch seratch added bug Something isn't working feature:mcp labels Jul 16, 2025
@seratch seratch requested a review from rm-openai July 16, 2025 03:23
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense and looks good to me; thanks for sending this!

@rm-openai rm-openai merged commit 076eb72 into openai:main Jul 16, 2025
5 checks passed
@rm-openai rm-openai mentioned this pull request Jul 16, 2025
rm-openai added a commit that referenced this pull request Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature:mcp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty tool output incorrectly triggers “Errored MCP tool result”
3 participants