Title: fix(repos): wrap get_file_contents directory listings in an object by Mystery01092000 · Pull Request #3869 · github/github-mcp-server · GitHub
Open Graph Title: fix(repos): wrap get_file_contents directory listings in an object by Mystery01092000 · Pull Request #3869 · github/github-mcp-server
X Title: fix(repos): wrap get_file_contents directory listings in an object by Mystery01092000 · Pull Request #3869 · github/github-mcp-server
Description: Summary get_file_contents now returns directory listings as {"entries": [...]} instead of a bare top-level array, so structuredContent is always a JSON object. Clients that only accept object-valued structuredContent can now list directories. Why Clients that model structuredContent as an object, such as SDKs that use dict[str, Any], reject the directory response before the agent sees any entries: structuredContent Input should be a valid dictionary [type=dict_type, input_value=[{'name': '.dockerignore'...}], input_type=list] RepositoryContentsOutput.MarshalJSON encoded the directory slice directly, and repositoryContentsOutputSchema() advertised a matching array variant. Fixes #3864 What changed Added RepositoryDirectoryOutput{Entries []*RepositoryDirectoryEntryOutput \json:"entries"`}. RepositoryContentsOutput.Directory` now points to it. The output schema's directory variant is now {"type":"object","properties":{"entries":{"type":"array",...}},"required":["entries"],"additionalProperties":false}. The variants are now null, directory object, and file-content object. The two object variants stay mutually exclusive (entries and content are each required, and no additional properties are allowed). An empty directory returns {"entries": []}, not {"entries": null}. The file (non-directory) path is unchanged. It still uses the {"content": [...]} shape. Text output: Legacy protocol versions (before 2026-07-28): the text content is byte-for-byte unchanged. It is still the JSON array of entries, and no structuredContent is sent. The existing byte-exact legacy assertions in TestTypedRepositoryOutputs still pass, and a new assertion checks that the legacy directory text is still an array. 2026-07-28 protocol: following the typed-output convention, the text content mirrors structuredContent, so it is now {"entries":[...]}. Updated the get_file_contents toolsnap. Tests: TestTypedRepositoryOutputs: directory calls now decode structuredContent into map[string]json.RawMessage, the way an object-only consumer would. They check that entries is non-nil and assert the wrapped shape for the submodule, empty, and projected-field directories. TestRepositoryOutputUnions: {"entries":[]} and {"entries":[{"name":"file"}]} are valid. [], [{"name":"file"}], {"entries":null} and {"entries":[],"content":[]} are rejected. New TestRepositoryContentsOutputSchemaIsObjectValued: every non-null output schema variant is type: object. TestTypedCompatibilityDirectoryProjection: the legacy text is still the array. The modern text and structuredContent are the wrapped object. MCP impact No tool or API changes Tool schema or behavior changed New tool added The get_file_contents output schema and directory structuredContent change from an array to {"entries": [...]}. This is visible only to clients on the 2026-07-28 protocol, which receive outputSchema/structuredContent. Legacy-protocol responses are unchanged. Prompts tested (tool changes only) Covered by unit and in-memory MCP session tests; not exercised against a live client. "List the files in the root of github/github-mcp-server" (path: "/", fields: ["name","type","path"]) "What's in pkg/github?" Security / limits No security or limits impact Auth / permissions considered Data exposure, filtering, or token/size limits considered 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 Lint & tests Linted locally with ./script/lint (ran golangci-lint run v2.14.0 and gofmt -s -l . in Docker) Tested locally with ./script/test (ran go test ./... in Docker with golang:1.27.4) Targeted tests: $ go test -count=1 -v -run "TestTypedRepositoryOutputs|TestRepositoryOutputUnions|TestRepositoryContentsOutputSchemaIsObjectValued|TestTypedCompatibilityDirectoryProjection" ./pkg/github/ --- PASS: TestTypedCompatibilityDirectoryProjection (0.01s) --- PASS: TestTypedRepositoryOutputs (0.32s) --- PASS: TestRepositoryOutputUnions (0.00s) --- PASS: TestRepositoryContentsOutputSchemaIsObjectValued (0.00s) ok github.com/github/github-mcp-server/v2/pkg/github 0.353s (241 passing tests and subtests, 0 failing.) Full suite (go test -count=1 -json ./...): 9054 passed, 2 skipped, 0 failed. $ golangci-lint run 0 issues. UPDATE_TOOLSNAPS=true go test ./... changed only get_file_contents.snap. script/generate-docs produced no changes, because output schemas are not part of the generated docs. Docs Not needed Updated (README / docs / examples) Skills Updated relevant skills or confirmed no bundled skill applies. Bundled skills mention get_file_contents but not the shape of its directory output. Notes for reviewers #3848 (omit the directory download_url, for #3748) touches the same directory-listing code. The two changes are independent, so whichever lands second may need a small rebase. About 20 other tools (for example list_commits, list_releases, list_gists) also return a top-level array as structuredContent on the 2026-07-28 protocol, and object-only clients would reject those too. I kept this PR to get_file_contents, which is the reported failure. I can follow up with the same wrapping for the others if you want it.
Open Graph Description: Summary get_file_contents now returns directory listings as {"entries": [...]} instead of a bare top-level array, so structuredContent is always a JSON object. Clients that only accept ob...
X Description: Summary get_file_contents now returns directory listings as {"entries": [...]} instead of a bare top-level array, so structuredContent is always a JSON object. Clients that only a...
Opengraph URL: https://github.com/github/github-mcp-server/pull/3869
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:bd1788ea-1733-62d5-0ea1-0da7c97561d3 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A5CA:93BED:2AF15B:39D0D6:6B0616F5 |
| html-safe-nonce | 7e034c2007b5a557d05792afe69dc840bf2c605dc304090b9238cd68c2407d4e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUNBOjkzQkVEOjJBRjE1QjozOUQwRDY6NkIwNjE2RjUiLCJ2aXNpdG9yX2lkIjoiODkxNTkxNTA0MzgyOTU4NTY1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d06f6fa404a134a70b1ac9b72c2d3748615fc0d95c7489890a6df20d8fc446d8 |
| hovercard-subject-tag | pull_request:5343611635 |
| 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/3869/files |
| twitter:image | https://avatars.githubusercontent.com/u/43115768?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/43115768?s=400&v=4 |
| og:image:alt | Summary get_file_contents now returns directory listings as {"entries": [...]} instead of a bare top-level array, so structuredContent is always a JSON object. Clients that only accept ob... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| 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 | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| 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