LabscoMCP early access ↗
oakenaiMCP SERVER

Edit File Lines MCP Server

Line-precise file edits with a dry run you have to approve: preview the diff, get a state ID back, then apply it — inside directories you explicitly allowed.

by oakenai ↗Local Filesystem AccessCommunity

LABSCO SUMMARY

The dry run is not optional theatre — the state ID is what makes it a real gate.

Because applying an edit needs the exact state ID and an exact match of path and edits, an assistant cannot quietly widen a change between the preview you read and the write that lands. The expiry is short by default, which is a security property rather than an annoyance: if you walked away, the approval is gone and the edit has to be re-proposed.

What it is

A TypeScript MCP server for making exact, line-based edits to text files. An edit names a line range and either a literal string or a regex to match within it, so replacements preserve the surrounding formatting and indentation rather than rewriting whole lines. Every edit can run as a dry run that returns a unified diff and a state ID; nothing touches the file until that state ID is approved.

What you get

  • Line-based edits by literal match or regex, across single or multiple lines, several edits at once, previewable before they apply — edit_file_lines
  • A two-step commit: the dry run returns a diff plus a state ID, and applying requires that ID and an exact match of file path and edits — approve_edit
  • Specific lines read back with surrounding context, to verify content before and after an edit — get_file_lines
  • Search that hands you the line numbers to edit: text or regex, case sensitivity, whole-word matching, configurable context, with defaults of 2 context lines, 100 maximum matches and a 10-line context cap — search_file
  • Whitespace handled deliberately: literal matches are whitespace-normalised, original indentation is preserved in replacements, and strMatch and regexMatch cannot be combined in one edit
  • Guardrails that fail loudly: overlapping regex patterns are rejected, and so is a line affected by multiple edits

Requirements

No account and no key. Build from a clone with npm install and npm run build. The server must be started with one or more allowed directories — node build/index.js <allowed-directory> [additional-directories...] — and every file operation is restricted to them, with symlink escapes and parent-directory traversal rejected. MCP_EDIT_STATE_TTL sets how long an edit state stays approvable, in milliseconds, defaulting to 60000; an expired or unknown state ID returns an error rather than applying anything. The package is edit-file-lines 0.1.0.

Setup effort

Build from source