DE

danielpodrazka/editor-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

14 stars 5 forks 质量 66 趋势 20MIT

一个基于Python的文本编辑器服务器由FastMCP所建,为文件操作提供工具. 这个服务器通过一个标准化的API可以读取,编辑和管理文本文件.

概览

基于Python的文本编辑器服务器用FastMCP所建,为文件操作提供强大的工具. 这个服务器能够通过一个标准化的API来读取,编辑并管理文本文件,具有独特的多步骤方法,大大提高了LLMs和AI助手的代码编辑精度和可靠性. - : 设置一个使用绝对路径工作的文件 - : - 用取出字行编号读取全部文件 - 用取出字行编号读取特定行编号 - 使用 find line在文件中查找特定文本 - 在 Python 和 JavaScript/JSX 文件中使用 find 函数查找并提取函数定义 - : - 有 diff 预览的两步编辑过程 - 选择并覆盖带有 ID 校验的文本 - 选择 → 覆盖 → 确认/取消模式的清洁编辑工作流程 - Python (.py) 和 JavaScript/React (.js,.

概述(AI 翻译)

基于Python的文本编辑器服务器用FastMCP所建,为文件操作提供强大的工具. 这个服务器能够通过一个标准化的API来读取,编辑并管理文本文件,具有独特的多步骤方法,大大提高了LLMs和AI助手的代码编辑精度和可靠性.

□ 特性

  • ** 文件选择**:设置使用绝对路径工作的文件
  • 读取操作:
  • 用行号读取全部文件 [[T0]
  • 使用 [[T1] 读取带有前缀行号的特定行范围
  • 使用find_line在文件中查找特定文本
  • 在 Python 和 JavaScript/ JSX 文件中查找并提取函数定义,使用 find_function
  • 编辑操作:
  • 有 diff 预览的两步编辑程序
  • 选择并覆盖带有ID验证的文本
  • 编辑工作流程干净,有选择 = 覆盖 = 确认/取消模式
  • Python (.py) 和 JavaScript/React (.js,.jsx) 文件的语法检查
  • 创建包含内容的新文件
  • ** 财务管理**:
  • 创建有适当初始化的新文件
  • 从文件系统中删除文件
  • 含有listdir的列表目录内容
  • ** 试验支助**:

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Editor MCP

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.

Features

  • File Selection: Set a file to work with using absolute paths
  • Read Operations:
    • Read entire files with line numbers using skim
    • Read specific line ranges with prefixed line numbers using read
    • Find specific text within files using find_line
    • Find and extract function definitions in Python and JavaScript/JSX files using find_function
  • Edit Operations:
    • Two-step editing process with diff preview
    • Select and overwrite text with ID verification
    • Clean editing workflow with select → overwrite → confirm/cancel pattern
    • Syntax checking for Python (.py) and JavaScript/React (.js, .jsx) files
    • Create new files with content
  • File Management:
    • Create new files with proper initialization
    • Delete files from the filesystem
    • List directory contents with listdir
  • Testing Support:
    • Run Python tests with run_tests
    • Set Python paths for proper module resolution
  • Safety Features:
    • Content ID verification to prevent conflicts
    • Line count limits to prevent resource exhaustion
    • Syntax checking to maintain code integrity
    • Protected paths to restrict access to sensitive files

Security Risks

The editor-mcp includes powerful capabilities that come with certain security considerations:

  • Jailbreak Risk: The editor-mcp can potentially be jailbroken when reading a file that has harmful instructions embedded inside. Malicious content in files being edited could contain instructions that manipulate the AI assistant.
  • Arbitrary Code Execution: If running tests is enabled, there is a risk of arbitrary code execution through manipulated test files or malicious Python code.
  • Data Exposure: Access to file system operations could potentially expose sensitive information if proper path protections aren’t configured.

To mitigate these risks:

  1. Use the PROTECTED_PATHS environment variable to restrict access to sensitive files and directories.
  2. Disable test running capabilities in production environments unless absolutely necessary.
  3. Carefully review files before opening them, especially if they come from untrusted sources.
  4. Consider running the editor in a sandboxed environment with limited permissions.

Key Advantages For LLMs

This text editor’s unique design solves critical problems that typically affect LLM code editing:

在 GitHub 查看完整 README

安装

uvx install git+https://github.com/danielpodrazka/mcp-text-editor.git
新手?先看 mcpskill.org 教程 →

配置

{ "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" } } } }