
A Python-based text editor server built with FastMCP that provides tools for file operations. This
A Python-based text editor server built with FastMCP that provides tools for file operations. This server enables reading, editing, and managing text files through a standardized API.
·
A Python-based text editor server built with FastMCP that provides powerful tools for file operations. This server enables reading, editing, and managing text files through a standardized API with a unique multi-step approach that significantly improves code editing accuracy and reliability for LLMs and AI assistants.
skimreadfind_linefind_functionlistdirrun_testsThe editor-mcp includes powerful capabilities that come with certain security considerations:
To mitigate these risks:
PROTECTED_PATHS environment variable to restrict access to sensitive files and directories.This text editor's unique design solves critical problems that typically affect LLM code editing:
Prevents Loss of Context - Traditional approaches often lead to LLMs losing overview of the codebase after a few edits. This implementation maintains context through the multi-step process.
Avoids Resource-Intensive Rewrites - LLMs typically default to replacing entire files when confused, which is costly, slow, and inefficient. This editor enforces selective edits.
Provides Visual Feedback - The diff preview system allows the LLM to actually see and verify changes before committing them, dramatically reducing errors.
Enforces Syntax Checking - Automatic validation for Python and JavaScript/React ensures that broken code isn't committed.
Improves Edit Reasoning - The multi-step approach gives the LLM time to reason between steps, reducing haphazard token production.
The editor implements several safeguards to ensure system stability and prevent resource exhaustion:
This MCP was developed and tested with Claude Desktop. You can download Claude Desktop on any platform. For Claude Desktop on Linux, you can use an unofficial installation script (uses the official file), recommended repository: https://github.com/emsi/claude-desktop/tree/main
Once you have Claude Desktop installed, follow the instructions below to install this specific MCP:
The easiest way to install the Editor MCP is using the provided installation script:
# Clone the repository
git clone https://github.com/danielpodrazka/editor-mcp.git
cd editor-mcp
# Run the installation script
chmod +x install.sh
./install.shThis script will:
editor-mcp command available in your PATH# Install directly from GitHub
uvx install git+https://github.com/danielpodrazka/mcp-text-editor.git
# Or install from a local clone
git clone https://github.com/danielpodrazka/mcp-text-editor.git
cd mcp-text-editor
uvx install -e .pip install git+https://github.com/danielpodrazka/mcp-text-editor.git
# Or from a local clone
git clone https://github.com/danielpodrazka/mcp-text-editor.git
cd mcp-text-editor
pip install -e .Install from the lock file:
uv pip install -r uv.lockuv pip compile requirements.in -o uv.lockAfter installation, you can start the Editor MCP server using one of these methods:
# Using the installed script
editor-mcp
# Or using the Python module
python -m text_editor.serverYou can add the Editor MCP to your MCP configuration file:
{
"mcpServers": {
"text-editor": {
"command": "editor-mcp",
"env": {
"MAX_SELECT_LINES": "100",
"ENABLE_JS_SYNTAX_CHECK": "0",
"FAIL_ON_PYTHON_SYNTAX_ERROR": "1",
"FAIL_ON_JS_SYNTAX_ERROR": "0",
"PROTECTED_PATHS": "*.env,.env*,config*.json,*secret*,/etc/passwd,/home/user/.ssh/id_rsa"
}
}
}
}The Editor MCP supports several environment variables to customize its behavior:
MAX_SELECT_LINES: "100" - Maximum number of lines that can be edited in a single operation (default is 50)
ENABLE_JS_SYNTAX_CHECK: "0" - Enable/disable JavaScript and JSX syntax checking (default is "1" - enabled)
FAIL_ON_PYTHON_SYNTAX_ERROR: "1" - When enabled, Python syntax errors will automatically cancel the overwrite operation (default is enabled)
FAIL_ON_JS_SYNTAX_ERROR: "0" - When enabled, JavaScript/JSX syntax errors will automatically cancel the overwrite operation (default is disabled)
PROTECTED_PATHS: Comma-separated list of file patterns or paths that cannot be accessed, supporting wildcards (e.g., ".env,.env,/etc/passwd")
{
"mcpServers": {
"text-editor": {
"command": "/home/daniel/pp/venvs/editor-mcp/bin/python",
"args": ["/home/daniel/pp/editor-mcp/src/text_editor/server.py"],
"env": {
"MAX_SELECT_LINES": "100",
"ENABLE_JS_SYNTAX_CHECK": "0",
"FAIL_ON_PYTHON_SYNTAX_ERROR": "1",
"FAIL_ON_JS_SYNTAX_ERROR": "0",
"PROTECTED_PATHS": "*.env,.env*,config*.json,*secret*,/etc/passwd,/home/user/.ssh/id_rsa"
}
}
}
}The Editor MCP provides 13 powerful tools for file manipulation, editing, and testing:
set_fileSets the current file to work with.
Parameters:
filepath (str): Absolute path to the fileReturns:
skimReads full text from the current file. Each line is prefixed with its line number.
Returns:
Example output:
{
"lines": [
[1, "def hello():"],
[2, " print(\"Hello, world!\")"],
[3, ""],
[4, "hello()"]
],
"total_lines": 4,
"max_select_lines": 50
}readReads text from the current file from start line to end line.
Parameters:
start (int): Start line number (1-based indexing)end (int): End line number (1-based indexing)Returns:
Example output:
{
"lines": [
[1, "def hello():"],
[2, " print(\"Hello, world!\")"],
[3, ""],
[4, "hello()"]
],
"start_line": 1,
"end_line": 4
}selectSelect a range of lines from the current file for subsequent overwrite operation.
Parameters:
start (int): Start line number (1-based)end (int): End line number (1-based)Returns:
Note:
overwritePrepare to overwrite a range of lines in the current file with new text.
Parameters:
new_lines (list): List of new lines to overwrite the selected rangeReturns:
Note:
ENABLE_JS_SYNTAX_CHECK environment variableconfirmApply pending changes from the overwrite operation.
Returns:
Note:
cancelDiscard pending changes from the overwrite operation.
Returns:
Note:
delete_fileDelete the currently set file.
Returns:
new_fileCreates a new file and automatically sets it as the current file for subsequent operations.
Parameters:
filepath (str): Path of the new fileReturns:
Behavior:
Protected Files Note:
*.env) can be created normallyconfig.env, populate it with example config, but cannot reopen it laterNote:
find_lineFind lines that match provided text in the current file.
Parameters:
search_text (str): Text to search for in the fileReturns:
Example output:
{
"status": "success",
"matches": [
[2, " print(\"Hello, world!\")"]
],
"total_matches": 1
}Note:
find_functionFind a function or method definition in the current Python or JavaScript/JSX file.
Parameters:
function_name (str): Name of the function or method to findReturns:
Example output:
{
"status": "success",
"lines": [
[10, "def hello():"],
[11, " print(\"Hello, world!\")"],
[12, " return True"]
],
"start_line": 10,
"end_line": 12
}Note:
listdirLists the contents of a directory.
Parameters:
dirpath (str): Path to the directory to listReturns:
run_tests and set_python_pathTools for running Python tests with pytest and configuring the Python environment.
FAIL_ON_PYTHON_SYNTAX_ERROR: Controls whether Python syntax errors automatically cancel the overwrite operation (default: 1)
FAIL_ON_JS_SYNTAX_ERROR: Controls whether JavaScript/JSX syntax errors automatically cancel the overwrite operation (default: 0)
DUCKDB_USAGE_STATS: Controls whether usage statistics are collected in a DuckDB database (default: 0)
STATS_DB_PATH: Path where the DuckDB database for statistics will be stored (default: "text_editor_stats.duckdb")
DUCKDB_USAGE_STATS is enabledPROTECTED_PATHS: Comma-separated list of file patterns or absolute paths that will be denied access
*.env,.env*,config*.json,*secret*,/etc/passwd,/home/user/credentials.txt*.env - matches files ending with .env, like .env, dev.env, prod.env.env* - matches files starting with .env, like .env, .env.local, .env.production*secret* - matches any file containing 'secret' in the nameThe editor-mcp requires:
Install development dependencies:
# Using pip
pip install pytest pytest-asyncio pytest-cov
# Using uv
uv pip install pytest pytest-asyncio pytest-covFor JavaScript/JSX syntax validation, you need Node.js and Babel. The text editor uses npx babel to check JS/JSX syntax when editing these file types:
# Required for JavaScript/JSX syntax checking
npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/preset-react
# You can also install these globally if you prefer
# npm install -g @babel/core @babel/cli @babel/preset-env @babel/preset-reactThe editor requires:
@babel/core and @babel/cli - Core Babel packages for syntax checking@babel/preset-env - For standard JavaScript (.js) files@babel/preset-react - For React JSX (.jsx) files# Run tests
pytest -v
# Run tests with coverage
pytest -v --cov=text_editorThe test suite covers:
set_file tool
read tool
select tool
overwrite tool
confirm and cancel tools
delete_file tool
new_file tool
find_line tool
Unlike traditional code editing approaches where LLMs simply search for lines to edit and make replacements (often leading to confusion after multiple edits), this editor implements a structured multi-step workflow that dramatically improves editing accuracy:
This structured workflow forces the LLM to reason carefully about each edit and prevents common errors like accidentally overwriting entire files. By seeing previews of changes before committing them, the LLM can verify its edits are correct.
The server uses FastMCP to expose text editing capabilities through a well-defined API. The ID verification system ensures data integrity by verifying that the content hasn't changed between reading and modifying operations.
The ID mechanism uses SHA-256 to generate a unique identifier of the file content or selected line ranges. For line-specific operations, the ID includes a prefix indicating the line range (e.g., "L10-15-[hash]"). This helps ensure that edits are being applied to the expected content.
The main TextEditorServer class:
max_select_lines limit (default: 50) from environment variablesset_file: Validates and sets the current file pathskim: Reads the entire content of a file, returning a dictionary of line numbers to line textread: Reads lines from specified line range, returning a structured dictionary of line contentselect: Selects lines for subsequent overwrite operationoverwrite: Takes a list of new lines and prepares diff preview for changing contentconfirm: Applies pending changes from the overwrite operationcancel: Discards pending changes from the overwrite operationdelete_file: Deletes the current filenew_file: Creates a new filefind_line: Finds lines containing specific textfind_function: Finds function or method definitions in Python and JavaScript/JSX fileslistdir: Lists contents of a directoryrun_tests and set_python_path: Tools for running Python testsThe server runs using FastMCP's stdio transport by default, making it easy to integrate with various clients.
For optimal results with AI assistants, it's recommended to use the system prompt (see system_prompt.md) that helps guide the AI in making manageable, safe edits.
This system prompt helps the AI assistant:
By incorporating this system prompt when working with AI assistants, you'll get more reliable editing behavior and avoid common pitfalls in automated code editing.
The text editor MCP can collect usage statistics when enabled, providing insights into how the editing tools are being used:
DUCKDB_USAGE_STATS is enabledSTATS_DB_PATHThe collected statistics can help understand usage patterns, identify common workflows, and optimize the editor for most frequent operations.
You can query the database using standard SQL via any DuckDB client to analyze usage patterns.
If you encounter issues:
Inspired by a similar project: https://github.com/tumf/mcp-text-editor, which at first I forked, however I decided to rewrite the whole codebase from scratch so only the general idea stayed the same.
Pick your client and paste the snippet. Each one is the same server, written the way that client expects it.
claude mcp add text-editor -- editor-mcp{
"mcpServers": {
"text-editor": {
"env": {
"PROTECTED_PATHS": "",
"MAX_SELECT_LINES": "",
"ENABLE_JS_SYNTAX_CHECK": "",
"FAIL_ON_JS_SYNTAX_ERROR": "",
"FAIL_ON_PYTHON_SYNTAX_ERROR": ""
},
"command": "editor-mcp"
}
}
}code --add-mcp '{"name":"text-editor","env":{"PROTECTED_PATHS":"","MAX_SELECT_LINES":"","ENABLE_JS_SYNTAX_CHECK":"","FAIL_ON_JS_SYNTAX_ERROR":"","FAIL_ON_PYTHON_SYNTAX_ERROR":""},"command":"editor-mcp"}'[mcp_servers.text-editor]
command = "editor-mcp"Runs locally on your device. Your client starts the server itself, so nothing has to be hosted.
Paste this prompt into your agent. It reads this page and does the setup for you.
Read https://aiagentslisting.com/mcp/editor-mcp to learn what the "Editor MCP" MCP server does and how to install it. Add it to my coding agent's MCP configuration as documented on that page, then confirm the server connects and list the tools it exposes.Agents can also browse this directory over MCP at https://aiagentslisting.com/api/mcp
uvx install git+https://github.com/danielpodrazka/mcp-text-editor.git
uvx install -e .This server runs locally, so we can't read its tool list over the web yet.
Maintain this server? Claiming proves you own the listing and earns the last 4 points.
Claim this listingPaste this line near the top of your repository's README. The badge always renders the current score.
[](https://aiagentslisting.com/mcp/editor-mcp)Nothing comparable is listed yet.
No tagged releases on record.
Connect to the AI Agents Listing MCP server at https://aiagentslisting.com/api/mcp using the HTTP transport and complete the sign-in when it asks. Then call the submit_review tool for the listing "editor-mcp" with a rating from 1 to 5 and a short note on what worked and what did not.No reviews yet
Be the first to share your experience with this tool.
One email a week. New agents, MCP servers and skills, and what is actually getting traction.