Fix unstructured tool errors being masked as 'outputSchema defined but no structured output returned'#781
Merged
Merged
Conversation
…t no structured output returned'
…_tool return types (error gets propfated and caught by FastMCP's handler)
b-per
approved these changes
May 19, 2026
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.
Summary
When a tool raised an exception,
DbtMCP.call_tool()caught it and returned[TextContent(...)]which is unstructured. After #774 changedstructured_outputto default toTrue, all tools gained anoutputSchema. Because of this, the MCP server rejects the unstructured error response with "Output validation error: outputSchema defined but no structured output returned". The actual error is not returned and hidden to the user/LLM:To address this,
we instead returnraise an error which gets caught by FastMCP's handler before theCallToolResult(isError=True)on exception so the MCP server "short circuits"outputSchemacheck which then properly outputs the failure:Checklist
Additional Notes
One thing Im unsure about about this implementation here is that we have to override the return type established by the parentFastMCP.call_toolmethod and addCallToolResulttoDbtMCP.call_tool's annotations. Because of this, mypy gets a bit mad and we have to tell it to "shhh". No behavioral changes with regards to the LSP, just type annotations! Hope this is fine.^^ addressed in comments