メインコンテンツへスキップ
Kameleoon Model Context Protocol (MCP) サーバーは、AI コーディングアシスタントを Kameleoon プロジェクトに直接接続し、フィーチャーフラグや実験のためのエージェント型ワークフローを可能にします。本ガイドでは、AI ツールに対して構成の検索、結果の分析、バリエーションコードの開発環境への直接取り込みを指示することで、開発の「ラストマイル」を自動化する方法を説明します。サーバーを登録・認証して、フラグの作成からロールアウトに至る実装ライフサイクルを自動化しましょう。

機能

サーバーを接続すると、AI エージェントは Kameleoon と連携して次のタスクを実行できます。
  • フィーチャーフラグ構成の検索、取得、切り替え、管理。
  • 実験の勝者の分析、統計サマリーの取得。
  • 実験から JavaScript または CSS のバリエーションコードを直接取得。
  • フラグ作成からロールアウトまでの実装ライフサイクル全体の自動化。

主要ワークフロー: 勝った実験から本番環境へ

Kameleoon MCP サーバーは、実装の「ラストマイル」を自動化します。IDE を離れることなく、AI アシスタントに次のワークフローを実行するよう指示できます。
  1. 実験結果を取得し、勝ったバリエーションを特定する。
  2. Kameleoon からそのバリエーションの生コードを抽出する。
  3. コードを既存のコードベースに整合したネイティブで本番対応のコード (React コンポーネントなど) に変換する。
  4. Kameleoon でフィーチャーフラグを作成する。
  5. 新しい実装をフィーチャーフラグの背後にラップする。
  6. 本番環境で機能を有効化して検証する。

利用可能なツール

ツール目的プロンプト例
feature_flag_listサイトのすべてのフラグを一覧表示します。“List all feature flags for site d1alzzxd7k.”
feature_flag_get詳細なフラグ構成を取得します。“Show configuration for flag snake_game.”
feature_flag_enableフラグを ON に切り替えます。“Enable the new_search flag in production.”
feature_flag_create新しい基本フラグを作成します。“Create a flag ui_refresh for site d1alzzxd7k.”
experiment_listアクティブな実験を一覧表示します。“List all active experiments.”
experiment_results_get結果と勝者データを取得します。“Show winner summary for experiment 149640.”
experiment_code_getJavaScript または CSS のバリエーションコードを抽出します。“Pull variation code for experiment 149640.”

Claude 連携

前提条件

  • Claude Code がインストールされていること (claude --version)
  • Node.js v18 以降がインストールされていること (node --version)
  • Kameleoon アカウント

ステップ 1: サーバーの登録

サーバーをユーザープロファイル用に登録 (すべてのプロジェクトで利用可能) するには、ターミナルを開いて次のコマンドを実行します。
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 ファイルがリポジトリに追加されます) する場合は、次を実行します。
claude mcp add kameleoon -- npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 --static-oauth-client-metadata '{ "scope": "openid" }'
Claude がサーバーを追加したことを確認します。
claude mcp list
期待される出力: kameleoon: ... - ✗ Failed to connect (まだ認証を完了していないため、これは正常です)。

ステップ 2: OAuth 認証の完了

同じターミナルで、ログインフローをトリガーします。
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 を押します。
接続を確認します。
claude mcp list
期待される出力: kameleoon: ... - ✓ Connected

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

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

ステップ 4: 接続の確認

新しい Claude Code 会話で、次のプロンプトを試します。
  • “List my Kameleoon feature flags.”
  • “What experiments are active on site X?”
  • “Show me the status of experiment Y.”
  • “Show me the code for variation 1 of experiment Z.”

Claude のトラブルシューティング

