该工具遵循MCP协议,主要用于编辑文件。它能有效解决文件编辑过程中的安全、版本控制等问题,为用户提供安全、智能、便捷的文件编辑体验。
启动服务器时需要指定一个或多个允许目录:
node build/index.js <允许目录> [额外目录...]
所有文件操作均限于这些指定的目录。
运行以下命令安装所需依赖:
npm install
构建生产环境版本的服务器:
npm run build
在开发环境中启用自动重建功能:
npm run watch
{
"path": "src/components/Button.tsx",
"edits": [{
"startLine": 5,
"endLine": 5,
"content": "export const Button = () => {"
}]
}
{
"operations": [
{
"path": "src/App.tsx",
"edits": [{
"startLine": 10,
"endLine": 10,
"content": "// 新注释"
}]
},
{
"path": "src/styles.css",
"edits": [{
"startLine": 20,
"endLine": 20,
"content": ".button { padding: 1rem; }"
}]
}
]
}
MCP_EDIT_STATE_TTL:编辑状态的超时时间,单位为毫秒,默认值为60000。常见错误及解决方案:
Error: 没有找到字符串匹配项"oldValue"在第5行
Error: 无效的正则表达式模式"([": 未终止的分组
Error: 第5行受到多个编辑操作的影响
推荐使用test:tools脚本对工具进行全面测试:
npm run test:tools
该脚本会:
在Claude环境中的配置示例:
export MCP_EDIT_STATE_TTL=360000
如需帮助或发现任何问题,请联系技术支持团队。