feat: add file mode (executable bit) support to push_files#2579
Open
why-pengo wants to merge 1 commit into
Open
feat: add file mode (executable bit) support to push_files#2579why-pengo wants to merge 1 commit into
why-pengo wants to merge 1 commit into
Conversation
Adds an optional `mode` field to each entry of the push_files tool, threaded into the Git Data API CreateTree call. Allowed values are the modes the API itself accepts: 100644 (regular file, the default when omitted), 100755 (executable), 120000 (symlink), 040000 (subtree), and 160000 (submodule). Unknown values are rejected with a clear error so agentic callers can correct themselves instead of silently writing the wrong mode. Before this change there was no in-band way for an MCP client to publish an executable file. Two failure modes were observed in practice: agents hallucinating in PR bodies that they had pushed mode 100755 when the blob actually landed as 100644, and agents inventing a second "fix permissions" file outside the requested scope. Exposing mode closes both gaps without breaking existing callers, which continue to get 100644 when the field is omitted. create_or_update_file still cannot set the executable bit because the Contents API surfaces a fixed mode; its description now points callers at push_files with a single-entry files array for that case. Closes github#2578 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is my first contribution to this repo. I used Claude Code with Opus 4.7. I reviewed the code and tried to make sure I followed contributing.md.
Summary
modefield to each entry inpush_files, threaded into the Git Data APICreateTreecall. Accepted values are the ones the API itself accepts:100644(regular file, the default when omitted),100755(executable),120000(symlink),040000(subtree),160000(submodule). Unknown values are rejected with a clear error.create_or_update_file's description to point callers atpush_files(with a single-entryfilesarray) when they need to land an executable file, since the Contents API can't set the mode.modecontinue to write100644.Motivation
Agentic harnesses use this server to publish files into a repo on behalf of an LLM. When the produced artifact is a shell script, build helper, or other executable, the file needs the executable bit set — otherwise reviewers either have to
chmod +xafter merge or land a broken artifact. Today there is no in-band way to do this through the server.In practice we observed two failure modes:
100755when the blob in fact landed as100644.scripts/permissions.shthat runschmod +xlater).Exposing
modeas a first-class field closes both.create_or_update_fileis not changed in this PR because the Contents API has nomodeparameter — that's a GitHub API constraint, not a server one. The description now points topush_filesfor that case.Test plan
UPDATE_TOOLSNAPS=true go test ./...— all packages green; toolsnaps forpush_filesandcreate_or_update_fileregenerated.script/lint(golangci-lint v2) — 0 issues.script/generate-docs—README.mdregenerated to reflect the newfiles[].modefield description.Test_PushFiles:100755and another defaults to100644(asserts the request body sent to the Git Data API contains the correct per-entry mode);0755) with a clear error;modevalue.Closes #2578