Add a patch-safe file update tool for large files
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- github, go
- Bereich
- backend-api-design
Rechercherichtung
Beginne damit, die vorhandenen Tools create_or_update_file und push_files sowie ihre GitHub-Pfade zum Schreiben von Inhalten nachzuverfolgen. Definiere das vorgeschlagene patch-sichere Tool anhand der genannten Anforderungen an optimistische Nebenläufigkeitskontrolle, exakte Bearbeitung, Validierung und Fail-Closed-Verhalten und füge anschließend gezielte Tests hinzu, die diese Verhaltensweisen und die zurückgegebenen Commit-Metadaten abdecken.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Go
- Sterne
- 33.1k
- Forks
- 5k
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 25
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/github-mcp-server
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
github/github-mcp-server#3235 ·
-
enhancement
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
github/github-mcp-server#3042 · 2 Kommentare ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
github/github-mcp-server#3032 · 1 Reaktion ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
github/github-mcp-server#2803 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
github/github-mcp-server#2740 ·
Alle Issues in github/github-mcp-server
Ähnliche Issues
-
area/dev-productivity area/disaster-recovery area/ipcei kind/enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
kind/bug status/0-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
🤔 refinement needed
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
equinor/radix-operator#1979 ·