Skip to content

Accept base64url ToolFile data in emitted output - #2141

Open
vstreame wants to merge 1 commit into
UsefulSoftwareCo:mainfrom
vstreame:fix/toolfile-base64url
Open

vstreame wants to merge 1 commit into
UsefulSoftwareCo:mainfrom
vstreame:fix/toolfile-base64url

Conversation

@vstreame

Copy link
Copy Markdown

Summary

Emitted ToolFile output now accepts base64url data, padded or unpadded, such as Gmail's payload.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 whole execute call 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 files
  • bun run lint: 0 warnings, 0 errors on packages/hosts/mcp and packages/core/execution
  • bun run typecheck: @executor-js/host-mcp and @executor-js/execution pass
  • bun run test: not run in full. packages/hosts/mcp/src/tool-server.test.ts (64 tests) and packages/core/execution (79 tests) pass
  • e2e: no scenario added. The change is covered in tool-server.test.ts by tests that run a real MCP client against the host

New tests in packages/hosts/mcp/src/tool-server.test.ts:

  • A Japanese text/plain body in unpadded base64url decodes to the right text.
  • A base64url binary file reaches the client as standard padded base64 (-_8 → +/8=).
  • Invalid data renders the "omitted" note, and the call still completes without an error.

All three fail on main and pass with this change.

Checklist

  • Added a changeset (bun run changeset), or this change needs none.
  • Added or updated tests for the new behaviour.
  • No secrets, credentials, or private data in the diff.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gmail message bodies fail via ToolFile/emit(): base64url data rejected by atob ("Internal tool error")

1 participant