feat(rust): support binary tool results#1222
Merged
stephentoub merged 2 commits intogithub:mainfrom May 8, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the Rust SDK’s handling of MCP tool results that include binary payloads, ensuring binary resources are preserved for LLM consumption (instead of being forced into text-only results).
Changes:
- Default MCP
resource.blobmimeTypetoapplication/octet-streamwhenmimeTypeis missing or an empty string. - Add Rust type-level serialization tests to confirm the
binaryResultsForLlmwire shape is emitted correctly (and omitted whenNone). - Expand MCP conversion tests to cover image content, resource blob content, mixed text/binary, and no-binary cases.
Show a summary per file
| File | Description |
|---|---|
rust/src/types.rs |
Adds focused serialization tests for ToolResultExpanded.binaryResultsForLlm wire output. |
rust/src/tool.rs |
Treats empty mimeType as missing (defaults to application/octet-stream) and adds targeted MCP conversion tests for binary content. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
Collaborator
|
Thanks, @cschleiden. I think the Python and Node.js SDKs have the same bug. Would you mind fixing those in this PR as well? |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Rust tool results need to preserve binary payloads from MCP tool calls so callers can return images and binary resources to the LLM without collapsing structured results into text.
This updates the Rust SDK coverage around binary tool results by ensuring resource blobs default to
application/octet-streamwhenmimeTypeis missing or empty, and by adding focused tests for the publicbinaryResultsForLlmwire shape plus MCP image, resource blob, mixed text/binary, and no-binary conversion behavior.Validation:
cd rust && cargo test --all-featurescargo +nightly-2026-04-14 fmt --checkcargo clippy --all-features --all-targets -- -D warnings