Title: fix(repos)!: stop mirroring file bodies in get_file_contents structured output by jbayardo · Pull Request #3500 · github/github-mcp-server · GitHub
Open Graph Title: fix(repos)!: stop mirroring file bodies in get_file_contents structured output by jbayardo · Pull Request #3500 · github/github-mcp-server
X Title: fix(repos)!: stop mirroring file bodies in get_file_contents structured output by jbayardo · Pull Request #3500 · github/github-mcp-server
Description: Summary On protocol 2026-07-28, get_file_contents returned every file twice: once as the embedded resource in content and again as text/blob in structuredContent. Structured output now carries only the resource uri and mimeType; the body stays in content. Modern JSON text is also encoded without HTML escaping, so it equals JSON.stringify(structuredContent). Why Clients that forward both content and structuredContent to the model pay for each file twice. In Copilot CLI the mirror is ~41.5% of get_file_contents tokens: ~1.07 GB/day of structured content across 81K of 241K daily calls. Without it, ~9.4K/day of the 19.7K results that spill past 20 KiB would stay inline. Separately, json.Marshal escapes <, > and & as \u003c, \u003e and \u0026. Copilot CLI only drops the structured JSON when the text is byte-equal to JSON.stringify(structuredContent), so all-text results containing those characters (e.g. pull_request_read, search_code, web_search, search_repositories) were also sent twice. MCP spec context: modelcontextprotocol/modelcontextprotocol#1624, modelcontextprotocol/modelcontextprotocol#2200. Fixes # What changed RepositoryResourceOutput keeps only uri and mimeType. repositoryContentOutput no longer copies the file body, and the text/blob oneOf is removed from the output schema. applyModernStructuredText encodes with SetEscapeHTML(false) and then unescapes \u003c/\u003e/\u0026 inside JSON strings. The second step is needed because the SDK hands over an already-escaped json.RawMessage. Escaped backslashes are handled, so a literal \u003c in the data stays as-is. Tests: The get_file_contents wire test now expects structured output equal to the legacy blocks minus the resource bodies, with no text or blob. Schema cases updated. New tests cover unescaped modern text and the unescaping scanner's edge cases. get_file_contents.snap regenerated; docs/typed-tool-schemas.md documents both rules. Options considered Option Outcome Metadata-only structured output (chosen) Keeps the typed outputSchema for discovery. The file body is no longer duplicated, and every client still receives it in content. Drop outputSchema for get_file_contents Removes typed output for the tool entirely, which is a bigger contract change. PreserveHandlerContent Only skips the text rewrite; structuredContent is still emitted, so it does not fix the duplication. Omit structuredContent only for file reads Not viable: with an outputSchema, the spec requires structuredContent, and the TS SDK client throws when it is missing. Measurements (real API, stdio binary, github/github-mcp-server@main, protocol 2026-07-28) Bytes of content + structuredContent: Request Before After docs/typed-tool-schemas.md 4,251 + 4,263 4,251 + 313 README.md 123,084 + 123,096 123,084 + 296 pkg/octicons/icons/repo-light.png 852 + 864 852 + 306 pkg/github (directory) 73,351 + 69,198 unchanged pull_request_read #3437: text equals JSON.stringify(structuredContent) ❌ (1 HTML escape) ✅ Legacy protocol (2025-11-25) results are byte-identical before and after. MCP impact No tool or API changes Tool schema or behavior changed — the get_file_contents output schema and structuredContent no longer include text/blob. This is a contract change for consumers that read file bodies from structuredContent (typed outputs shipped in v2.0.0); they should read the embedded resource in content. Go library consumers lose RepositoryResourceOutput.Text and .Blob. Modern JSON text no longer HTML-escapes <, > and &; it parses to the same value. New tool added Prompts tested (tool changes only) Exercised over stdio with a JSON-RPC harness (protocol 2026-07-28 and 2025-11-25), not through an LLM client: "Show me docs/typed-tool-schemas.md in github/github-mcp-server" (text file) "Get README.md from github/github-mcp-server" (large text file) "Fetch pkg/octicons/icons/repo-light.png" (binary file) "List pkg/github in github/github-mcp-server" (directory) "Get PR #3437 in github/github-mcp-server" (pull_request_read; HTML escaping) In every modern-protocol case, structuredContent validated against the advertised outputSchema with Ajv (the TS SDK's validator). I also confirmed in the Copilot CLI source that it still sends the embedded resource body to the model. Security / limits No security or limits impact Auth / permissions considered Data exposure, filtering, or token/size limits considered — this roughly halves get_file_contents result size on the modern protocol and lets clients dedupe all-text results. No data is newly exposed or filtered. Tool renaming I am renaming tools as part of this PR (e.g. a part of a consolidation effort) I have added the new tool aliases in deprecated_tool_aliases.go I am not renaming tools as part of this PR Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs. Lint & tests Linted locally with ./script/lint: gofmt -s -l clean; golangci-lint run (v2.14.0, matching CI) on ./pkg/inventory/... ./pkg/github/... reported 0 issues. Tested locally with ./script/test: go test ./... -count=1 passed. I ran it without -race because cgo isn't available on this Windows machine; CI runs -race. go run ./cmd/github-mcp-server generate-docs produced no changes. Docs Not needed Updated (README / docs / examples) — docs/typed-tool-schemas.md now covers non-HTML-escaped modern text and metadata-only structured output for resource results. README needed no changes.
Open Graph Description: Summary On protocol 2026-07-28, get_file_contents returned every file twice: once as the embedded resource in content and again as text/blob in structuredContent. Structured output now carries only...
X Description: Summary On protocol 2026-07-28, get_file_contents returned every file twice: once as the embedded resource in content and again as text/blob in structuredContent. Structured output now carries only...
Opengraph URL: https://github.com/github/github-mcp-server/pull/3500
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9615da06-ac9f-ad9d-d883-450660e98d96 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 96A6:202708:70E4A0:9DD315:6B05C404 |
| html-safe-nonce | 0dbb5329bec445d8d074234ff99f9469d639515af823fc7fedd0b2fc82157a25 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkE2OjIwMjcwODo3MEU0QTA6OUREMzE1OjZCMDVDNDA0IiwidmlzaXRvcl9pZCI6IjYyMDkxMDM2NzE3OTY4MTA3NTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 78e8e62ec7c71a7d1b1f9b4fa149a55a4e2f8d4a18dadc09258392dc726c1716 |
| hovercard-subject-tag | pull_request:4860902390 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/github/github-mcp-server/pull/3500/files |
| twitter:image | https://avatars.githubusercontent.com/u/1063569?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1063569?s=400&v=4 |
| og:image:alt | Summary On protocol 2026-07-28, get_file_contents returned every file twice: once as the embedded resource in content and again as text/blob in structuredContent. Structured output now carries only... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 13b1c5df76a26b2d8420784ae7f9fb9c438fc6cb0c95a689d26fb49879d8e556 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bcf1e3e7f14567fd89b0218ee06dd0aad8f1d288 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width