Fix binary resource blob encoding - #3098
Merged
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes double-base64 encoding of binary MCP resources.
Changes:
- Pass raw binary bytes to MCP resource blobs.
- Add PNG/PDF wire-format regression coverage.
- Preserve text-resource behavior.
Show a summary per file
| File | Description |
|---|---|
pkg/github/repository_resource.go |
Returns raw response bytes as blobs. |
pkg/github/repository_resource_test.go |
Verifies single-encoded PNG resources. |
pkg/github/repositories.go |
Removes manual blob encoding. |
pkg/github/repositories_test.go |
Tests text and binary wire serialization. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
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
Returns raw binary bytes through MCP resource blobs so the Go SDK performs exactly one base64 encoding. The same migration bug is fixed in both
get_file_contentsand repository resource reads.Why
Fixes #3097.
Binary resources were manually base64-encoded before being assigned to
mcp.ResourceContents.Blob []byte, causingencoding/jsonto encode the base64 text a second time. Images were corrupted after a spec-compliant single decode and could poison subsequent client conversation turns.What changed
ResourceContents.Blobinget_file_contents.ResourceContents.Blobin repository resource reads, the only other affected production construction found by the audit.MCP impact
Binary resource behavior is corrected to the MCP wire contract. Tool names, descriptions, input schemas, and response shapes are unchanged.
Prompts tested (tool changes only)
get_file_contentsand consume it as an image.get_file_contents.Security / limits
The change removes the extra base64 layer and its persistent invalid payload growth; existing 1 MiB resource-link behavior and data exposure are unchanged.
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testDocs