Conversation
Gmail returns message bodies as unpadded base64url. Agents wrap them in a ToolFile as documented, and the MCP host's atob() rejected `-`/`_`, which failed the whole execute call with an opaque internal error. Normalize ToolFile data to standard padded base64 before rendering it, so text files decode and image/audio/resource blocks hand clients standard base64. Data that is not base64 in either alphabet renders a note instead of failing the call. Fixes UsefulSoftwareCo#2138
This branch has not been deployed
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
Emitted
ToolFileoutput now accepts base64url data, padded or unpadded, such as Gmail'spayload.body.data. The MCP host converts file data to standard padded base64 before rendering it, for every kind of file (text, image, audio, binary). Before this change,atob()threw on-/_and the wholeexecutecall failed with "Internal tool error". Data that is not valid base64 in either form now renders a short "File output omitted" note, and the rest of the result still comes back. The execute skill now says that base64url data can be passed through unchanged.Linked issue
Fixes #2138
Verification
bun run format:check: clean for the changed filesbun run lint: 0 warnings, 0 errors onpackages/hosts/mcpandpackages/core/executionbun run typecheck:@executor-js/host-mcpand@executor-js/executionpassbun run test: not run in full.packages/hosts/mcp/src/tool-server.test.ts(64 tests) andpackages/core/execution(79 tests) passtool-server.test.tsby tests that run a real MCP client against the hostNew tests in
packages/hosts/mcp/src/tool-server.test.ts:text/plainbody in unpadded base64url decodes to the right text.-_8→+/8=).All three fail on
mainand pass with this change.Checklist
bun run changeset), or this change needs none.