MCP Text Editor Server
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.
Potencialize seu agente
Instalação do publicador. Não é um endpoint do PlugMCP.
Host a copy with our keys and logs.
Ainda não há uma versão empacotada no registro. Siga o README do repositório.
URL remota ou um comando na sua máquina? Como as duas instalações diferem
Rodar no PlugMCP
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
AbrirDo publicador
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.
A token-efficient MCP server for safe, line-oriented text file editing with partial reads, hash-based conflict detection, and atomic multi-file operations.
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
└── pyproject.toml # Project configuration
MIT
This project uses Python type hints throughout the codebase. Please ensure any contributions maintain this.
All error cases should be handled appropriately and return meaningful error messages. The server should never crash due to invalid input or file operations.
New features should include appropriate tests. Try to maintain or improve the current test coverage.
All code should be formatted with Black and pass Ruff linting. Import sorting should be handled by isort.
A token-efficient MCP server for safe, line-oriented text file editing with partial reads, hash-based conflict detection, and atomic multi-file operations.
Ferramentas
Ainda não há lista de ferramentas. Servidores remotos recebem uma após a primeira verificação de saúde.
Perguntas frequentes
Copie nesta página a configuração stdio para Cursor, Claude Desktop, Claude Code ou VS Code. Ela usa a instalação do publicador, não um proxy do PlugMCP.
Este registro não lista nenhuma variável de ambiente obrigatória.
MCP Text Editor roda localmente via stdio.
Última verificação: 2026-10-28. A token-efficient MCP server for safe, line-oriented text file editing with partial reads, hash-based conflict detection, and atomic multi-file operations.