mcp-precise-edit mcp

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

Precise file editor. Three operations: view (read file or line range), edit (replace old_string with new_string — fails if text appears 0 or more than once, preventing accidental changes), patch (apply unified diff with @@ hunks, fuzzy matching ±20 lines). Modeled after Claude Code Edit tool. Use view first to confirm context before editing.

editoreditpatchdifffilesprecisecodingagentllm

Input Parameters

ParameterTypeDescription
operationrequired string view=read file or line range, edit=precise text replacement (unique match required), patch=apply unified diff One of: view, edit, patch.
pathrequired string Absolute path to the file. Required for all operations.
old_stringoptional string edit: exact text to find. Must appear exactly once in the file. Include surrounding lines for context if needed.
new_stringoptional string edit: replacement text.
diffoptional string patch: unified diff text (@@ hunks). Standard output of diff -u.
start_lineoptional integer view: first line to return (1-based). Default: 1.
end_lineoptional integer view: last line to return (1-based). Default: end of file.
encodingoptional string File encoding. utf8 (default), ansi (Windows-1252 for legacy files with tildes/enyes), utf8bom, utf16. One of: utf8, ansi, utf8bom, utf16. Default: utf8.

Output Fields

FieldTypeDescription
No output fields defined

Examples

View file lines 10-20

// Input
{
  "operation": "view",
  "path": "C:/src/main.pas",
  "start_line": 10,
  "end_line": 20
}

// Output
{
  "path": "C:/src/main.pas",
  "content": "  Result := 0;\n  ..."
}

Precise text replacement

// Input
{
  "operation": "edit",
  "path": "C:/src/main.pas",
  "old_string": "  Result := 0;\n  Exit;",
  "new_string": "  Result := -1;\n  Exit;"
}

// Output
{
  "path": "C:/src/main.pas",
  "ok": true,
  "msg": "Successfully replaced text at exactly one location."
}

Apply unified diff patch

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

// Output
{
  "path": "C:/src/main.pas",
  "ok": true,
  "msg": "Patch applied successfully."
}

Install & Discovery

Install

ppm install mcp-precise-edit

Get JSON Schema

GET /v1/packages/mcp-precise-edit/1.0.0/schema

Discover by keyword

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

PascalAI Usage

uses toolslib;
var Tool := LoadTool('mcp-precise-edit');
Tool.Call(JsonObj(['operation','view','path','C:/src/main.pas','start_line',1,'end_line',30]));
Tool.Call(JsonObj(['operation','edit','path','C:/src/main.pas','old_string','foo := 1;','new_string','foo := 2;']));