Skip to main content
Glama
igordev96
by igordev96

Diff one file between two refs

diff_file
Read-only

Show the unified diff of one file between two Git refs, scoped by path, without a working tree. Use it to review changes for a specific file across branches or commits.

Instructions

The unified diff of one file between two refs — git diff -M <from> <to> -- <path> — without a working tree. The caller names the file and the diff is scoped before git runs, so nothing is found by parsing a patch header. context sets the lines shown around each hunk (default 3, 0-10) and max_bytes caps the diff. Scoping by path narrows rename detection, so a renamed file is read as an added (or deleted) file. The two refs are a raw two-dot diff: pass a merge_base printed by compare as from for the branch view of one file. A file that is unchanged between the refs yields no diff, and one absent from both is reported as not found. A binary file is refused: git has only a "Binary files … differ" line for it, which is not a patch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesThe ref to diff to, e.g. 'fix/PROJ-7608'.
fromYesThe ref to diff from, e.g. 'develop' or a commit sha.
pathYesFile path from the repository root, e.g. 'src/index.tsx'.
contextNoLines of context on each side of a hunk (default 3, at most 10). Use 0 for the fewest lines.
projectNoGitLab project path, e.g. 'group/subgroup/repo'. Defaults to GITLAB_DEFAULT_PROJECT.
max_bytesNoByte cap for the patch (default 200000). A cut patch is marked in the result.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.10.1

TDQS

A4.6/5.0
Behavior5/5

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

With annotations only covering readOnly/openWorld, the description adds substantial behavioral detail: path scoping is applied before git runs, rename detection is narrowed so renames read as add/delete, unchanged files yield no diff, absent files are reported not found, and binary files are refused because git emits no patch. These are exactly the edge cases an agent must anticipate.

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 first sentence gives purpose and command form, and the remaining sentences each carry an edge case rather than filler. It is dense but slightly long, with some detail (e.g. restating context default) that the schema already supplies.

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?

No output schema exists, yet the description explains the meaningful result states (patch, empty diff, not-found, binary refusal) and the safety profile is covered by annotations. An agent has everything needed to call it correctly across the 6-param surface.

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?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning to `from`/`to` (raw two-dot diff; merge_base from `compare`) and to how `context` and `max_bytes` shape the patch. The context default/range restates the schema, but the ref semantics elevate it above the baseline.

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 precise verb+resource ('The unified diff of one file between two refs') plus the exact underlying command, and distinguishes the scope from siblings like compare and get_file. An agent can tell it produces a patch for a single named path rather than a ref comparison or file read.

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 operative guidance: pass a `merge_base` printed by `compare` as `from` for a per-file branch view, and explains the consequences of path scoping (narrowed rename detection). It references the `compare` sibling but does not explicitly say when to prefer this over `compare`/`get_file` for other tasks.

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