RepoPatch
Provides write-scoped tools for GitHub repositories: listing allowed repos, creating non-default branches, applying unique-match text diffs/creates/deletes atomically in one commit, and creating or updating pull requests (draft by default).
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
RepoPatch (repopatch-mcp)
Least-privilege write-scoped GitHub MCP server (5 tools) for targeted diff commits on feature branches and draft PRs — no full-file rewrites.
Part of the kitepon GitHub MCP pair: RepoPeek (read-only, 5 tools) + RepoPatch (write-scoped diff commits & draft PRs, 5 tools — this repo). Split read and write into two small, auditable servers so AI agents get read access everywhere and write access only when editing.
Why RepoPatch?
Large-file reliability (no output truncation): Official GitHub MCP tools (
push_files,create_or_update_file) require the LLM to emit the entire file on every edit — hitting model output caps on large files or forcing multiple fragmented pushes. RepoPatch accepts targetedold_text -> new_textdiffs, verifies each edit matches uniquely (exactly once) on the server, and commits multiple edits, creations, and deletions atomically in one Git Data API commit.Blast-radius isolation: RepoPatch hard-refuses direct pushes to
main,master, and the repository's livedefault_branch, hard-codesforce: false, blocks secret paths, caps per-commit file count and size, and opens pull requests as draft by default.
Official GitHub MCP vs. RepoPeek + RepoPatch
Capability | Official GitHub MCP | RepoPeek + RepoPatch |
Tool surface | ~50+ tools in one server | 5 read (RepoPeek) + 5 write (RepoPatch) |
Read / write token split | Shared token | Strictly separated (read-only PAT vs. write-scoped PAT) |
Large-file edits | Full-file | Server-side diff patching ( |
Default-branch & force-push safety | Relies on prompt discipline / repo rules | Hard-refused in server ( |
Plain-text web connectors (Gemini, etc.) | Mixed | 100% plain |
How the pair fits together
flowchart LR
Client["AI Client (Gemini, Claude, Cursor, Codex)"]
Peek["RepoPeek (5 read tools)<br/>bare git · plain text"]
Patch["RepoPatch (5 write tools)<br/>branch · atomic diff · draft PR"]
GH["GitHub (repos / Git Data API)"]
Client -- "list / read / grep" --> Peek
Peek -- "read-only PAT or public clone" --> GH
Client -- "create_branch / patch_files / PR" --> Patch
Patch -- "write-scoped PAT (non-default only)" --> GHRelated MCP server: ChangeWarden
Tools (5 write-scoped)
Tool | Purpose |
| List repositories allowed by |
| Create a new non-default branch from a ref (default: repository |
| Atomically edit ( |
| Open a pull request ( |
| Update an existing pull request's title, body, or base branch |
Example tool call (patch_files)
{
"name": "patch_files",
"arguments": {
"repo": "myorg/myrepo",
"branch": "feat/fix-timeout",
"message": "Increase request timeout and add test",
"changes": [
{
"path": "src/client.ts",
"action": "edit",
"edits": [
{
"old_text": "const TIMEOUT_MS = 5000;",
"new_text": "const TIMEOUT_MS = 15000;"
}
]
},
{
"path": "src/client.test.ts",
"action": "create",
"content": "import assert from 'node:assert/strict';\nassert.ok(true);\n"
}
]
}
}Committed 2 files to myorg/myrepo@feat/fix-timeout
Commit: 4a106befc15fa50fbedb840ba6f3e179573a44a0
Message: Increase request timeout and add test
Changes:
- M src/client.ts (+1/-1 lines, 1 edit)
- A src/client.test.ts (+2 lines)
Compare: https://github.com/myorg/myrepo/compare/main...feat%2Ffix-timeoutFull specs: tool contract · architecture & data flow.
Quick start (Docker Compose)
git clone https://github.com/kitepon/repopatch-mcp.git && cd repopatch-mcp
TOKEN=$(openssl rand -base64 32) # Bearer token; save in your password manager
cat > docker-compose.override.yml <<EOF
services:
repopatch-mcp:
environment:
- ALLOWED_REPOS=myorg/myrepo
- GITHUB_TOKEN=github_pat_... # Fine-grained PAT: Contents (R/W) + Pull requests (R/W)
- REPOPATCH_TOKEN_SHA256=$(printf %s "$TOKEN" | sha256sum | cut -d' ' -f1)
- REPOPATCH_STORE_KEY=$(openssl rand -base64 32)
EOF
docker compose up -d --build
curl -s http://127.0.0.1:39231/health # {"status":"ok","service":"repopatch-mcp"}The server listens on 127.0.0.1:39231 and refuses to start without REPOPATCH_TOKEN_SHA256. Only the token's SHA-256 goes into config; clients send Authorization: Bearer $TOKEN. See docker-compose.override.yml.example for all options.
Without Docker (Node.js 20+)
npm ci && npm run build
export ALLOWED_REPOS=myorg/myrepo
export GITHUB_TOKEN=github_pat_...
export REPOPATCH_TOKEN_SHA256=$(printf %s "$TOKEN" | sha256sum | cut -d' ' -f1)
export REPOPATCH_STORE_KEY=$(openssl rand -base64 32)
npm start # http://0.0.0.0:39231/mcpConnect an MCP client
Static Bearer header (Cursor, Claude Code, Codex, generic Streamable HTTP clients)
{
"mcpServers": {
"repopatch": {
"url": "https://repopatch.example.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_MCP_TOKEN"
}
}
}
}Web connectors with OAuth 2.1 (Gemini, etc.)
Deploy RepoPatch behind HTTPS and set
REPOPATCH_PUBLIC_URL=https://<your-host>.Add a custom MCP connector with URL
https://<your-host>/mcp.The client registers via DCR + PKCE S256 and opens
/authorize(protected by Cloudflare Access when configured, or by the Bearer token form).RepoPatch advertises server-level MCP
instructionsand tool descriptions guiding clients to preferpatch_filesover GitHub MCP'spush_files/create_or_update_filefor repositories inALLOWED_REPOS.
Configuration
Variable | Default | Meaning |
| required | SHA-256 hex of the shared Bearer token (exits without it) |
| empty (refuse all) | Comma-separated |
| unset | Direct-mode fine-grained PAT (Contents: R/W, Pull requests: R/W) |
|
| GitHub REST API origin |
|
| Public origin advertised in OAuth metadata |
|
| HTTP port |
|
| Encrypted OAuth store ( |
| unset | Base64 of 32 bytes; encrypts the OAuth store when no auth module is used |
| empty | Extra comma-separated secret-file globs ( |
|
| Max files per |
|
| Max single-file size in bytes (512 KiB) |
|
| Max total commit payload in bytes (2 MiB) |
| unset | Cloudflare Access team domain (set together with |
| unset | Cloudflare Access application AUD |
| empty | Optional comma-separated e-mail allow-list |
| unset | Optional auth-mediation caller socket (zero-PAT container mode + wrapped store key) |
| unset | Auth-mediation wrap key name |
| empty | Comma-separated |
Security model
No default-branch writes:
patch_fileshard-refusesmain,master, and the repository's livedefault_branch;updateRefhard-codesforce: false.Atomic batch validation: every file is fetched, validated, and patched in memory before any write API call; any mismatch or violation aborts with zero writes.
Allowlist: empty
ALLOWED_REPOSrefuses all repositories.Secret-path protection:
.env,.env.*,*.pem,*.key,*secret*,id_rsa*,id_ed25519*,*.p12,*.pfx,credentials.json, plusREPOPATCH_SECRET_PATTERNSare refused forcreate,edit, anddelete.Authentication:
/mcprequiresAuthorization: Bearer(only SHA-256 stored); OAuth 2.1 tokens live in an AES-256-GCM encrypted store;/authorizesupports Cloudflare Access JWT (fail closed).
See SECURITY.md to report vulnerabilities.
Development
npm ci
npm run lint
npm run typecheck
npm run build
npm testSee CONTRIBUTING.md before opening a pull request.
Directory listings
License
MIT — built by kitepon.dev.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Edit your live web app by chatting: preview changes in a sandbox, then open a pull request.
Edit your live web app by chatting: preview changes in a sandbox, then open a pull request.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
AI agents propose database changes as reviewable requests — no direct write access.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables agents to autonomously resolve GitHub issues by editing code, running tests, and opening pull requests, while enforcing guardrails that protect critical files and systems.7Apache 2.0
- FlicenseNot gradedqualityCmaintenanceEnables AI coding agents to request bounded GitHub changes through a default-deny policy, independent human approval, one-time execution with a GitHub App credential, and verifiable receipts.1-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to run structured preflight checks and identity-scoped Git operations, committing, pushing and opening GitHub PRs with the correct Git name, email, SSH key and signature for each repository. Persistent changes require exact proposals, human approval by default and recoverable, idempotent apply.131 PyPIMIT
- AlicenseAqualityBmaintenanceEnables AI agents to perform exact-match, transactional multi-file edits with atomic writes, dry-run diffs, and self-correcting error diagnostics that reduce token usage.122 npm1MIT