Skip to main content
Glama

Diff

diff
Read-onlyIdempotent

Compare two text files and produce a unified line-by-line comparison from a to b to identify changes between files on disk.

Instructions

Compare two text files and return a unified diff from a to b. Use when you need line differences between two files on disk. Do not use it to find text across files; use search_text instead. To preview your own pending change, use the dryRun option of the write tools. Binary and non-UTF-8 files fail. A file over the size limit fails with TOO_LARGE. So does a diff not done within 1 s, or a full diff queue; retry once, then read matching line ranges. Returns ---/+++ headers (basenames) and @@ hunks; identical files give headers only.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "a": "<a>",
      "b": "<b>"
    },
    "name": "diff"
  }
}

Input Schema

NameRequiredDescriptionDefault
aYesOriginal file; its lines are the - side
bYesChanged file; its lines are the + side
contextNoUnchanged lines shown around each hunk; output size only

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.20.0
    • changedInput schema / properties / a / description
      Previous value: -"First file to compare"New value: +"Original file; its lines are the - side"
    • changedInput schema / properties / b / description
      Previous value: -"Second file to compare"New value: +"Changed file; its lines are the + side"
    • changedInput schema / properties / context / description
      Previous value: -"Number of context lines surrounding each change (default: 3)"New value: +"Unchanged lines shown around each hunk; output size only"
  2. Changed1 schema field changedv2.4.1
    • addedInput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
  3. Addedv2.0.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive, closed-world), yet the description adds substantial operational context: binary/non-UTF-8 inputs fail, TOO_LARGE on size limit, a 1 s timeout and full-queue failures, a retry-once-then-fallback policy, and the exact return shape.

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

Conciseness5/5

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

Front-loaded with purpose, then tightly sequenced: when to use, when not to, alternative routes, failure modes, retry policy, return format. Dense but every clause carries actionable information with no filler.

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, and the description compensates by describing the return value ("---/+++ headers (basenames) and @@ hunks; identical files give headers only"). Combined with error modes and retry guidance, nothing an agent needs to call it correctly is missing.

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

Parameters3/5

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

Schema coverage is 100%, so a and b and context are already documented (including the - side/+ side semantics and what context controls). The description's "from a to b" reinforces direction but adds no format or constraint detail beyond the schema, so the baseline 3 applies.

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?

The opening sentence gives a specific verb and resource ("Compare two text files and return a unified diff") plus directionality ("from a to b"), which is enough for an agent to distinguish it from siblings like read or search_text 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?

Explicitly states when to use it ("line differences between two files on disk"), names a sibling to avoid it for ("Do not use it to find text across files; use `search_text` instead"), and routes two adjacent cases elsewhere: dryRun of write tools for pending changes, and `read` line ranges after a failed diff.

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