FileTools

•

Eliminates common AI code-editing errors by providing robust, line-range scoped, and CRLF-safe file manipulation capabilities.

FileTools is an MCP server and TypeScript library engineered to solve common file-editing failures encountered by AI coding agents, such as line drift, CRLF mismatches, ambiguous duplicate matches, and "Could not find oldString" errors. By constraining byte-literal replacements within explicit line-number ranges and automatically preserving line endings and whitespace, it guarantees dependable modifications. In the event of an edit mismatch, the tool returns the actual ground-truth content of the targeted range, enabling agents to self-correct accurately rather than guessing from memory.

Key Features

010 GitHub stars
02Line-range scoped editing to constrain target matching and prevent ambiguous replacements
03Atomic file operations and unified diff generation for safe, verified updates
04CRLF and LF preservation with automatic platform-specific line ending handling
05Byte-literal string replacement to prevent regex token and whitespace corruption
06Self-correction feedback that returns actual range content when a match fails

Use Cases

01Replacing brittle built-in file editing tools in coding agents like Claude Desktop and opencode
02Safely modifying source code files across cross-platform repositories with mixed line endings
03Integrating resilient, programmatic file manipulation capabilities into custom LLM agent workflows