Ot Aiops
支持多协议工业设备数据采集与智能诊断,具备高风险写入防护机制。
为AI代理提供受控的文件系统操作能力,支持读写、搜索与目录管理。
openclaw skills install @buddhasource/filesystem-mcp命令、参数、文件名以原文为准
AI Agent 的安全文件操作
官方 MCP 参考实现,提供经过沙箱隔离的文件系统访问能力,支持细粒度权限控制。
大多数 Agent 任务都涉及文件操作:
纯使用 Node.js 内置模块实现,不依赖任何外部 API 或速率限制。
# 官方参考实现
npm install -g @modelcontextprotocol/server-filesystem
# 或从源码构建
git clone https://github.com/modelcontextprotocol/servers
cd servers/src/filesystem
npm install
npm run build在 MCP 客户端配置中添加:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/yourname/Documents",
"/Users/yourname/Projects"
]
}
}
}参数说明 = 允许访问的目录路径(可多个)
只读访问:
"args": ["--read-only", "/path/to/docs"]完全访问(默认):
"args": ["/path/to/workspace"]{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/dev/projects",
"/Users/dev/workspace"
]
}
}
}{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"--read-only",
"/Users/docs/knowledge-base"
]
}
}
}list_directory)Agent: "我的 Projects 文件夹里有哪些文件?"
Agent: "显示 /workspace/src 的内容"返回信息:
create_directory)Agent: "创建一个名为 'components' 的新文件夹"
Agent: "在 /workspace/tests 创建目录"move_file)Agent: "将 old-name.txt 重命名为 new-name.txt"
Agent: "把 report.pdf 移动到 /Documents/Reports/"read_file)Agent: "读取 config.json 的内容"
Agent: "给我看看 README.md 文件"支持格式:
write_file)Agent: "创建一个名为 notes.txt 的文件,内容为会议笔记"
Agent: "将生成的代码写入 src/index.ts"edit_file)Agent: "将 package.json 中的 'version: 1.0' 替换为 'version: 2.0'"
Agent: "在 utils.js 中添加一个新函数"get_file_info)Agent: "report.pdf 上次修改是什么时候?"
Agent: "data.csv 的大小是多少?"返回信息:
search_files)Agent: "在项目中查找所有 Python 文件"
Agent: "搜索包含 'API_KEY' 的文件"支持搜索条件:
delete_file)Agent: "删除临时日志文件"
Agent: "移除 old-backup.zip"安全机制:
Human: "创建一个用于登录表单的 React 组件"
Agent:
1. create_directory("/workspace/components")
2. write_file("/workspace/components/LoginForm.tsx", generated_code)
3. write_file("/workspace/components/LoginForm.test.tsx", test_code)
4. "已在 components/LoginForm.tsx 创建 LoginForm 组件"Human: "分析错误日志并总结问题"
Agent:
1. list_directory("/var/log/app")
2. read_file("/var/log/app/error.log")
3. search_files(pattern="ERROR", path="/var/log/app")
4. generate_summary()
5. write_file("/reports/error-summary.md", summary)Human: "按类型整理我的文档"
Agent:
1. list_directory("/Documents")
2. 对每个文件:
- get_file_info(file)
- 判断文件类型
- create_directory("/Documents/[type]")
- move_file(file, destination_folder)Human: "根据代码注释生成 API 文档"
Agent:
1. search_files(pattern="*.ts", path="/src")
2. 对每个文件:
- read_file(file)
- 提取文档注释
3. 生成 Markdown 文档
4. write_file("/docs/API.md", generated_docs)Agent 可以执行的操作:
Agent 不可执行的操作:
../)/etc/、/sys/)允许路径:/Users/dev/projects
Agent 尝试访问:/Users/dev/projects/src/index.ts → ✅ 允许
Agent 尝试访问:/Users/dev/projects/../secret → ❌ 阻止
Agent 尝试访问:/etc/passwd → ❌ 阻止- 仅授予必要的目录
- 无需写入时使用 --read-only 参数
- 不要添加 / 或系统目录
- 限制在用户工作区范围内
- 定期审查 MCP 服务器日志
- 监控异常文件访问模式
- 将凭证、密钥等存放在独立目录
- 不将其包含在允许的路径中
代理生成博客文章、报告、文档,并保存至结构化文件夹。
读取项目文件,生成代码,创建测试用例,更新配置。
读取 CSV/JSON 数据文件,进行分析,生成报告与可视化图表。
扫描目录,分类文件,移动至合适位置,清理重复项。
索引 Markdown 文件,搜索文档,提取信息,更新维基内容。
解析日志文件,识别错误,生成摘要,创建告警通知。
node_modules/)--read-only 模式下无法写入| 方法 | 安全性 | 代理集成 | 配置复杂度 |
|---|---|---|---|
| Filesystem MCP | ✅ 沙箱环境 | ✅ 自动发现 | 简单 |
| 直接文件系统访问 | ❌ 全系统权限 | ❌ 手动配置 | 无 |
| 文件上传/下载 | ✅ 手动控制 | ⚠️ 功能受限 | 复杂 |
| 云存储 API | ✅ API 层级安全 | ⚠️ 需 SDK 支持 | 复杂 |
{
"mcpServers": {
"filesystem": {
"command": "node",
"args": [
"/path/to/filesystem-server/build/index.js",
"/workspace",
"/documents"
],
"env": {
"MAX_FILE_SIZE": "10485760",
"ENABLE_LOGGING": "true",
"LOG_PATH": "/var/log/mcp-filesystem.log"
}
}
}
}安全可靠的代理文件系统访问方案:从代码生成到日志分析,Filesystem MCP 是代理文件操作的基础。
已收录 1 个 Skill