Tools Invoke(HTTP)
OpenClaw 的 Gateway 提供一个简单的 HTTP 端点,可直接调用单个工具。该端点始终启用,但受 Gateway 认证与工具策略约束。POST /tools/invoke- 与 Gateway 相同端口(WS + HTTP 复用):
http://<gateway-host>:<port>/tools/invoke
认证
使用 Gateway 的认证配置。发送 bearer token:Authorization: Bearer <token>
- 当
gateway.auth.mode="token"时,使用gateway.auth.token(或OPENCLAW_GATEWAY_TOKEN)。 - 当
gateway.auth.mode="password"时,使用gateway.auth.password(或OPENCLAW_GATEWAY_PASSWORD)。
请求体
tool(string,必需):要调用的工具名。action(string,可选):若工具 schema 支持action且 args 未提供该字段,会将其映射进 args。args(object,可选):工具参数。sessionKey(string,可选):目标会话 key。若省略或为"main",Gateway 使用配置的 main 会话 key(遵循session.mainKey与默认 agent,或全局作用域中的global)。dryRun(boolean,可选):预留未来使用;当前忽略。
策略 + 路由行为
工具可用性经过与 Gateway agents 相同的策略链过滤:tools.profile/tools.byProvider.profiletools.allow/tools.byProvider.allowagents.<id>.tools.allow/agents.<id>.tools.byProvider.allow- 组策略(当 session key 映射到群或频道)
- subagent 策略(使用 subagent session key 调用时)
x-openclaw-message-channel: <channel>(例如slack,telegram)x-openclaw-account-id: <accountId>(存在多账号时)
响应
200→{ ok: true, result }400→{ ok: false, error: { type, message } }(请求无效或工具错误)401→ 未授权404→ 工具不可用(未找到或不在 allowlist)405→ 方法不允许