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

# MCPクライアントを設定する

> Claude Code、Antigravity、Codex、CursorにKameleoon MCPサーバーを登録します。

各クライアントは、Kameleoon MCPサーバーを自身の設定に登録し、OAuthログインを 1 回完了します。お使いのクライアントの手順に従ってから、サンプルプロンプトを実行してツールが動作することを確認してください。

## Claude Code の連携

### ステップ 1: サーバーを登録する

サーバーをユーザープロファイルに登録する場合（すべてのプロジェクトで使用できるようにする場合）は、ターミナルを開き、次のコマンドを実行します。

```bash theme={null}
claude mcp add --scope user kameleoon -- npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 --static-oauth-client-metadata '{ "scope": "openid" }'
```

現在のプロジェクトだけにサーバーを登録する場合（チームで共有するためにリポジトリに `.mcp.json` ファイルを追加します）は、次のコマンドを実行します。

```bash theme={null}
claude mcp add --scope project kameleoon -- npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 --static-oauth-client-metadata '{ "scope": "openid" }'
```

Claude がサーバーを追加したことを確認します。

```bash theme={null}
claude mcp list
```

**期待される出力:** `kameleoon: ... - ✗ Failed to connect`（この時点ではまだ認証を完了していないため、接続に失敗するのは正常です）。

### ステップ 2: OAuth認証を完了する

同じターミナルで、ログインフローを開始します。

```bash theme={null}
npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 --static-oauth-client-metadata '{ "scope": "openid" }'
```

1. コマンドは自動的にブラウザータブを開きます。開かない場合は、ターミナルに表示されたURLをコピーして、手動で開いてください。
2. Kameleoonアカウントにサインインします。
3. **Authorize** をクリックします。
4. ブラウザーに成功メッセージが表示されたら、ターミナルで `Ctrl+C` を押します。

接続を確認します。

```bash theme={null}
claude mcp list
```

**期待される出力:** `kameleoon: ... - ✓ Connected`

### ステップ 3: 新しいClaude Codeセッションを開始する

Claude Code は、新しく追加されたMCPサーバーのツールを、サーバーを登録した後に開始したセッションでのみ利用できるようにします。現在のClaude Codeのチャットを閉じて、新しいチャットを開いてください。

### ステップ 4: 接続を確認する

新しいClaude Codeの会話で、次のプロンプトを試してください。

* "List the Kameleoon feature flags."
* "What experiments are running on site X?"
* "Show the status of experiment Y."
* "Show the code for variation 1 of experiment Z."

## Antigravity の連携

### クイックセットアップ

次のセルフスタータープロンプトをAntigravityのチャットに直接貼り付けて、自動的に接続します。

```text theme={null}
Connect to the Kameleoon MCP production server. The endpoint is https://mcp.kameleoon.com/mcp, using mcp-remote@0.1.37 on port 35535 with the openid scope. Authenticate by running the npx mcp-remote command to trigger my browser, then verify the connection.
```

### 手動での設定

`~/.gemini/config/mcp_config.json` の設定ファイルを編集し、次のJSONブロックを追加します。ファイルにすでに `mcpServers` オブジェクトがある場合は、`kameleoon` のエントリーだけを追加してください。

```json theme={null}
{
  "mcpServers": {
    "kameleoon": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote@0.1.37",
        "https://mcp.kameleoon.com/mcp",
        "35535",
        "--static-oauth-client-metadata",
        "{ \"scope\": \"openid\" }"
      ]
    }
  }
}
```

## Codex の連携

### クイックセットアップ

次のセルフスタータープロンプトをCodexのチャットに貼り付けます。

```text theme={null}
Configure the Kameleoon MCP server at https://mcp.kameleoon.com/mcp. Use port 35535 for callback. Once configured, run the login command to trigger my browser and then list my feature flags.
```

### 手動での設定

次のブロックを `~/.codex/config.toml` に追加します。ファイルが存在しない場合は作成してください。

```toml theme={null}
[mcp_servers.kameleoon]
command = "npx"
args = ["-y", "mcp-remote@0.1.37", "https://mcp.kameleoon.com/mcp",
        "35535", "--static-oauth-client-metadata",
        "{ \"scope\": \"openid\" }"]
```

## 接続を認証する

Kameleoon MCPサーバーはOAuthを使用します。認可フローを開始するには、ターミナルで次のコマンドを実行します。

```bash theme={null}
npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 \
  --static-oauth-client-metadata '{ "scope": "openid" }'
```

**期待される動作:**

