Title: fix: resolve annotated tags to their commit in get_file_contents by burrows99 · Pull Request #3936 · github/github-mcp-server · GitHub
Open Graph Title: fix: resolve annotated tags to their commit in get_file_contents by burrows99 · Pull Request #3936 · github/github-mcp-server
X Title: fix: resolve annotated tags to their commit in get_file_contents by burrows99 · Pull Request #3936 · github/github-mcp-server
Description: Summary get_file_contents now resolves an annotated tag to the commit it points at, so the repo://.../sha/{sha}/contents/... URI it returns can be read back. Before, the URI named the tag object and reading it failed with 404. Why An annotated tag ref (refs/tags/v1.0.0 in this repo) points at a tag object, not a commit. resolveGitReference returned reference.Object.SHA as is, so for annotated tags it returned the tag object's SHA: the embedded resource / resource link URI became repo://github/github-mcp-server/sha/c7fc888…/contents/go.mod, and reading it through the server's own repository_content_commit template fails with 404 Not Found (raw content does not accept tag object SHAs). For files of 1 MB or more the tool returns no content, only a resource link (and a download URL), and that link cannot be read either; the "resolved refs" in the path-suggestion message report the tag object SHA as if it were the commit. Branches and lightweight tags were fine because their ref already points at a commit. No upstream issue is associated with this fix. Reproduced on main at 9a72d8d. flowchart TD A[get_file_contents with ref v1.0.0] --> B{Annotated tag ref} B -->|Before| C[URI names the tag object and reads back 404] B -->|After| D[URI names the tagged commit and reads back the file] Loading What changed pkg/github/repositories_helper.go: after the ref is resolved, peel annotated tags with Git.GetTag until the object is not a tag, and return that SHA. One extra API call, only for annotated tags. pkg/github/repositories_test.go: Test_resolveGitReference case "annotated tag resolves to the tagged commit" (ref returns a type: tag object, tag API returns the commit). Narrated recording in the MCP Inspector, before then after (sound on). Server run with --read-only --toolsets=repos,security_advisories: evidence.mp4 Edge cases and unchanged behaviour checked (in the running server through the Inspector, as shown in the video): ref: refs/tags/v1.0.0 (fully qualified annotated tag) -> sha/569a48d… (the tagged commit) lightweight tag cli/cli v2.60.0 -> sha/44ee177…, the same commit as before branch main -> sha/9a72d8d… (branch head), unchanged unit test: branch, lightweight tag, heads/, tags/, PR ref and SHA cases in Test_resolveGitReference unchanged and passing MCP impact No tool or API changes Tool schema or behavior changed get_file_contents input/output schema is unchanged; for annotated tags the returned resource URI and resolved SHA now name the commit. New tool added Prompts tested (tool changes only) "Show me go.mod from github/github-mcp-server at tag v1.0.0" (then read the returned resource URI) Security / limits No security or limits impact 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 gofmt -s -l pkg/github clean; golangci-lint v2.14.0 (the pinned version) on ./pkg/github/...: 0 issues. Tested locally with ./script/test go test ./pkg/github/ passes. The new case fails on main (expected: "commit-sha", actual: "tag-object-sha") and passes with the fix. I did not run the whole repository suite. Docs Not needed Skills Updated relevant skills or confirmed no bundled skill applies No bundled skill describes ref resolution. AI assistance (Claude Code) was used to find the bug, write the fix and test, and record the video. 🤖 Generated with Claude Code
Open Graph Description: Summary get_file_contents now resolves an annotated tag to the commit it points at, so the repo://.../sha/{sha}/contents/... URI it returns can be read back. Before, the URI named the tag object an...
X Description: Summary get_file_contents now resolves an annotated tag to the commit it points at, so the repo://.../sha/{sha}/contents/... URI it returns can be read back. Before, the URI named the tag object an...
Opengraph URL: https://github.com/github/github-mcp-server/pull/3936
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
| 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:16abcb96-da0d-1bb1-4c27-261236c75ca1 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C6F4:5F360:37EE2E:4953FE:6B061803 |
| html-safe-nonce | 0e6128787d849d5f51e443566b4534647f837fe7bb8f7ab44a271051182ad01f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkY0OjVGMzYwOjM3RUUyRTo0OTUzRkU6NkIwNjE4MDMiLCJ2aXNpdG9yX2lkIjoiMjc2NzAzODIwNTU3MTUwNDEzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 403e7034fe5b22b5688a3bd897ee689852a98c014af965a0f26ab023f92c0aad |
| hovercard-subject-tag | pull_request:5466158152 |
| 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/3936/files |
| twitter:image | https://avatars.githubusercontent.com/u/69508267?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/69508267?s=400&v=4 |
| og:image:alt | Summary get_file_contents now resolves an annotated tag to the commit it points at, so the repo://.../sha/{sha}/contents/... URI it returns can be read back. Before, the URI named the tag object an... |
| 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