Title: create_or_update_file cannot represent true binary content — no encoding parameter, JSON string requires valid UTF-8 · Issue #3312 · github/github-mcp-server · GitHub
Open Graph Title: create_or_update_file cannot represent true binary content — no encoding parameter, JSON string requires valid UTF-8 · Issue #3312 · github/github-mcp-server
X Title: create_or_update_file cannot represent true binary content — no encoding parameter, JSON string requires valid UTF-8 · Issue #3312 · github/github-mcp-server
Description: Describe the bug create_or_update_file has no way to write a genuine binary file (e.g. a PNG) without corruption, even when the caller follows the tool's own current description exactly. The content parameter description says: "Content o...
Open Graph Description: Describe the bug create_or_update_file has no way to write a genuine binary file (e.g. a PNG) without corruption, even when the caller follows the tool's own current description exactly. The conten...
X Description: Describe the bug create_or_update_file has no way to write a genuine binary file (e.g. a PNG) without corruption, even when the caller follows the tool's own current description exactly. The co...
Opengraph URL: https://github.com/github/github-mcp-server/issues/3312
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"create_or_update_file cannot represent true binary content — no encoding parameter, JSON string requires valid UTF-8","articleBody":"### Describe the bug\n\n`create_or_update_file` has no way to write a genuine binary file (e.g. a PNG) without corruption, even when the caller follows the tool's own current description exactly.\n\nThe `content` parameter description says:\n\n> \"Content of the file, exactly as it should appear once written. Do not base64-encode it; this server does that before calling the REST API.\"\n\nThis reads as a fix for #2981 (models pre-encoding out of confusion with the REST API docs). But it doesn't address the deeper problem: **`content` is a JSON string, and JSON strings must be valid UTF-8.** Raw binary bytes (arbitrary byte sequences, e.g. PNG magic bytes `89 50 4E 47 ...`) are frequently *not* valid UTF-8, so there is no way to place them into this parameter at all — encoded or not:\n\n- Pass the raw bytes as-is → most MCP/JSON transports will reject the call outright (invalid UTF-8 in a string field), or the bytes get mangled by whatever text encoding recovery the client/transport applies.\n- Pre-encode as base64 yourself (the \"obvious\" workaround, and what #2981's own reproduction did) → per the current server behavior, the base64 **text** is stored literally as the file's bytes. The tool reports success; the resulting file is corrupt (its content is the ASCII base64 string, not the decoded image).\n\n### Minimal reproduction\n\nCreated a 77-byte, 10×10 solid-color PNG, base64-encoded it (104 chars), and called `create_or_update_file` with that base64 string as `content`:\n\ncontent: \"iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAFElEQVR4nGP8n2XJgBsw4ZEbwdIABR4Btgm0KTcAAAAASUVORK5CYII=\"\n\n\nResult: commit succeeds, `content.size` in the response is **104** (the length of the base64 *text*), not 77 (the actual PNG size). Fetching the file back with `get_file_contents` returns the literal base64 string as the file's text content — not a decodable/valid PNG.\n\nThere is no parameter on this tool to say \"this content is base64\" or otherwise indicate a binary-safe encoding, unlike what a `content_base64` / `encoding` field would provide. Every path leads to a corrupted binary file for any client that can only pass JSON string parameters (which is all MCP clients).\n\n### Impact\n\nAny MCP client — including AI agents — that needs to commit a binary asset (image, font, icon, PDF, zip, etc.) via `create_or_update_file` (or the equivalent multi-file `push_files`, which has the identical `content: string` shape per-file) cannot do so reliably. The only safe workaround currently is bypassing this tool entirely (e.g. driving the GitHub web upload UI in a browser, or using a real `git` client locally), which defeats the purpose of having this tool.\n\n### Suggested fix\n\nAdd an explicit binary-safe path, e.g.:\n- An optional `encoding` (or `content_encoding`) parameter on `create_or_update_file` and each file entry in `push_files`, with values like `\"utf-8\"` (default, current behavior) and `\"base64\"` — when `\"base64\"`, the server decodes the given base64 string once and writes the resulting raw bytes, instead of writing the base64 text (or double-encoding it).\n- Document clearly in the parameter description which mode is used, since this is exactly the ambiguity #2981 tried (and, per this report, failed) to close.\n\n### Related\n\n- #2981 — addressed the *ambiguity* around double-encoding of text-ish content, but this report shows the description fix alone does not make binary uploads possible; there is still no valid way to submit non-UTF-8 bytes.\n- #3097 — the mirror-image bug on the read path (`get_file_contents` double-base64-encoding binaries), already fixed.\n- #372 — requested a non-base64 *read* option; this report is the write-side binary-safe request.\n\n### Environment\n\nReproduced via the hosted GitHub MCP Server connector, 2026-09-19, through an Anthropic Claude MCP connector session. Not version-specific — the tool's `content` parameter has always been a plain JSON string with no encoding flag.","author":{"url":"https://github.com/DrWilliamBell","@type":"Person","name":"DrWilliamBell"},"datePublished":"2026-09-19T21:28:44Z","url":"https://github.com/github/github-mcp-server/issues/3312"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:13fac41b-6a65-e5ed-49fd-4a3fff0728d4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D438:1188C0:AD6ABB:E0BE80:6B0638A7 |
| html-safe-nonce | 36512feb7a08f0b63b94513ca94747b9196a4908e19200b852e77870335bac22 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDM4OjExODhDMDpBRDZBQkI6RTBCRTgwOjZCMDYzOEE3IiwidmlzaXRvcl9pZCI6IjQ2MjIwMjMxNDY0OTEyMjk4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2bc9ce568b8dfa18b8504a7bf5c605d3c30b58c75764cdcafb206ee4cb3d9be3 |
| hovercard-subject-tag | issue:5513696634 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/github-mcp-server/3312/issue_layout |
| twitter:image | https://opengraph.githubassets.com/90634290c6b0a51dcb314827b0f7d377bad0ec79f23bbed9ef4ac3d16fe0ae01/github/github-mcp-server/issues/3312 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/90634290c6b0a51dcb314827b0f7d377bad0ec79f23bbed9ef4ac3d16fe0ae01/github/github-mcp-server/issues/3312 |
| og:image:alt | Describe the bug create_or_update_file has no way to write a genuine binary file (e.g. a PNG) without corruption, even when the caller follows the tool's own current description exactly. The conten... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DrWilliamBell |
| hostname | github.com |
| expected-hostname | github.com |
| None | dcf72c457c022486d23c3cbb0dd21aba537a87611ca9ddabd1799cf2eaa9b297 |
| turbo-cache-control | no-preview |
| go-import | github.com/github/github-mcp-server git https://github.com/github/github-mcp-server.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 942771284 |
| octolytics-dimension-repository_nwo | github/github-mcp-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 942771284 |
| octolytics-dimension-repository_network_root_nwo | github/github-mcp-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0f38f5735226749ec5e08a8649dce4cb2613d9ad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width