1. ブラウザーウィンドウが自動的に開きます。
2. Kameleoonのログインページで **Authorize** をクリックします。
3. Kameleoonがポート 35535 でローカルのコールバックを完了します。
4. ターミナルに、プロキシが正常に接続されたことが表示されます。

接続が成功すると、次のようなテキストが出力されます。

```text theme={null}
Connected to remote server using StreamableHTTPClientTransport
Local STDIO server running
Proxy established successfully between local STDIO and remote StreamableHTTPClientTransport
```

## ツールの動作を確認する

認証後、次のチェックを実行して、ツールが期待どおりに動作することを確認してください。

1. **ツールの一覧を確認する:** `tools/list` が成功し、Kameleoonのツールが返されることを確認します。[ツールリファレンス](https://docs.kameleoon.com/ja/mcp/mcp-server.md#ツールリファレンス)に記載されているツール（`experiment_code_get`、`feature_flag_list`、`feature_flag_create` など）が出力に含まれていることを確認します。
2. **フィーチャーフラグを取得する:** `feature_flag_list(siteCode = "d1alzzxd7k")` を実行します。成功すると、指定したサイトのフィーチャーフラグの一覧が返されます。
3. **実験結果を取得する:** `experiment_results_get(experimentId = 149640)` を実行します。成功すると、実験に紐付いた各ゴールの結果が含まれます。

## Cursor の連携

Cursor は、MCPツールをIDEのチャットサイドバーに直接統合するため、コーディング中にツールを利用できます。

### オプション 1: Cursor の UI で設定する（推奨）

1. Cursor Settings を開きます（macOSでは `Cmd+Shift+J`、WindowsとLinuxでは `Ctrl+Shift+J`）。
2. **Features > MCP Servers > + Add New MCP Server** に移動します。
3. **Name** を `kameleoon` に設定します。
4. **Type** を `command` に設定します。
5. **Command** に次の文字列を入力します。
   ```bash theme={null}
   npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 --static-oauth-client-metadata '{ "scope": "openid" }'
   ```
6. 設定を保存します。

### オプション 2: JSONファイルで設定する（上級者向け）

`~/.cursor/mcp.json` を開きます（ファイルが存在しない場合は作成します）。次のエントリーを `mcpServers` オブジェクトに追加します。

```json theme={null}
{
  "mcpServers": {
    "kameleoon": {
      "command": "bash",
      "args": [
        "-lc",
        "npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 --static-oauth-client-metadata '{ \"scope\": \"openid\" }'"
      ]
    }
  }
}
```

> [!NOTE]
>
> ファイルを手動で編集した後は、Cursor を再起動してください。

## 開発ワークフローのプロンプトの例

Kameleoon MCPサーバーに接続したら、IDEで次のようなプロンプトを使用します。

* "List the Kameleoon MCP tools available in this session."
* "Show all feature flags for site code `d1alzzxd7k`."
* "Get the details for feature flag new\_search on site `d1alzzxd7k`."
* "Fetch experiment results for experiment `149640` and summarize the current status."
* "Pull the variation code for experiment `<experimentId>` and variation `<variationId>`."

より高度なワークフローには、次のプロンプトを試してください。

* "Inspect feature flag new\_search for site `d1alzzxd7k` and explain what environments and variations it has."
* "Summarize experiment `149640` for an engineer. Include status, site code, winner state, and whether any variation data is available."
* "List the active feature flags for site `d1alzzxd7k` and point out any flags that look like stale candidates."
* "Retrieve the code for variation `<variationId>` in experiment `<experimentId>` and explain what frontend behavior it changes."
* "Create a new feature flag named `<name>` with key `<featureKey>` for site `d1alzzxd7k`."
* "Turn on feature flag `<featureKey>` in the staging environment for site `d1alzzxd7k`."
* "Turn off feature flag `<featureKey>` in the production environment for site `d1alzzxd7k`."
* "How has the checkout experiment performed week by week on phones?"
* "Did new visitors react differently from returning ones in the pricing test? Use Bayesian statistics."
* "Show the daily trend of the checkout test without Safari, counting every purchase, not only buyers."
* "Create a segment of returning visitors from Germany on desktop who already completed the Purchase goal."

## プロンプトのヒント

* フィーチャーフラグを扱うときは、サイトコードを含めてください。
* 実験または実験結果を照会するときは、実験IDを含めてください。
* バリエーションのコードを依頼するときは、`experimentId` と `variationId` の両方を含めてください。
* フィーチャーフラグのオン・オフを依頼するときは、対象の環境を明示してください。
* 生のデータを取得するだけでなく、AIエージェントにMCPのレスポンスを解釈させたい場合は、平易な言葉での要約を依頼してください。
