← Package Index
mcp-diff mcp
v1.0.0 · MCP Tool · developer · registry.pascalai.org
Apply unified diffs to files and parse diff structure. Fuzzy hunk matching tolerates +/-20 line offset. Pure RTL, no external dependencies.
diff patch unified-diff file-patch code-diff apply-patch
Input Parameters
Parameter Type Description
operationrequired
string
apply: read filePath, apply unified diff, write result to outputPath (default: overwrite source). parse: return hunk structure as JSON. One of: apply, parse.
filePathoptional
string
Path to the source file to patch. Required for apply.
diffoptional
string
Unified diff string (--- +++ @@ headers). Required for apply and parse.
outputPathoptional
string
Output file path for apply. Omit to overwrite the source file in place.
Output Fields
Field Type Description
output
string
Path of the written file (apply only)
lines_before
integer
lines_after
integer
size_bytes
integer
hunk_count
integer
hunks
array[object]
Examples
Apply a patch to a file
// Input
{
"operation": "apply",
"filePath": "C:/project/main.pas",
"diff": "--- a/main.pas\n+++ b/main.pas\n@@ -10,3 +10,3 @@\n- Old line\n+ New line\n"
}
// Output
{
"output": "C:/project/main.pas",
"lines_before": 50,
"lines_after": 50,
"size_bytes": 1234
}
Parse a diff to inspect its structure
// Input
{
"operation": "parse",
"diff": "--- a/file.txt\n+++ b/file.txt\n@@ -1,3 +1,4 @@\n context\n-removed\n+added\n+extra\n context\n"
}
// Output
{
"hunk_count": 1,
"hunks": []
}
Install & Discovery
Install
ppm install mcp-diff
Get JSON Schema
GET /v1/packages/mcp-diff/1.0.0/schema
Discover by keyword
GET /v1/mcp/discover?q=diff
Discovery hint: Install with ppm install mcp-diff or invoke remotely via POST /v1/invoke/mcp-diff on the MCP Service.
PascalAI Usage
uses toolslib;
var Tool := LoadTool('mcp-diff');
var R := Tool.Call(JsonObj(['operation','apply','filePath','main.pas','diff',MyDiff]));
Writeln(R.ToJSON);