Editor MCP - MCP服务,MCP服务器,MCP教程

基本能力

产品定位

Editor MCP 是一个专为 LLM 和 AI 助手设计的文本编辑器服务器,旨在提供安全、可靠的代码编辑体验。

核心功能

  • 文件操作:支持文件的读取、编辑、创建和删除
  • 多步编辑:采用 select → overwrite → confirm/cancel 的工作流程
  • 语法检查:支持 Python 和 JavaScript/JSX 文件的语法检查
  • 安全特性:包括内容 ID 验证、行数限制和保护路径等功能
  • 测试支持:可以运行 Python 测试

适用场景

  • AI 辅助代码编辑
  • 自动化代码维护
  • 批量文件操作
  • 代码库探索和理解

工具列表

Editor MCP 提供了 13 个强大的工具:
1. set_file - 设置当前工作文件
2. skim - 读取整个文件内容
3. read - 读取特定行范围
4. select - 选择要编辑的行范围
5. overwrite - 准备替换选定行的内容
6. confirm - 确认并应用更改
7. cancel - 取消待处理的更改
8. delete_file - 删除当前文件
9. new_file - 创建新文件
10. find_line - 查找包含特定文本的行
11. find_function - 查找 Python 或 JavaScript/JSX 文件中的函数定义
12. listdir - 列出目录内容
13. run_testsset_python_path - 运行 Python 测试和配置 Python 环境

常见问题解答

  1. 安全问题
  2. 存在越狱风险,可能通过读取含有恶意指令的文件来操纵 AI 助手
  3. 如果启用测试运行,可能通过操纵测试文件或恶意 Python 代码执行任意代码
  4. 文件系统操作可能暴露敏感信息

  5. 缓解措施

  6. 使用 PROTECTED_PATHS 环境变量限制对敏感文件和目录的访问
  7. 在生产环境中禁用测试运行功能
  8. 在打开文件前仔细审查,特别是来自不受信任来源的文件
  9. 考虑在权限受限的沙盒环境中运行编辑器

使用教程

使用依赖

  • Python 3.7+
  • FastMCP 包
  • black(用于 Python 代码格式化检查)
  • Babel(用于 JavaScript/JSX 语法检查)

安装开发依赖:
```bash

使用 pip

pip install pytest pytest-asyncio pytest-cov

使用 uv

uv pip install pytest pytest-asyncio pytest-cov
```

对于 JavaScript/JSX 语法验证,需要 Node.js 和 Babel:
bash
npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/preset-react

安装教程

使用 UVX 安装(推荐)

bash
git clone https://github.com/danielpodrazka/editor-mcp.git
cd editor-mcp
chmod +x install.sh
./install.sh

手动安装
使用 UVX

bash
uvx install git+https://github.com/danielpodrazka/mcp-text-editor.git

使用传统 pip

bash
pip install git+https://github.com/danielpodrazka/mcp-text-editor.git

使用 requirements(旧版)

bash
uv pip install -r uv.lock

调试方式

启动服务器:
```bash

使用安装的脚本

editor-mcp

或使用 Python 模块

python -m text_editor.server
```

运行测试:
```bash

运行测试

pytest -v

运行带覆盖率的测试

pytest -v --cov=text_editor
```

点击访问

搜索工具

mcp-github-trending MCP Server - MCP服务,MCP服务器,MCP教程

2025-4-29 16:58:21

搜索工具

Hello MCP Go 👋 - MCP服务,MCP服务器,MCP教程

2025-4-29 16:58:28

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索