Title: Symlink corruption: `get_file_contents` follows symlinks but `create_or_update_file` does not · Issue #2997 · github/github-mcp-server · GitHub
Open Graph Title: Symlink corruption: `get_file_contents` follows symlinks but `create_or_update_file` does not · Issue #2997 · github/github-mcp-server
X Title: Symlink corruption: `get_file_contents` follows symlinks but `create_or_update_file` does not · Issue #2997 · github/github-mcp-server
Description: Describe the bug While using Claude Fable 5, I asked the agent to edit a text file that was a symlink to another file. get_file_contents returned the target file's content and a SHA without indicating that the requested path was a symlin...
Open Graph Description: Describe the bug While using Claude Fable 5, I asked the agent to edit a text file that was a symlink to another file. get_file_contents returned the target file's content and a SHA without indicat...
X Description: Describe the bug While using Claude Fable 5, I asked the agent to edit a text file that was a symlink to another file. get_file_contents returned the target file's content and a SHA without ind...
Opengraph URL: https://github.com/github/github-mcp-server/issues/2997
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Symlink corruption: `get_file_contents` follows symlinks but `create_or_update_file` does not","articleBody":"### Describe the bug\n\nWhile using Claude Fable 5, I asked the agent to edit a text file that was a symlink to another file.\n\n`get_file_contents` returned the target file's content and a SHA without indicating that the requested path was a symlink. Claude then passed the edited content and returned SHA to `create_or_update_file` for the same path.\n\nThe write succeeded, but updated the symlink blob rather than the target file, while preserving Git mode `120000`. In the original incident, approximately 15 KB of Markdown became the symlink target and the resulting commit could not be checked out.\n\nThis does not happen in a normal filesystem-based editing workflow, where reads and writes both follow the symlink. It is specific to workflows that use GitHub MCP or the GitHub API for the write, including cases where an agent reads from a local checkout and uses MCP only to commit the update.\n\n### Affected version\n\nThe command that works with the current image is:\n\n```console\n$ docker run -i --rm ghcr.io/github/github-mcp-server:latest --version\nGitHub MCP Server\nVersion: v1.8.0\nCommit: ca8ab52dcc45b86fae190398178fd22edb7b1362\nBuild Date: 2026-07-30T13:28:24Z\n```\n\n### Steps to reproduce the behavior\n\n1. Create and push a regular file and a symlink to it:\n\n ```bash\n head -c 4097 /dev/zero | tr '\\0' A > file1.txt\n ln -s file1.txt file2.txt\n git add file1.txt file2.txt\n git commit -m \"Add symlink\"\n git push\n ```\n\n2. Call `get_file_contents` for `file2.txt`. It returns the 4,097-byte contents of `file1.txt`, a file SHA, and no indication that the requested path is a symlink.\n\n3. Call `create_or_update_file` for `file2.txt` with the returned SHA and content.\n\n4. Inspect the result:\n\n ```bash\n git ls-tree HEAD file2.txt\n git cat-file -p HEAD:file2.txt\n ```\n\n The mode remains `120000`, but the blob contains the submitted file content instead of `file1.txt`.\n\n5. Clone or check out the resulting commit. Checkout fails with `File name too long`.\n\n### Expected vs actual behavior\n\nExpected: before writing, the agent is told that GitHub API writes operate on the exact Git path and do not follow symlinks like filesystem writes. This should still allow intentional symlink updates: to edit the linked file, write to its target path; to change the symlink, write the new target path.\n\nActual: the read follows the symlink, while the write updates the symlink blob. The different semantics are not exposed to the agent, and SHA validation accepts the value returned by the read.\n\nA possible fix is to document the exact-path behavior in both the server-level MCP `instructions` and the `tools/list` descriptions of mutating file tools. This informs the agent before any file tool is called, including when it reads the content locally and uses MCP only for the write.\n\nI would be happy to submit a pull request once the maintainers confirm the preferred wording and scope.\n\n### Logs\n\nThe following output was captured using the official v1.8.0 Docker image. Repository identifiers, SHAs, URLs, and most of the 4,097-byte content have been redacted.\n\n`get_file_contents` followed `file2.txt` and returned the 4,097-byte contents of `file1.txt` as a text resource:\n\n```json\n{\"jsonrpc\":\"2.0\",\"id\":2,\"result\":{\"content\":[\n {\"type\":\"text\",\"text\":\"successfully downloaded text file (SHA: \u003credacted>)\"},\n {\"type\":\"resource\",\"resource\":{\"uri\":\"repo://\u003credacted>/contents/file2.txt\",\"mimeType\":\"text/plain; charset=utf-8\",\"text\":\"AAAA... \u003c4,093 bytes redacted>\"}}\n]}}\n```\n\n`create_or_update_file` accepted the same content and returned success with `size: 4097`:\n\n```json\n{\"jsonrpc\":\"2.0\",\"id\":3,\"result\":{\"content\":[{\"type\":\"text\",\"text\":\"{\\\"content\\\":{\\\"name\\\":\\\"file2.txt\\\",\\\"path\\\":\\\"file2.txt\\\",\\\"sha\\\":\\\"\u003credacted>\\\",\\\"size\\\":4097,\\\"html_url\\\":\\\"\u003credacted>\\\"},\\\"commit\\\":{\\\"sha\\\":\\\"\u003credacted>\\\",\\\"message\\\":\\\"Reproduce symlink write behavior\\\",\\\"html_url\\\":\\\"\u003credacted>\\\"}}\"}]}}\n```\n\nAfter the write, the Contents API reported the path as a 4,097-byte symlink, and the Git tree still had mode `120000`:\n\n```json\n{\"type\":\"symlink\",\"size\":4097,\"sha\":\"\u003credacted>\",\"target\":\"AAAA... \u003c4,093 bytes redacted>\"}\n{\"path\":\"file2.txt\",\"mode\":\"120000\",\"type\":\"blob\",\"sha\":\"\u003credacted>\",\"size\":4097}\n```\n\nThis cannot happen on an ordinary file system. The MCP call itself produced no error. Cloning the resulting branch fetched the commit, then failed during checkout:\n\n```text\nCloning into '\u003credacted>'...\nerror: unable to create symlink file2.txt: File name too long\nfatal: unable to checkout working tree\nwarning: Clone succeeded, but checkout failed.\n```\n","author":{"url":"https://github.com/kujiy","@type":"Person","name":"kujiy"},"datePublished":"2026-08-03T02:27:16Z","url":"https://github.com/github/github-mcp-server/issues/2997"}
| 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:7eadb7b8-d330-a20a-15f7-3f9a39bdb968 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9000:33943:1F08103:290EF7A:6B0691D6 |
| html-safe-nonce | 9d17be2bd52a447f4190710540e720b1645317048bbe6a272b343d8f871ed9f8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDAwOjMzOTQzOjFGMDgxMDM6MjkwRUY3QTo2QjA2OTFENiIsInZpc2l0b3JfaWQiOiIzOTQ5MDI3OTk3Mjk4MTAyNzQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 057fb18872a44f1c1729a066fddc071fd0648daa46c5822d332709fa4839b45e |
| hovercard-subject-tag | issue:5045729909 |
| 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/2997/issue_layout |
| twitter:image | https://opengraph.githubassets.com/36b0d71f7b3e45f9deff0b9e914a57fbbedcf1d167a3e2fe010d37f6d578e7db/github/github-mcp-server/issues/2997 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/36b0d71f7b3e45f9deff0b9e914a57fbbedcf1d167a3e2fe010d37f6d578e7db/github/github-mcp-server/issues/2997 |
| og:image:alt | Describe the bug While using Claude Fable 5, I asked the agent to edit a text file that was a symlink to another file. get_file_contents returned the target file's content and a SHA without indicat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kujiy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a |
| 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 | 6d3909414814ff86ce7da4c51a0f4918a13fb41b |
| 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