> ## Documentation Index
> Fetch the complete documentation index at: https://docs2.openclaw.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI を接続

`openclaw attach` は、1 つの Gateway セッションにバインドされた厳格な一時 MCP 設定で Claude Code を起動します。

```sh theme={"theme":{"light":"min-light","dark":"min-dark"}}
openclaw attach
openclaw attach --session agent:main:telegram:123 --ttl 600000
openclaw attach --print-config
```

オプション:

* `--session <key>` はグラントを Gateway セッションにバインドします。デフォルトはメインセッションです。
* `--ttl <ms>` はミリ秒単位で正のグラント TTL を要求します。Gateway は独自の上限を適用します。
* `--bin <path>` は Claude Code バイナリを選択します。デフォルトは `claude` です。
* `--print-config` は一時的な `.mcp.json` を書き込み、起動コマンドと env を出力し、TTL が期限切れになるまでグラントを有効なままにします。

ベアラートークンは argv ではなく、環境変数を通じて渡されます。OpenClaw は `--strict-mcp-config --mcp-config <path>` で Claude Code を起動するため、周囲の Claude MCP サーバーはアタッチされたセッションに参加しません。通常の起動では、Claude Code プロセスが終了するとグラントが取り消されます。

関連項目: [Gateway CLI](/ja-JP/cli/gateway)、[MCP CLI](/ja-JP/cli/mcp)、[ACP CLI](/ja-JP/cli/acp)。
