# Text Diff Engine MCP

> Text Diff Engine compares text versions character-by-character and line-by-line to generate absolute patch files. It bypasses LLM summarization, giving you deterministic diff outputs for code patches, legal contracts, or structured data. Stop guessing what changed; see the exact additions (+), deletions (-), and unchanged lines between any two strings.

## Overview
- **Category:** productivity
- **Price:** Free
- **Tags:** diffing, text-comparison, patch-generation, code-review, version-control, deterministic-analysis

## Description

When you're dealing with version control, relying on a large language model to summarize what changed? Nah. Those things just give you a narrative; they don't show you the actual mechanics. You need to know *how* it flipped—not just that it did. This Text Diff Engine fixes that mess. It ditches the guesswork and gives you deterministic, structured patches for any text input, whether it’s code or some dense legal contract.

The `compare_texts` tool performs an exact line-by-line diff comparison between two strings, spitting out a structured report of additions, deletions, and context lines that tells you exactly what's up. It takes the original version and the modified version, runs the comparison, and returns a detailed breakdown: everything added gets marked with `+`, anything removed shows up with `-`, and context lines—the bits that didn’t move—are kept intact.

You can use this engine to generate structured line-by-line diffs by passing two text strings (original and modified) to get a report detailing every change. It doesn't just tell you *if* something changed; it shows the full record, which is crucial for reliable code review and compliance checks on legal documents. Because of this granular control, **you can pinpoint specific character-level edits**, making it perfect for tracking minor syntax alterations in configuration files or source code where a single comma matters.

Beyond simple line comparison, you'll get the ability to create unified diff patches. This means the output is standardized in formats like those used by Git, allowing you to apply these changes directly as patch versions of documents. You feed it two texts, and you walk away with a formal set of instructions for applying the difference.

This engine’s purpose is simple: it guarantees determinism. It gives you an absolute record when your workflow demands precision—whether you're migrating structured data like JSON or XML, or just need to prove exactly what got scrubbed out of a policy document. You don't get vague summaries; **you get the precise mechanics**. Use this tool when "it looks right" isn't good enough; you gotta see the exact additions and deletions.

## Tools

### compare_texts
Performs an exact line-by-line diff comparison between two strings, returning a structured report of additions, deletions, and context lines.

## Prompt Examples

**Prompt:** 
```
Generate a unified diff between `v1-config.json` and `v2-config.json`.
```

**Response:** 
```
✅ **Diff Generated:**
```diff
-  "timeout": 30
+  "timeout": 60
```
```

**Prompt:** 
```
Show me the word-level differences between these two legal contract paragraphs.
```

**Response:** 
```
✅ **Word Diff:** Detected 4 removed words and 2 added clauses accurately.
```

**Prompt:** 
```
Compare the original HTML file with the minified version to ensure no attribute loss.
```

**Response:** 
```
✅ **Comparison Complete:** The files are structurally identical, differing only in 1,204 whitespace removals.
```

## Capabilities

### Generate Structured Line-by-Line Diff
Pass two text strings (original and modified) to get a structured report detailing every addition, deletion, and context line.

### Identify Exact Character Changes
The tool pinpoints specific character-level edits, useful when tracking minor syntax alterations in configuration files or source code.

### Create Unified Diff Patches
Output standardized diff formats (like those used in Git) that can be directly applied to patch versions of documents.

## Use Cases

### Reviewing a JSON Schema Update
A DevOps engineer updates a service's environment configuration from v1 to v2. Instead of pasting the files and asking an AI agent what changed, they run `compare_texts`. The tool immediately isolates that the 'database_port' was changed from 5432 to 6000, and no other critical keys were modified. This prevents deployment errors.

### Tracking Legal Clause Revisions
A legal analyst receives a revised non-disclosure agreement (NDA). They use `compare_texts` on the original and new versions. The tool highlights exactly where 'Indemnification' was added, and which specific paragraph defining 'Confidential Information' was deleted, making compliance review straightforward.

### Comparing HTML Minified vs. Original Code
A frontend developer needs to confirm that minifying an HTML file didn't strip any necessary attributes or unique class names. Running `compare_texts` confirms the files are structurally identical, showing only whitespace differences—a clean pass.

### Patching a Multi-File Codebase
A software team rolls out an update that affects three interconnected source code files. Instead of manually tracking changes across Git commits, they use `compare_texts` on the old and new versions of each file to generate clean, unified diffs for immediate patching.

## Benefits

- **Deterministic Output:** Instead of getting a narrative summary, `compare_texts` gives you structured diffs. This means the output is purely technical data you can trust—it’s reliable, repeatable truth.
- **Code Integrity:** When reviewing JSON or config files, you need to know if an attribute was dropped or changed its value. The engine flags these structural shifts instantly, which simple LLM prompts often miss.
- **Legal Precision:** For contracts and regulatory documents, vague summaries are useless. You use `compare_texts` to guarantee that every single word added or removed is visible for compliance checks.
- **Version Control Compliance:** It functions as a dedicated diff library, allowing you to compare file versions (like HTML minification) to confirm structural identity despite whitespace changes.
- **Bypasses AI Guesswork:** You're not relying on an agent's best guess. The engine uses the `diff` library directly, providing raw, verifiable data that is 100% accurate.

## How It Works

The bottom line is: it gives you absolute truth about text changes, regardless of how complex or subtle they are.

1. You send the tool two text inputs: the 'Original' content and the 'Modified' content.
2. The engine processes both strings using the internal diff library, mapping every character divergence.
3. It returns a structured output showing additions (`+`), deletions (`-`), and unchanged lines in clear patch format.

## Frequently Asked Questions

**How does Text Diff Engine compare text versions?**
It uses a deterministic diff library, not an LLM summary. You provide two strings (original and modified), and the engine generates structured patches showing additions (+) and deletions (-).

**Is the output from compare_texts useful for code review?**
Absolutely. The unified diff format it provides is standard in version control systems, making it immediately usable by engineers who need to see exactly what was added or changed.

**Can I use Text Diff Engine for comparing JSON files?**
Yes. While you pass the content as text strings, it handles structural differences in data formats like JSON and XML reliably, ensuring attribute loss is flagged.

**Does Text Diff Engine handle whitespace changes?**
Yes. It's designed to detect both functional changes and cosmetic ones. It can report if only whitespace was removed or added, which is critical for minification checks.

**What is the character limit when running compare_texts?**
The tool handles large texts efficiently, supporting inputs of significant length without hitting memory limits. It's built to manage full documents or long codebases, so don't worry about standard document size constraints.

**Does the output from Text Diff Engine provide a structured format?**
Yes, the output is highly structured for easy parsing. Instead of just plain text, it returns distinct sections detailing additions, deletions, and unchanged lines in a format your agent can consume directly.

**What happens if I pass non-text data to compare_texts?**
The tool validates inputs before processing. If the original or modified versions aren't valid strings, it returns a specific error message and status code, allowing your agent to handle the failure gracefully.

**Are there any rate limits I should know about when using Text Diff Engine?**
Rate limits are managed by Vinkius Marketplace. For standard usage through your AI client connection, you'll operate under established service quotas. Check the server dashboard for real-time usage metrics.

**Can it diff code?**
Yes, it is excellent for comparing code files.

**Does it output in standard patch format?**
Yes, it outputs unified diff formatting.

**Can it diff large documents?**
Absolutely, it runs instantly on large text payloads.