
MCP Text Editor Server
Line-oriented text file editing for LLMs with token-efficient partial reads and hash-based conflict detection.
Add to your client
Copy the config for your MCP client and paste it into its config file.
uvx mcp-text-editorPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-text-editor-server": {
"command": "uvx",
"args": [
"mcp-text-editor"
]
}
}
}Requires `uv` (the Python package runner). Install it from https://docs.astral.sh/uv/ if `uvx` is not found.
Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Python 3.13+ (README also notes 3.11+ in an earlier section)
- uv / uvx installed (curl -LsSf https://astral.sh/uv/install.sh | sh)
- POSIX-compliant OS (Linux, macOS) or Windows
- File system read/write permissions
About MCP Text Editor Server
MCP Text Editor Server facilitates safe and efficient line-based text file operations in a client-server architecture. It implements the Model Context Protocol with robust conflict detection and resolution, making it suitable for collaborative editing tools, automated text processing, or any scenario where multiple processes modify text files safely. Its partial file access (line-range reads) is especially valuable for LLM tools, reducing token consumption by loading only the necessary portions of files. Modifications use SHA-256 hash validation to handle concurrent edits correctly.
Tools & capabilities (3)
get_text_file_contentsGet the contents of one or more text files with line-range specification (1-based line numbers). Supports a single range or multiple ranges across multiple files in one call, with optional per-file encoding. Returns content plus SHA-256 hashes, total line count, and content size for use in subsequent edits.
patch_text_file_contentsApply patches to one or more text files with robust error handling and conflict detection. Requires the file hash and per-range range_hash from get_text_file_contents. Patches are applied bottom-to-top to handle line-number shifts, must not overlap, and use 1-based line numbers (end: null appends to end of file). Returns ok with a new hash, or an error with suggestions/hints on conflict.
edit_text_file_contentsEdit text file contents with conflict detection (shown in the README's common usage pattern). Takes a file path, the current hash, optional encoding, and a list of line-based patches (line_start/line_end/contents); returns ok or an error such as a hash mismatch when the file was modified concurrently.
What this server can do
MCP Text Editor Server provides tools for these capabilities — tap one to see every MCP server that does the same:
When to use it
- Letting an LLM edit large source or text files while loading only the relevant line ranges to save tokens
- Safe concurrent editing of shared files with hash-based conflict detection
- Atomic multi-file edits in automated text-processing pipelines
- Reading specific line ranges across several files in a single operation
- Working with non-UTF-8 files via explicit encoding (e.g. shift_jis, latin1)
Security notes
The server validates all file paths to prevent directory traversal attacks. All file modifications are validated using SHA-256 hashes to prevent race conditions. Inputs are sanitized and sensitive information is not exposed in error messages. Set proper file system permissions to restrict access to authorized directories.
MCP Text Editor Server FAQ
How does it reduce token usage for LLMs?
It supports partial file access via line-range specifications, so the model can read only the necessary portions of a file instead of the whole thing.
How are concurrent edits handled?
Every read returns SHA-256 hashes (file hash and per-range range_hash). Patches must supply the matching hashes; if the file changed, the server returns a hash-mismatch error and you re-fetch fresh content before retrying.
How do I install it for Claude Desktop?
Add an mcpServers entry running 'uvx mcp-text-editor' to claude_desktop_config.json, or install automatically via Smithery with 'npx -y @smithery/cli install mcp-text-editor --client claude'.
Which encodings are supported?
Flexible character encodings including utf-8 (default), shift_jis, latin1, and others; the encoding used to read a file must match the one used when patching it.
Alternatives to MCP Text Editor Server
Compare all alternatives →Official MCP reference server for secure local filesystem read/write within allowed directories.
Official MCP server for reading, searching, and manipulating a local Git repository's files and history.
Official AWS Labs MCP server to manage and query S3 Tables (table buckets, namespaces, tables).
Compare MCP Text Editor Server with: