Title: `create_or_update_file` content description doesn't specify plaintext, leading models to double-encode · Issue #2981 · github/github-mcp-server · GitHub
Open Graph Title: `create_or_update_file` content description doesn't specify plaintext, leading models to double-encode · Issue #2981 · github/github-mcp-server
X Title: `create_or_update_file` content description doesn't specify plaintext, leading models to double-encode · Issue #2981 · github/github-mcp-server
Description: Describe the bug The content parameter of create_or_update_file expects plaintext, but its description does not say so, and the REST endpoint the tool wraps expects base64. Models frequently resolve that ambiguity by base64-encoding the ...
Open Graph Description: Describe the bug The content parameter of create_or_update_file expects plaintext, but its description does not say so, and the REST endpoint the tool wraps expects base64. Models frequently resolv...
X Description: Describe the bug The content parameter of create_or_update_file expects plaintext, but its description does not say so, and the REST endpoint the tool wraps expects base64. Models frequently resolv...
Opengraph URL: https://github.com/github/github-mcp-server/issues/2981
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`create_or_update_file` content description doesn't specify plaintext, leading models to double-encode","articleBody":"### Describe the bug\n\nThe `content` parameter of `create_or_update_file` expects **plaintext**, but its description\ndoes not say so, and the REST endpoint the tool wraps expects **base64**. Models frequently\nresolve that ambiguity by base64-encoding the content themselves, which the server then encodes\nagain. The result is a successful API call that commits base64 text as the file's contents, with\nno error anywhere.\n\nThe schema says only:\n\n```json\n\"content\": { \"description\": \"Content of the file\", \"type\": \"string\" }\n```\n\nThe server treats it as plaintext and encodes exactly once\n([`pkg/github/repositories.go#L484-L485`](https://github.com/github/github-mcp-server/blob/main/pkg/github/repositories.go#L484-L485)):\n\n```go\n// json.Marshal encodes byte arrays with base64, which is required for the API.\ncontentBytes := []byte(content)\n```\n\nThat is correct behavior. The problem is that a model reading the tool description has no way to\nknow it, while it has very likely seen\n[`PUT /repos/{owner}/{repo}/contents/{path}`](https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents),\nwhose `content` field is documented as \"The new file content, using Base64 encoding.\" Given a\nparameter named `content` on a tool named `create_or_update_file`, pre-encoding is a reasonable\ninference.\n\nThe failure is silent in both directions: the tool returns success, and the resulting file looks\nfine to the API. It surfaces only when a human opens the file and finds one long base64 line.\nDecoding it yields exactly the content the model intended to write.\n\n### Affected versions\n\nNot version-specific. The description is byte-identical in `v1.6.0`, `v1.8.0`, and `main`, so\nupgrading does not change it. The remote server runs the same code and is equally affected.\n\n### Steps to reproduce\n\n1. Point an agent at a repository with `create_or_update_file` available.\n2. Ask it to modify an existing text file and commit the result.\n3. Inspect the committed file.\n\nWhether the model pre-encodes is model- and prompt-dependent, so this does not reproduce 100% of\nthe time. That is arguably what makes it worth fixing: it is an intermittent, silent corruption\nthat depends on how a given model resolves an ambiguous parameter description.\n\n### Expected behavior\n\nThe description states the expected encoding, so a model does not have to guess.\n\n### Suggested fix\n\nA description change is probably sufficient:\n\n```json\n\"content\": {\n \"description\": \"Content of the file as plain text. Do NOT base64-encode it; the server handles encoding.\",\n \"type\": \"string\"\n}\n```\n\nOptionally, defensively reject input that is unambiguously already-encoded (valid base64 whose\ndecoding yields valid UTF-8 that differs from the input). That has false-positive risk for files\nthat genuinely contain base64, so the description fix is the safer first step.\n\nThe same ambiguity exists on sibling tools and would be worth fixing together:\n\n- `push_files` — `files[].content`, described as `\"file content\"`\n- `create_gist` — `\"Content for simple single-file gist creation\"`\n- `update_gist` — `\"Content for the file\"`\n\n### Possibly related\n\n- #2182 (`create_or_update_file silently truncates large files`) was closed as not reproducible.\n Pre-encoding would inflate content by roughly 33% and collapse it to a single line, which could\n present as truncation, so these may share a root cause.\n- #841 reported the mirror-image problem on the read path.\n","author":{"url":"https://github.com/ericsciple","@type":"Person","name":"ericsciple"},"datePublished":"2026-07-30T20:48:05Z","url":"https://github.com/github/github-mcp-server/issues/2981"}
| 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:5cfa4bff-8e6f-ae08-d249-4d62bdce3cb8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 89F6:1759AA:984CB5:CC39A9:6B063CDC |
| html-safe-nonce | e9736fd99d5093051124a5ce51c9ab56a1e1c210f3fc5cbaa793ab76ed54006d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUY2OjE3NTlBQTo5ODRDQjU6Q0MzOUE5OjZCMDYzQ0RDIiwidmlzaXRvcl9pZCI6IjczMjA3NDAxODU1MjI5NzgwMTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 67d0fd0a1674562db523d49e7c318a086d89cb47857747da194e7d1023b01ef6 |
| hovercard-subject-tag | issue:5023864403 |
| 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/2981/issue_layout |
| twitter:image | https://opengraph.githubassets.com/62707e52b3ea019307e41fd1d6376a6247ade99a2e32e778bcbd4b93581e41c7/github/github-mcp-server/issues/2981 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/62707e52b3ea019307e41fd1d6376a6247ade99a2e32e778bcbd4b93581e41c7/github/github-mcp-server/issues/2981 |
| og:image:alt | Describe the bug The content parameter of create_or_update_file expects plaintext, but its description does not say so, and the REST endpoint the tool wraps expects base64. Models frequently resolv... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ericsciple |
| 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