Skip to main content
Glama

Git diff

git_diff
Read-only

Parses staged or worktree Git diffs into per-file hunks for code review, previews, or tests, with optional unified patch text via include_patch.

Instructions

Parsed git diff (staged or worktree): files + hunks (old_start/lines, new_start/lines, section). Patch text is opt-in via include_patch=true. Use when: you need per-file hunk info for review/preview or a test, not free text. Avoid when: you need a raw unified blob (use include_patch=true or diff_files) or a PR diff (provider tools). Output: files[] {old_path|null, new_path|null, action (added|modified|deleted|renamed), binary, hunks[] {old_start, old_lines, new_start, new_lines, section}}, counts{}, patch_bytes, patch/patch_truncated when include_patch=true.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "git_diff"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathsNoOptional workspace-relative paths to limit the diff.
reasonNoOptional why (max 400 chars), audit-logged.
stagedNotrue compares the index to HEAD (git diff --cached); false compares worktree to HEAD/index.
max_bytesNoPatch text budget when include_patch=true (default 65536).
context_linesNoUnified-diff context lines (default 3).
include_patchNotrue includes the unified diff text (truncated to max_bytes).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed11 schema fields changedv4.5.0
    • removedInput schema / properties / include_patch / anyOf
      Removed value: -[
      -  {
      -    "type": "boolean"
      -  },
      -  {
      -    "maximum": 1,
      -    "minimum": 0,
      -    "type": "integer"
      -  }
      -]
    • changedInput schema / properties / include_patch / description
      Previous value: -"1 includes the unified diff text (truncated to max_bytes)."New value: +"true includes the unified diff text (truncated to max_bytes)."
    • removedInput schema / properties / include_patch / maximum
      Removed value: -1
    • removedInput schema / properties / include_patch / minimum
      Removed value: -0
    • changedInput schema / properties / include_patch / type
      Previous value: -"integer"New value: +"boolean"
    • changedInput schema / properties / max_bytes / description
      Previous value: -"Patch text budget when include_patch=1 (default 65536)."New value: +"Patch text budget when include_patch=true (default 65536)."
    • removedInput schema / properties / staged / anyOf
      Removed value: -[
      -  {
      -    "type": "boolean"
      -  },
      -  {
      -    "maximum": 1,
      -    "minimum": 0,
      -    "type": "integer"
      -  }
      -]
    • changedInput schema / properties / staged / description
      Previous value: -"1 compares the index to HEAD (git diff --cached); 0 compares worktree to HEAD/index."New value: +"true compares the index to HEAD (git diff --cached); false compares worktree to HEAD/index."
    • removedInput schema / properties / staged / maximum
      Removed value: -1
    • removedInput schema / properties / staged / minimum
      Removed value: -0
    • changedInput schema / properties / staged / type
      Previous value: -"integer"New value: +"boolean"
  2. Addedv4.0.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description builds on that by disclosing that patch text is opt-in, that patch output is truncated to max_bytes with a patch_truncated signal, and what counts/fields accompany the result. It stops short of noting limits such as path-count caps or behavior on binary files, so it is strong but not exhaustive.

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 what the tool returns, then when/when-not, then output shape — a sensible order. The output enumeration is long but earns its place since no output schema exists; a few clauses (e.g. 'or a test') are slightly loose.

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

Completeness4/5

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

With no output schema and six optional parameters, the description carries the return-value burden well by spelling out files[], hunk fields, action enum values, counts, and patch fields. Error behavior and path-limit semantics are the only notable omissions for a read-only diff tool.

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?

Coverage is 100%, so the schema already documents each parameter; the description goes beyond it by explaining the causal relationship between include_patch and max_bytes truncation and by tying patch_bytes/patch_truncated to those inputs. The 'staged' explanation largely restates the schema, keeping this below a 5.

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 and resource ('Parsed git diff') plus scope ('staged or worktree') and enumerates the returned structure. It explicitly distinguishes itself from diff_files and provider PR tools, so an agent can separate it from siblings without opening a schema.

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

Usage Guidelines5/5

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

Provides an explicit 'Use when' clause (per-file hunk info for review/preview/test) and an explicit 'Avoid when' clause naming concrete alternatives (include_patch=true or diff_files for raw blobs, provider tools for PR diffs). The selection condition is fully specified.

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