该工具集基于模型上下文协议,提供多种功能以协助开发和维护工作。
<a href="https://glama.ai/mcp/servers/@GonTwVn/GonMCPtool"> <img width="380" height="200" src="https://gips2.baidu.com/it/u=3690047181,2091524345&fm=3081&app=3081&f=PNG?w=760&h=400" alt="GonMCPtool MCP 服务器" /> </a>提供文件写入功能,可以创建新文件或修改现有文件。
fileWrite({
filePath: "path/to/file.txt",
content: "这是内容",
mode: "write", // 可选值: write, append, json
createDirs: true, // 可选,是否自动创建目录
prettify: true // 可选,仅对json模式有效,是否美化JSON输出
})
读取文件内容,支持纯文本和 JSON 格式。
fileRead({
filePath: "path/to/file.txt",
mode: "text", // 可选值: text, json
encoding: "utf8" // 可选,指定编码方式
})
精确编辑归档,可以替换特定文本内容。
edit_file({
path: "path/to/file.txt",
edits: [
{
oldText: "要替换的文字",
newText: "替换后的文字"
}
],
dryRun: false // 可选,预览变更而不实际修改文件
})
在文件的特定位置插入新内容。
insert_to_file({
path: "path/to/file.txt",
position: 10, // 行号 (从1开始),或标记文字
content: "要插入的内容",
dryRun: false // 可选,预览变更而不实际修改文件
})
从归档中删除特定内容。
delete_from_file({
path: "path/to/file.txt",
selector: "要删除的文字", // 或 {startLine: 5, endLine: 10} 或 {start: "开始标记", end: "结束标记"}
dryRun: false // 可选,预览变更而不实际修改文件
})
// 创建一个新的 TypeScript 文件
fileWrite({
filePath: "src/utils/helper.ts",
content: `export function add(a: number, b: number): number {
return a + b;
}`,
mode: "write"
});
// 读取文件内容
fileRead({
filePath: "src/utils/helper.ts",
mode: "text"
});
// 编辑文件中的特定文字
edit_file({
path: "src/utils/helper.ts",
edits: [
{
oldText: "export function add",
newText: "export function sum"
}
]
});
// 在文件中插入新内容
insert_to_file({
path: "src/utils/helper.ts",
position: 1, // 在第一行插入
content: "// 数学实用函数\n"
});
// 删除文件中的特定内容
delete_from_file({
path: "src/utils/helper.ts",
selector: "// 数学实用函数\n"
});
// 创建 JSON 配置文件
fileWrite({
filePath: "config.json",
content: '{"version": "1.0.0", "debug": false}',
mode: "json",
prettify: true
});
// 读取 JSON 文件
fileRead({
filePath: "config.json",
mode: "json"
});
codeFileRead、codeLineInsert 和 codeLineDelete 工具主要用于代码编辑,而新的归档工具(fileWrite 和 fileRead)更具通用性,可用于任何类型的文本文件。
使用 edit_file、insert_to_file 和 delete_from_file 工具时,建议先启用 dryRun 模式预览更改,确保操作不会导致意外修改。
文件路径可以是相对路径或绝对路径。
执行批量操作时,建议使用 edit_file 工具,可以在一次调用中执行多次编辑操作。