Skip to main content
Glama

diff_files

Compare two JSON, YAML, TOML, .env, INI, or CSV files to find path-level semantic changes while ignoring key order and formatting.

Instructions

Semantic diff of two files: what changed, by path, ignoring key order and formatting.

Reads JSON, JSONC, YAML (safe subset, multi-document supported), TOML, .env and INI files (format is detected from the file name; a and b may be different formats). Returns {identical, summary{added, removed, changed, type_changed, moved, total}, changes[], warnings[]}. Each change has an op ('added', 'removed', 'changed', 'type_changed', 'moved'), a JSONPath-like path such as $.servers[id=3].port, and old/new values (truncated to max_value_chars). A value going from 1 to "1" is type_changed; null versus a missing key is reported as a key that was added or removed, never as a change.

Args: a, b: file paths (relative paths resolve against the first --dir). format: json, jsonc, yaml, toml, env, ini, csv, or auto (from the extension). array_match: how list items are paired. 'auto' (default) matches lists of objects by the first of array_keys that is present and unique in every item, and falls back to position; 'index' pairs by position; 'key' is like auto but warns when no key works; 'set' ignores order and duplicates-aware compares items by value (good for tag lists). Items matched by key that changed position are reported as 'moved'. array_keys: candidate key fields, default ["id", "name", "key"]. ignore: patterns of paths to skip. '' matches any text, including dots and brackets: '$.metadata.updatedAt', '$.items[].etag', '.timestamp'. Must start with '$' or ''. abs_tol, rel_tol: numbers within these tolerances are treated as equal (0.1+0.2 vs 0.3 needs abs_tol=1e-9). 1 and 1.0 are always equal; big integers stay exact. strip_comments: remove // and /* */ comments and trailing commas before parsing JSON (always on for .jsonc). encoding: 'auto' honours UTF-8/16/32 BOMs, otherwise UTF-8; or give e.g. 'cp1252'. max_changes: cap on listed changes; summary counts are always complete.

Input Schema

NameRequiredDescriptionDefault
aYes
bYes
formatNoauto
ignoreNo
abs_tolNo
rel_tolNo
encodingNoauto
array_keysNo
array_matchNoauto
max_changesNo
strip_commentsNo
max_value_charsNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations supplied, the description carries the burden and does well: it discloses format detection, safe YAML parsing, output structure, change operation types, null-versus-missing-key semantics, tolerance behavior, truncation, and that summary counts remain complete under max_changes. It does not explicitly state that the tool is read-only or describe error behavior.

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?

The description is front-loaded with purpose and return shape, then uses a structured Args list, which suits a complex 12-parameter tool. It is dense but mostly earns its space, though some return-shape detail is redundant because an output schema exists.

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?

For a complex file-diffing tool with 12 parameters and an existing output schema, the description is nearly complete: parameters and core behavior are well covered. Minor gaps remain around explicit read-only/non-destructive status, error handling, and the reference to a '--dir' option that may not map cleanly to an MCP context.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate, and it explains all 12 parameters meaningfully. It documents path resolution, format options, array matching modes, key candidates, ignore-pattern syntax and constraints, tolerance semantics with examples, encoding behavior, comment stripping, and the caps on changes and value length.

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

Purpose4/5

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

The description states a specific verb and resource: semantic diff of two files, with supported structured formats and a clear focus on semantic rather than textual comparison. It does not explicitly distinguish itself from sibling tools such as diff_text or csv_diff, and the prose format list omits CSV though the format argument includes it.

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

Usage Guidelines3/5

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

Usage is implied by 'semantic diff' and the supported structured formats, and the array_match options include guidance on when each matching mode is appropriate. However, there is no explicit when-to-use guidance versus sibling tools like diff_text, csv_diff, or inspect_file, nor are there stated exclusions.

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