Edit - MCP是一个模型上下文协议(MCP)服务器,它与微软的Edit工具集成,为AI系统提供高级文件编辑功能。它采用混合架构,将用于提升性能的直接文件系统操作与用于处理复杂编辑任务的微软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 HTTP传输协议监听的端口(默认值:"3000")
-e, --edit-path Edit可执行文件的路径
-m, --max-instances Edit实例的最大数量(默认值:"5")
-t, --timeout Edit实例的超时时间(以毫秒为单位,默认值:"300000")
-c, --config 配置文件的路径
-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许可证。