Tools Invoke (HTTP)
OpenClaw 的 Gateway 暴露一個簡單的 HTTP Endpoint 用於直接呼叫單一工具。它永遠啟用,但受 Gateway Auth 與 Tool Policy 管控。POST /tools/invoke- 與 Gateway 相同的 Port (WS + HTTP multiplex):
http://<gateway-host>:<port>/tools/invoke
認證 (Authentication)
使用 Gateway Auth 設定。傳送 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)。
Request Body
tool(string, required): 要呼叫的工具名稱。action(string, optional): 若 Tool Schema 支援action且 Args Payload 省略它,則映射至 Args。args(object, optional): 工具特定參數。sessionKey(string, optional): 目標 Session Key。若省略或為"main",Gateway 使用設定的 Main Session Key (尊重session.mainKey與預設 Agent,或在 Global Scope 下為global)。dryRun(boolean, optional): 保留供未來使用;目前忽略。
Policy + Routing 行為
工具可用性透過與 Gateway Agents 相同的 Policy Chain 進行過濾:tools.profile/tools.byProvider.profiletools.allow/tools.byProvider.allowagents.<id>.tools.allow/agents.<id>.tools.byProvider.allow- Group Policies (若 Session Key 映射至 Group 或 Channel)
- Subagent Policy (當使用 Subagent Session Key 呼叫時)
x-openclaw-message-channel: <channel>(例如:slack,telegram)x-openclaw-account-id: <accountId>(當存在多個 Accounts 時)
Responses
200→{ ok: true, result }400→{ ok: false, error: { type, message } }(Invalid Request 或 Tool Error)401→ Unauthorized404→ Tool not available (Not found 或 Not allowlisted)405→ Method Not Allowed