Skip to content

fix(mcp): preserve binary skill other files via base64 encoding - #2582

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2573-mcp-binary
Aug 4, 2026
Merged

fix(mcp): preserve binary skill other files via base64 encoding#2582
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-2573-mcp-binary

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Background

Issue #2573 tracks four follow-ups from the PR #2568 review.

Items 1 and 3, plus the isBinaryBuffer part of item 2, are obsolete: PR #2575 deleted isBinaryBuffer from src/utils/file.ts entirely, because skill companion files are now copied byte-faithfully with no text/binary split.

What remained actionable:

Changes

  • Skill otherFiles entries now carry an optional encoding field ("utf-8" | "base64"), applied symmetrically on get and put.
    • On get, encoding is decided by whether the buffer survives a UTF-8 round trip byte-identically; text files keep encoding: "utf-8" and their existing body, so existing clients are unaffected.
    • On put, the client-declared encoding is trusted (defaulting to "utf-8"), base64 bodies are validated to reject silently-dropped invalid input, and the decoded bytes are written with writeFileBuffer instead of writeFileContent.
    • The 1MB size check now measures decoded byte length rather than string length.
  • Tool schemas (src/mcp/skills.ts, src/mcp/tools.ts) and tool descriptions updated to expose encoding.
  • docs/reference/mcp-server.md documents the otherFiles shape and the encoding rules (embedded docs regenerated).
  • Tests: binary other file round-trips byte-identically through put/get, text file keeps the utf-8 shape, omitted encoding is treated as UTF-8 even when the body looks like base64, invalid base64 is rejected, plus direct readFileBufferOrNull tests (missing file -> null, existing file -> exact bytes).

Closes #2573

🤖 Generated with Claude Code

cm-dyoshikawa and others added 2 commits August 4, 2026 01:57
Skill other files were transported through the MCP get/put surface as UTF-8 strings, which corrupted binary files such as images. Other file entries now carry an optional encoding field (utf-8 by default, base64 for binary), applied symmetrically on get and put, and put writes the decoded bytes verbatim.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Also document the encoding round-trip requirement and the base64/size validation rules, and measure the skill size limit in bytes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dyoshikawa
dyoshikawa merged commit 60beab8 into main Aug 4, 2026
9 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-2573-mcp-binary branch August 4, 2026 11:58
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.

Follow-ups from PR #2568 review: harden isBinaryBuffer, add direct util tests, fix MCP binary corruption

2 participants