by tumf
A token-efficient MCP server for safe, line-oriented text file editing with partial reads, hash-based conflict detection, and atomic multi-file operations.
# Add to your Claude Code skills
git clone https://github.com/tumf/mcp-text-editorGuides for using mcp servers skills like mcp-text-editor.
mcp-text-editor is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by tumf. A token-efficient MCP server for safe, line-oriented text file editing with partial reads, hash-based conflict detection, and atomic multi-file operations. It has 202 GitHub stars.
mcp-text-editor's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/tumf/mcp-text-editor" and add it to your Claude Code skills directory (see the Installation section above).
mcp-text-editor is primarily written in Python. It is open-source under tumf on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh mcp-text-editor against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
A Model Context Protocol (MCP) server that provides line-oriented text file editing capabilities through a standardized API. Optimized for LLM tools with efficient partial file access to minimize token usage.
To use this editor with Claude.app, add the following configuration to your prompt:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"text-editor": {
"command": "uvx",
"args": [
"mcp-text-editor"
]
}
}
}
MCP Text Editor Server is designed to facilitate safe and efficient line-based text file operations in a client-server architecture. It implements the Model Context Protocol, ensuring reliable file editing with robust conflict detection and resolution. The line-oriented approach makes it ideal for applications requiring synchronized file access, such as collaborative editing tools, automated text processing systems, or any scenario where multiple processes need to modify text files safely. The partial file access capability is particularly valuable for LLM-based tools, as it helps reduce token consumption by loading only the necessary portions of files.
pyenv install 3.11.6
pyenv local 3.11.6
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
uvx mcp-text-editor
To install Text Editor Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install mcp-text-editor --client claude
pyenv install 3.13.0
pyenv local 3.13.0
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
Start the server:
python -m mcp_text_editor
The server provides several tools for text file manipulation:
Get the contents of one or more text files with line range specification.
Request:
The tool accepts a files array. Each file contains one or more line ranges using
start and end. File paths must be absolute.
{
"files": [
{
"file_path": "/absolute/path/to/file.txt",
"ranges": [
{"start": 1, "end": 10},
{"start": 20, "end": null}
]
}
],
"encoding": "utf-8"
}
Parameters:
file_path: Absolute path to the text filestart: First line to read (1-based)end: Last line to read (inclusive); null reads through end of fileencoding: File encoding for all requested files (default: utf-8)Response:
The top-level object is keyed by absolute file path. file_hash protects the
whole-file state; each range_hash protects the corresponding range.
{
"/absolute/path/to/file.txt": {
"file_hash": "sha256-hash-of-the-file",
"ranges": [
{
"content": "Lines 1-10 content",
"start": 1,
"end": 10,
"range_hash": "sha256-hash-of-this-range",
"total_lines": 50,
"content_size": 512
}
]
}
}
Apply one or more non-overlapping patches to one file. Read the target ranges
first and pass both the current file_hash and each matching range_hash.
Request:
{
"file_path": "/absolute/path/to/file.txt",
"file_hash": "sha256-hash-from-get-response",
"patches": [
{
"start": 5,
"end": 8,
"range_hash": "sha256-hash-of-lines-5-through-8",
"contents": "New content for lines 5-8\n"
}
],
"encoding": "utf-8"
}
Important notes:
get_text_file_contents immediately before editing.start and end; line_start and line_end are not accepted.append_text_file_contents, insert_text_file_contents, or
delete_text_file_contents for those specialized operations.Success response:
{
"result": "ok",
"file_hash": "sha256-hash-of-new-file-contents",
"reason": null,
"suggestion": null,
"hint": null
}
Error response:
{
"result": "error",
"reason": "Content range hash mismatch",
"suggestion": "get",
"hint": "Please run get_text_file_contents first to get current content and hashes"
}
get_text_file_contents for the exact range to replace.file_hash and the range's range_hash from the keyed response.patch_text_file_contents with those hashes and the same range.path = "/absolute/path/to/file.txt"
contents = await get_text_file_contents({
"files": [{
"file_path": path,
"ranges": [{"start": 5, "end": 8}]
}]
})
file_info = contents[path]
selected_range = file_info["ranges"][0]
result = await patch_text_file_contents({
"file_path": path,
"file_hash": file_info["file_hash"],
"patches": [{
"start": 5,
"end": 8,
"range_hash": selected_range["range_hash"],
"contents": "New content\n"
}]
})
The server handles various error cases:
Permission Denied
Hash Mismatch and Range Hash Errors
Encoding Issues
Connection Issues
Performance Issues
uv pip install -e ".[dev]"make allTests are located in the tests directory and can be run with pytest:
# Run all tests
pytest
# Run tests with coverage report
pytest --cov=mcp_text_editor --cov-report=term-missing
# Run specific test file
pytest tests/test_text_editor.py -v
Current test coverage: 90%
mcp-text-editor/
├── mcp_text_editor/
│ ├── __init__.py
│ ├── __main__.py # Entry point
│ ├── models.py # Data models
│ ├── server.py # MCP Server implementation
│ ├── service.py # Core service logic
│ └── text_editor.py # Text editor functionality
├── tests/ # Test files