Edit-MCP 是一个与 Microsoft 的 Edit 工具集成的模型上下文协议(MCP)服务器,为 AI 系统提供高级文件编辑能力。它采用混合架构,结合了直接文件系统操作以提高性能,并通过 Microsoft Edit 集成来处理复杂的编辑任务。
Edit-MCP 服务器作为 AI 系统和文件编辑操作之间的复杂协调者。它暴露了一个标准化的 MCP 接口,允许 AI 模型进行以下操作:
Edit-MCP 采用混合架构,包括以下组件:
# 克隆仓库
git clone https://github.com/mixelpixx/edit-mcp.git
cd edit-mcp
# 安装依赖
npm install
# 构建项目
npm run build
您可以使用 stdio 或 HTTP 传输启动 Edit-MCP 服务器:
# 使用 stdio 传输启动(直接与 AI 系统集成)
npm run stdio
# 使用 HTTP 传输启动(基于 Web 的集成)
npm run http
用法:edit-mcp [选项]
选项:
-V, --version 输出版本号
-p, --port <port> HTTP 传输监听的端口(默认:"3000")
-e, --edit-path <path> Edit 可执行文件的路径
-m, --max-instances <number> 最大 Edit 实例数(默认:"5")
-t, --timeout <milliseconds> Edit 实例超时时间(毫秒,默认:"300000")
-c, --config <path> 配置文件路径
-d, --debug 启用调试日志
-s, --stdio 使用 stdio 传输而不是 HTTP
-h, --help 显示命令帮助
您可以通过 JSON 配置文件配置 Edit-MCP:
{
"editExecutable": "/path/to/edit",
"maxEditInstances": 5,
"instanceTimeout": 300000,
"simpleOperationThreshold": 1000,
"complexityFactors": {
"fileSize": 0.3,
"operationType": 0.4,
"contextRequirement": 0.3
}
}
Edit-MCP 提供以下工具:
read_file: 读取文件内容write_file: 写入文件内容list_files: 列出目录中的文件find_in_file: 在文件中查找模式出现format_code: 格式化文件中的代码complex_find_replace: 执行高级查找和替换操作interactive_edit_session: 开始交互式编辑会话smart_refactor: 跨多个文件智能重构代码backup_and_edit: 在编辑文件之前创建备份Edit-MCP 现在除了支持 stdio 之外还支持 HTTP 传输,允许远程访问和 REST API 端点。
# 使用默认 HTTP 端口(3000)启动
edit-mcp
# 使用自定义端口启动
edit-mcp --port 8080
# 使用配置文件启动
edit-mcp --config config.http.example.json
GET /health
POST /jsonrpc
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "read_file",
"arguments": {
"path": "example.txt"
}
},
"id": 1
}
GET /api/tools - 列出可用工具POST /api/tools/:toolName - 调用特定工具GET /api/files/:path - 读取文件内容PUT /api/files/:path - 写入文件内容GET /api/list/:directory - 列出目录中的文件POST /api/search - 在文件中搜索模式POST /api/format - 格式化代码POST /api/refactor - 跨文件重构符号GET /api/docs - API 文档通过在配置中设置 authEnabled: true 来启用 API 密钥认证:
{
"authEnabled": true,
"apiKey": "your-secure-api-key"
}
在请求中包含 API 密钥:
X-API-Key: your-secure-api-key?apiKey=your-secure-api-key在配置文件中配置允许的来源:
{
"corsOrigins": ["http://localhost:*", "https://yourdomain.com"]
}
配置速率限制以防止滥用:
{
"rateLimitWindowMs": 900000, // 15 分钟
"rateLimitMax": 100 // 每窗口 100 请求
}
# 构建项目
npm run build
# 监视更改并重新构建
npm run watch
# 使用热重载运行
npm run dev
MIT