快速开始

附加 CLI

openclaw attach 会使用绑定到一个 Gateway 网关会话的严格临时 MCP 配置启动 Claude Code。

sh
openclaw attachopenclaw attach --session agent:main:telegram:123 --ttl 600000openclaw attach --print-config

选项:

  • --session <key> 将授权绑定到一个 Gateway 网关会话。默认使用主会话。
  • --ttl <ms> 请求以毫秒为单位的正授权 TTL。Gateway 网关会应用自己的上限。
  • --bin <path> 选择 Claude Code 二进制文件。默认值为 claude
  • --print-config 写入临时 .mcp.json,打印启动命令和环境,并让授权保持有效直到 TTL 过期。

Bearer 令牌通过环境变量传递,而不是通过 argv。OpenClaw 使用 --strict-mcp-config --mcp-config <path> 启动 Claude Code,这样环境中的 Claude MCP 服务器就不会加入附加的会话。正常启动会在 Claude Code 进程退出时撤销授权。

另见:Gateway CLIMCP CLIACP CLI

Was this useful?