mcp-diffeditor mcp

v1.0.0 · MCP Tool · coding · registry.pascalai.org

File editor with unified diff support. Apply patches, replace text, edit line ranges, view files with line numbers. Designed for LLMs editing code.

editordiffpatcheditfilesreplacecodingagentllm

Input Parameters

ParameterTypeDescription
operationrequired string Operation to perform. One of: view, apply_diff, replace, replace_lines, insert_lines.
pathoptional string Path to the file to edit or view. Required for all operations.
diffoptional string Unified diff text. Required for: apply_diff.
oldstroptional string Exact text to find. Required for: replace.
newstroptional string Replacement text. Required for: replace.
contentoptional string New content. Required for: replace_lines, insert_lines.
fromlineoptional integer First line of range to replace (1-based). Required for: replace_lines.
tolineoptional integer Last line of range (1-based, inclusive). Required for: replace_lines.
lineoptional integer Insert BEFORE this line (1-based). 0 = append at end. Used by: insert_lines.
offsetoptional integer First line to show (1-based). Used by: view. Default: 1
limitoptional integer Number of lines to show. Used by: view. Default: 0 = all
encodingoptional string Encoding: utf8 (default), utf16, ansi.
backupoptional boolean Save .bak before editing. Default: false

Output Fields

FieldTypeDescription
No output fields defined

Examples

View file with line numbers

// Input
{
  "operation": "view",
  "path": "C:/src/main.pas",
  "limit": 30
}

// Output
{
  "ok": true,
  "content": "   1  program main;\n   2  begin\n",
  "total_lines": 50
}

Apply unified diff

// Input
{
  "operation": "apply_diff",
  "path": "C:/src/main.pas",
  "diff": "@@ -1,3 +1,3 @@\n context\n-old line\n+new line\n context"
}

// Output
{
  "ok": true,
  "hunks_applied": 1,
  "lines_before": 50,
  "lines_after": 50
}

Replace text

// Input
{
  "operation": "replace",
  "path": "C:/src/main.pas",
  "oldstr": "foo := 1;",
  "newstr": "foo := 2;"
}

// Output
{
  "ok": true,
  "replacements": 1
}

Install & Discovery

Install

ppm install mcp-diffeditor

Get JSON Schema

GET /v1/packages/mcp-diffeditor/1.0.0/schema

Discover by keyword

GET /v1/mcp/discover?q=editor
Discovery hint: Install with ppm install mcp-diffeditor or invoke remotely via POST /v1/invoke/mcp-diffeditor on the MCP Service.

PascalAI Usage

uses toolslib;
var Tool := LoadTool('mcp-diffeditor');
var R := Tool.Call(JsonObj(['operation','view','path','C:/src/main.pas']));
Tool.Call(JsonObj(['operation','replace','path','C:/src/main.pas','oldstr','old text','newstr','new text']));