OpenClaw Tools 的配置方法

OpenClaw 提供了 4 种预定义配置文件,用于控制工具权限
| Profile | 权限范围 | 适用场景 |
| minimal | 仅 session_status(会话状态) | 受限环境、只读监控 |
| coding | 文件系统、运行时、会话、内存、图片 | 代码开发、自动化脚本、技术支持 |
| messaging | 仅消息相关工具(默认) | 客服机器人、通知助手 |
| full | 所有工具(无限制) | 开发环境、超级管理员 |
OpenClaw 的主要配置文件位于:
~/.openclaw/openclaw.json
举例:
1、快速启用全部权限(推荐开发环境)
{
"tools": {
"profile": "full"
}
}
2、精细化权限控制,如下:
{
"tools": {
"profile": "coding",
"allow": ["web_search", "browser", "canvas"],
"deny": ["gateway", "exec"] #最先匹配这里
}
}
优先级如下:
deny (最高) → allow → profile (最低)
allow的意思是追加权限,因此正确的理解是,在coding功能的基础上,加上allow指定的功能,但是拒绝deny指定的功能
根据官方文档,coding 配置文件默认包含:
- 文件系统:
read,write,edit,apply_patch - 运行时:
exec,bash,process - 会话:
sessions_list,sessions_send,sessions_spawn - 内存:
memory_search,memory_get - 图片:
image
3、如果要严格限制只能使用特定的工具,应该使用minimal,如图:
{
"tools": {
"profile": "minimal", // 从最小权限开始
"allow": ["web_search", "browser", "canvas", "read", "write"]
}
}
4、多层策略精准控制权限,如下:
{
"tools": {
// 基础配置文件
"profile": "coding",
// 全局允许(可使用工具组)
"allow": [
"group:openclaw", // 所有核心工具
"group:fs", // 仅文件系统工具
"my_custom_tool" // 自定义工具
],
// 全局拒绝(覆盖允许列表)
"deny": ["exec", "gateway"],
// 基于提供商的策略
"byProvider": {
"anthropic": {
"profile": "full" // Claude模型允许所有工具
},
"openai": {
"allow": ["read", "write", "web_search"]
}
}
},
#控制特定的agent的权限
"agents": {
"list": [
{
"id": "coding-assistant",
"tools": {
"profile": "coding",
"alsoAllow": ["browser", "canvas"]
}
}
]
}
}
也可以通过工具组来管理策略,常见的工具组如下:
| 工具组 | 包含工具 | 用途 |
| group:runtime | exec, bash, process | 运行时命令执行 |
| group:fs | read, write, edit, apply_patch | 文件系统操作 |
| group:sessions | sessions_list, sessions_send, sessions_spawn | 会话管理 |
| group:memory | memory_search, memory_get | 记忆搜索 |
| group:web | web_search, web_fetch | 网络搜索 |
| group:ui | browser, canvas | 用户界面控制 |
| group:automation | cron, gateway | 自动化任务 |
| group:messaging | message | 消息发送 |
| group:openclaw | 所有内置 OpenClaw 工具 | 完整工具集 |
下面是一个使用工具组管理策略的例子,如下:
{
"tools": {
"profile": "minimal",
"allow": [
"group:fs",
"group:web",
"group:ui",
"group:memory"
],
"deny": ["group:runtime", "group:automation"] #禁用
}
}
最佳实践建议:
| 场景 | 推荐配置 |
| AI 编程助手 | group:fs + group:web + group:ui + group:memory |
| 网页数据采集 | group:web + group:ui |
| 系统运维脚本 | group:fs + group:runtime + group:automation |
| 客服机器人 | group:messaging + group:memory |
| 纯聊天场景 | profile: "messaging" 或 group:messaging 单独 |
完整配置文件举例:
{
"gateway": {
"host": "0.0.0.0",
"port": 18789
},
"tools": {
"profile": "coding",
"allow": [
"read", "write", "edit", "apply_patch",
"exec", "process",
"web_search", "web_fetch",
"browser", "image",
"memory_search", "memory_get",
"sessions_list", "sessions_send", "sessions_spawn",
"message", "cron", "gateway"
],
"deny": ["nodes", "canvas", "llm_task", "lobster"]
},
"approvals": {
"exec": { "enabled": true }
},
"agents": {
"main": {
"model": "kimi-coding/k2p5"
}
}
}
- approvals:要审批的操作