症状原因対処方法
ブラウザが開かない。自動起動に失敗した。ターミナルから URL をコピーして手動で開きます。
ポート 35535 で接続拒否。ポートが使用中。`netstat -anofindstr :35535` を実行し、プロセスを終了して再試行します。
OAuth 後に接続に失敗。トークンが保持されていない。ステップ 2 のコマンドを再実行してトークンを更新します。
Claude でツールが表示されない。サーバー追加前にセッションが開始された。新しい Claude Code 会話を開始します。
settings.jsonmcpServers キーが拒否される。間違ったファイル。Claude Code はそのキーを使用しません。代わりに claude mcp add コマンドを使用します。
長時間経過後の認証エラー。OAuth トークンが期限切れ。ステップ 2 のコマンドを再実行します。

Antigravity 連携

クイックセットアップ

次のセルフスタータープロンプトを Antigravity チャットに直接貼り付けると、自動的に接続できます。
“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/antigravity/mcp_config.json の構成ファイルを編集し、次の JSON ブロックを追加します。
"kameleoon": {
  "command": "npx",
  "args": [
    "-y",
    "mcp-remote@0.1.37",
    "https://mcp.kameleoon.com/mcp",
    "35535",
    "--static-oauth-client-metadata",
    "{ \"scope\": \"openid\" }"
  ]
}

Codex 連携

クイックセットアップ

次のセルフスタータープロンプトを Codex チャットに貼り付けます。
“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 に追加します。ファイルが存在しない場合は作成してください。
[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 を使用します。ターミナルで次のコマンドを実行して、認可フローを開始します。
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. ターミナルでプロキシが正常に接続されたことが確認されます。
接続が成功すると、次のようなテキストが出力されます。
Connected to remote server using StreamableHTTPClientTransport
Local STDIO server running
Proxy established successfully between local STDIO and remote StreamableHTTPClientTransport

ツール操作の確認

認証後、次のチェックを実行してツールが期待通りに動作することを確認します。
  1. 利用可能なツールを一覧表示する: tools/list が成功し、Kameleoon ツールを返すことを確認します。出力に experiment_code_getfeature_flag_listfeature_flag_create などツール表に記載されたツールが含まれていることを確認します。
  2. フィーチャーフラグの取得: feature_flag_list(siteCode = "d1alzzxd7k") を実行します。応答が成功すると、指定したサイトのフィーチャーフラグのリストが返されます。
  3. 実験結果の取得: experiment_results_get(experimentId = 149640) を実行します。応答が成功すると、実験名、サイトコード、タイプ、ステータスが含まれます。

Cursor 連携

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

オプション 1: Cursor UI で構成 (推奨)

  1. Cursor の設定を開きます (macOS では Cmd + Shift + J、Windows/Linux では Ctrl + Shift + J)。
  2. Features > MCP Servers > + Add New MCP Server に移動します。
  3. Namekameleoon に設定します。
  4. Typecommand に設定します。
  5. 次の文字列を Command として入力します。
    npx -y mcp-remote@0.1.37 https://mcp.kameleoon.com/mcp 35535 --static-oauth-client-metadata '{ "scope": "openid" }'
    
  6. 構成を保存します。

オプション 2: mcp.json で構成 (上級)

~/.cursor/mcp.json を開き (ファイルが存在しない場合は作成)、次のエントリを mcpServers オブジェクトに追加します。
{
  "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\" }'"
      ]
    }
  }
}
ファイルを手動で編集した後は、Cursor を再起動してください。

開発者ワークフロー向けのサンプルプロンプト

Kameleoon MCP サーバーを接続したら、IDE で次のようなプロンプトを使用します。
  • “List the Kameleoon MCP tools available in this session.”
  • “Show me 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 currently 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.”

高度なワークフロー: エンドツーエンドの自動化

MCP サーバーの完全な機能を体験するために、包括的なシステムプロンプトを使用します。次の例は、勝ったバリエーションコードを React コンポーネントに変換する方法を示しており、主に React アプリケーション向けです。AI エージェントに、勝った結果の取得から、新しいフィーチャーフラグの背後にゲートされた本番対応のネイティブコードの生成まで、実装ライフサイクル全体を処理するよう指示します。 次のプロンプトを AI アシスタントに貼り付けます。
You are integrating a Kameleoon A/B experiment into a production codebase by converting a Kameleoon PBX variation into maintainable native React code. Context
  • Experiment ID: 373001
  • Mode: strict_winner_only (default) or manual_variation_conversion (Fallback variation: 1266752)
