Skip to main content
Glama

merjax_apply_patch

Commit a patch to a branch without sending whole files — the way to change a few lines of a large file. patch is a unified diff as git diff prints it (one commit, message required) OR git format-patch mbox output (each patch becomes its own commit with the patch's own message and author, like git am; message is ignored). Applied server-side with git apply --cached against the branch head (created from base_branch if missing); blank context lines a transport stripped to empty lines, or trimmed off the end of the patch, are restored first (git still checks them against the file). expected_head_sha makes it compare-and-swap (all zeros = branch must not exist yet). Meets the same branch protection, rulesets and secret scan as a git push, and fires CI/webhooks like one. Patch limit 2 MiB. Requires 'repo' scope. Returns {branch, commit_sha, parent_sha, files_changed, files, commits, created} (+ blank_context_lines_restored / trimmed_blank_context_lines_restored when a repair was needed).

Input Schema

NameRequiredDescriptionDefault
repoYes
ownerYes
patchYesUnified diff (`git diff`, a/ b/ prefixes) or `git format-patch` mbox text. Max 2 MiB.
branchYesTarget branch (short name). Created if it does not exist.
messageNoCommit message. Required for a unified diff; ignored for mbox input (each patch carries its own).
base_branchNoBranch to fork from when `branch` does not exist yet (default: the repo's default branch).
expected_head_shaNoOptional compare-and-swap: the 40-hex sha you expect `branch` to point at. Refused if it moved. All zeros = the branch must not exist.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the annotations (readOnlyHint=false, destructiveHint=false) by disclosing application mechanics (git apply --cached against branch head), branch auto-creation from base_branch, blank-context-line repair, compare-and-swap semantics for expected_head_sha, branch protection/ruleset/secret-scan enforcement, CI/webhook firing, a 2 MiB limit, and required 'repo' scope.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core purpose and then packed with high-value detail; nearly every clause earns its place. It is a single dense paragraph with layered parentheticals that reward careful reading but make it slightly harder to scan than a structured list would.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite no output schema, the description enumerates the return fields ({branch, commit_sha, parent_sha, files_changed, files, commits, created} plus repair counters), and covers auth scope, size limits, enforcement, and format edge cases — everything an agent needs to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 71% schema coverage the schema already documents most params, but the description adds real meaning: the mbox-vs-unified-diff distinction and that message is ignored for mbox, and that all-zeros expected_head_sha means the branch must not exist. It does not restate owner/repo, but those need no elaboration.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (commit a patch) plus resource (branch) and immediately distinguishes itself from whole-file writes: 'without sending whole files — the way to change a few lines of a large file.' An agent can tell this apart from write_file or atomic_multi_file_commit without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives clear context for when this is appropriate ('change a few lines of a large file') and explains the two accepted input formats and when message is required vs ignored. It does not explicitly name the alternative sibling tools (write_file, atomic_multi_file_commit) that an agent should consider instead when replacing entire files.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources