Add a patch-safe file update tool for large files
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 48/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- github, go
研究方向
先追蹤現有的 create_or_update_file 和 push_files 工具及其 GitHub 內容寫入路徑。根據所述的樂觀並行、精確編輯、驗證和 fail-closed 要求定義提議的 patch-safe 工具,然後加入聚焦的測試,涵蓋這些行為以及回傳的提交中繼資料。
由索引模型根據 Issue 內容生成。
描述
Problem
create_or_update_file and push_files require the MCP client/model to send the complete replacement file content. For large files this can exceed host/request limits before the GitHub API receives the intended bytes.
A real private-repository workflow hit this with a ~303 KB changelog: a one-entry append required resending the entire file, the MCP request was truncated upstream of GitHub, and the resulting commit contained only ~70 KB. The bad PR was detected and closed, but a local Git client was required to recover the exact patch.
Proposed capability
Add a narrowly scoped patch-safe update tool, e.g. apply_file_patch or create_commit_from_patch, that fetches the current file server-side and applies a bounded exact patch without requiring the MCP client to transmit the entire replacement file.
A conservative initial contract could use exact text replacements rather than fuzzy patching:
owner,repo,branch,pathexpected_head_shaexpected_blob_sha- ordered edits containing exact
old_textandnew_text - each edit must match exactly once (or an explicitly supplied exact occurrence count)
commit_message
Required behavior:
- Read current branch/head and fail if
expected_head_shadiffers. - Fetch the current blob/file server-side and fail if
expected_blob_shadiffers. - Apply edits exactly; no fuzzy offsets or best-effort matching.
- Preserve file mode/path and reject binary/oversized/ambiguous inputs for the initial implementation.
- Commit only after all edits and validations pass.
- Return before/after blob SHA, commit SHA, tree SHA, changed path, and size.
- Never force-update a ref; concurrent branch movement must fail closed.
A later version could support a bounded unified-diff parser and atomic multi-file commits through the Git database APIs.
Why this belongs in the server
The server already has the authenticated GitHub client and can fetch the full current blob directly. Keeping the full file server-side avoids model/context/request amplification and materially reduces the risk of truncation while retaining optimistic concurrency checks.
Scope / non-goals
- No arbitrary shell or local Git execution.
- No fuzzy patch application.
- No force push.
- No bypass of repository permissions or branch protections.
- Keep the tool outside read-only mode and subject to the same OAuth/repository scope filtering as existing content-write tools.
I can prepare a focused PR with tests if this shape is acceptable.
- 主要語言
- Go
- 星號
- 33.1k
- 分支
- 5k
- 平均合併
- 2 天 1 小時
- 30 天內合併 PR
- 25
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/github-mcp-server 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
github/github-mcp-server#3235 ·
-
enhancement
難度 1/5 1 小時以內 新手友好度 88/100
github/github-mcp-server#3042 · 2 則留言 ·
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
github/github-mcp-server#3032 · 1 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 74/100
github/github-mcp-server#2803 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
github/github-mcp-server#2740 ·
查看 github/github-mcp-server 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 65/100
-
bug group: validation priority: low
難度 2/5 1-3 小時 新手友好度 75/100
codecheckers/chekhov#51 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 75/100