Rules
  • Inspect the repo first and follow existing conventions (structure, styling, routing, tests, feature flags).
  • Do not copy experiment code directly. Re-implement using idiomatic React (components, hooks, state).
  • Do not keep experiment-specific logic (IDs, Kameleoon APIs) in production code.
  • Prefer existing feature flag systems for rollout.
  • Avoid DOM manipulation (no querySelector, MutationObserver, etc.).
  • Do not add new dependencies unless necessary.
  • Be explicit if something is unclear.
Workflow steps
  1. Get experiment results.
  2. Decide integration:
    • Mode A (default: strict_winner_only): Proceed only if winner.status == "clear_winner".
    • Mode B (manual): Use the fallback variation provided in the context.
  3. Get the variation code and the prompt that was used.
  4. Convert the code to React (convert JS code to React components/hooks, and CSS code to the project styling system).
  5. Create a feature flag “pbx-winning-experiment-373001” and gate the converted code behind it.

ツールパラメータリファレンス

tools/list が返す正確なツール名とパラメータ名を使用してください。ライブ MCP スキーマは次のパラメータをサポートします。
ツール必須パラメータオプションパラメータ
feature_flag_listsiteCodeなし
feature_flag_getfeatureKey, siteCodeenvironmentKey
feature_flag_enablefeatureKey, siteCodeenvironmentKey
feature_flag_createfeatureKey, siteCodeなし
experiment_results_getexperimentIdなし
experiment_code_getexperimentId, variationIdなし
環境固有のクエリでは、サポートされている場所で environmentKey = "production" または environmentKey = "staging" を渡します。

プロンプトのヒント

  • フィーチャーフラグを操作する際は、サイトコードを含めてください。
  • 実験や実験結果を照会する際は、実験 ID を含めてください。
  • バリエーションコードをリクエストする際は、experimentIdvariationId の両方を含めてください。
  • エージェントにフィーチャーフラグの有効化または無効化を依頼する際は、対象環境を明示的に指定してください。
  • AI エージェントが生データを取得するだけでなく、MCP の応答を解釈することを希望する場合は、平易な英語のサマリーを要求してください。

一般的なトラブルシューティング

ポート 35535 がすでに使用中

認証が EADDRINUSE エラーで失敗する場合、別のプロセスがすでに OAuth コールバックポートをリスニングしています。
  • 原因: 以前の認証試行から残った古い mcp-remote プロセスがまだアクティブです。
  • 対処方法: ポート 35535 を使用している古いプロセスを停止して、OAuth コマンドを再実行します。

MCP サーバーが Codex チャットに表示されない

Codex は、新しく追加された MCP サーバーを既に実行中のスレッドへホットリロードしないことがあります。
  • 対処方法: config.toml を更新した後、Codex を更新するか、新しいセッションを開始します。

ブラウザフローが完了しない

OAuth ブラウザウィンドウは開くが認証が完了しない場合:
  • Kameleoon ログインページで Authorize ボタンをクリックしたことを確認します。
  • ブラウザまたはシステム設定が localhost コールバックをブロックしていないか確認します。
  • ブラウザが自動的に起動しない場合は、コールバック URL を手動で開きます。

ヘッドレスまたはリモートエージェントが認証に失敗する

リモートまたはヘッドレスエージェント (クラウドホスト型 Codex など) は、ブラウザベースの認可ステップを完了できません。
  • 対処方法: 代わりにツールのデスクトップ版を使用してください。

npx コマンドが見つからない

コマンドが「not found」エラーで失敗する場合、npx がシステムパス上で利用可能であることを確認してください。Node.js バージョン 5.2 以降には、デフォルトで npx が含まれています。