Pass through full CallToolResult to preserve binary content#21
Merged
Conversation
Previously invoke_tool collapsed all content to a string, silently dropping image, audio, and embedded-resource blocks with placeholder text. Now ToolProxyHandler returns CallToolResult directly and ConsumerTools.InvokeTool returns Task<CallToolResult>, which the MCP SDK passes through unchanged. The REST endpoint also returns the full structured result so binary content survives both paths. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
rockfordlhotka
force-pushed
the
feature/pass-through-binary-content
branch
from
March 11, 2026 00:41
fd59aa8 to
ea49d52
Compare
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
ToolProxyHandler.InvokeAsyncnow returnsTask<CallToolResult>instead ofTask<string>, passing the downstream result through unchangedConsumerTools.InvokeToolreturnsTask<CallToolResult>— the MCP SDK natively supports this return type and passes it straight to the callerServicesController) returns the full structuredCallToolResultJSONProblem
The previous implementation collapsed all tool results to a single string, silently dropping any non-text content blocks:
This meant any downstream MCP server that generates or returns images, audio, or embedded resources would have that content lost in transit.
What flows through now
TextContentBlockcontent[]ImageContentBlock[image content block]AudioContentBlock[audio content block]EmbeddedResourceContentBlockIsError = trueToolExecutionException(HTTP 400)isErrorflag intactBreaking change
The REST
POST /api/services/{name}/tools/{tool}/invokeresponse shape changes from{ "result": "text" }to the fullCallToolResultJSON ({ "content": [...], "isError": false }). Callers should checkisErrorin the body rather than relying on HTTP 400 for tool errors.Test plan
dotnet build)dotnet test)ImageContentBlockthrough to the caller🤖 Generated with Claude Code