インストール不要。2分以内に動きます。
cloud.anythingmcp.com で無料トライアルを開始し、PostHog をワンクリックで追加して、AI クライアント(Claude、ChatGPT、Copilot、Cursor)を生成された MCP エンドポイントに向けるだけ。Docker も git clone も、開発経験も不要です。
概要
AI に PostHog のプロダクト分析に関する質問に答えさせます。イベントとパーソンに対する読み取り専用 SQL(HogQL)の実行、トレンド、ファネル、リテンションの計算、保存済みのインサイトとダッシュボードの閲覧、パーソン、コホート、アノテーション、実験の参照、インサイトとフィーチャーフラグの管理ができます。PostHog Cloud(US または EU)またはセルフホスト版に、個人用 API キーで接続します。
こう聞いてみよう
PostHog のサンプルプロンプト
プロンプトをクリックでコピー。Claude / ChatGPT / Cursor / Gemini / Copilot / OpenClaw に貼り付けて、このコネクターで実行できます。
Claude は AI のため誤ることがあります。回答をご確認ください。
💡 インストール不要? cloud.anythingmcp.com を直接利用してください。 サインインし、Connectors → PostHog をクリック、認証情報を貼り付け、MCP API キーを発行すれば完了です。Docker も
git cloneもローカルサーバーも不要。
PostHog + Gemini
AI に PostHog のプロダクト分析に関する質問に答えさせます。イベントとパーソンに対する読み取り専用 SQL(HogQL)の実行、トレンド、ファネル、リテンションの計算、保存済みのインサイトとダッシュボードの閲覧、パーソン、コホート、アノテーション、実験の参照、インサイトとフィーチャーフラグの管理ができます。PostHog Cloud(US または EU)またはセルフホスト版に、個人用 API キーで接続します。
前提条件
完全なセットアップ手順はコネクタ自体に組み込まれています (ストアでコネクタを選択すると表示)。必要な環境変数:
POSTHOG_HOST, POSTHOG_PERSONAL_API_KEY
ステップ 1 — 認証情報を取得
- PostHog で Settings → User → Personal API keys を開き(US Cloud:
https://us.posthog.com/settings/user-api-keys、EU Cloud:https://eu.posthog.com/settings/user-api-keys)、+ Create a personal API key をクリックします。 - キーにラベルを付け(例: 「AnythingMCP」)、organization and project access を選びます。すべて、1 つの組織、または特定のプロジェクトから選べます。特定のプロジェクトに限定したキーでは組織やプロジェクトの一覧を取得できませんが、
posthog_get_current_userは動作し、現在のプロジェクトを確認できます。 - 次のスコープを選択します。
user:read,organization:read,project:readquery:read,person:read,cohort:read,experiment:readinsight:read,insight:write,dashboard:readfeature_flag:read,feature_flag:writeannotation:read,annotation:write
- すぐにキーをコピーします。PostHog が表示するのは一度だけです。キーは
phx_で始まります(phc_で始まるプロジェクトトークンはここでは使えません)。Bearer という語を付けずにPOSTHOG_PERSONAL_API_KEYに貼り付けます。 POSTHOG_HOSTには PostHog を開くときのアドレスを設定します。US Cloud はhttps://us.posthog.com、EU Cloud はhttps://eu.posthog.com、セルフホストの場合は自分のインスタンスのアドレスです。末尾のスラッシュやパスは付けません。インジェスト用ホストのus.i.posthog.comとeu.i.posthog.comは受け付けられず、キーは作成したクラウドリージョンでのみ有効です。その後、コネクターをインストールします。- まず
posthog_get_current_userを実行します。キーがどの PostHog ユーザーのものか、現在のプロジェクト、組織内のプロジェクトを確認できます。
読み取り専用の設定: :read スコープだけでキーを作成し、posthog_create_insight、posthog_update_insight、posthog_create_feature_flag、posthog_update_feature_flag、posthog_create_annotation をオフにします。HogQL は SELECT しか受け付けないため、クエリがデータを変更することはありません。AI が閲覧、変更できる範囲は、キーのユーザーと同じです。
インストール時にオフになっているツール: posthog_delete_insight、posthog_delete_feature_flag、posthog_delete_annotation。PostHog は API 経由で完全に削除することはなく、これらのツールはインサイト、フラグ、アノテーションに削除済みの印を付けるだけで、PostHog アプリから復元できます。削除したフラグはオフになり、そのキーを確認するコードは false を受け取ります。
プロジェクト ID: プロジェクト単位のツールはすべて project_id を受け取ります。PostHog の URL にある数字(/project/12345/...)で、Settings → Project → General にも表示されます。@current も使えますが、ユーザーがアプリで最後に開いたプロジェクトを指すため変わることがあります。数字の指定をおすすめします。ほかのプロジェクトは posthog_list_organizations と posthog_list_projects で一覧できます。
クエリ: posthog_run_hogql_query は events、persons、sessions、groups に対して HogQL(PostHog の SQL)の SELECT を 1 つ実行します。プロパティは properties.$browser や person.properties.email のように読みます。必ず時間で絞り込んでください(例: WHERE timestamp >= now() - INTERVAL 7 DAY)。絞り込まないスキャンは遅く、読み取り予算を消費します。LIMIT がなければ 100 行、指定すれば最大 50,000 行です。OFFSET は拒否されるため、AI は timestamp や id でページングします。日付はプロジェクトのタイムゾーンで解釈され、UTC ではありません。トレンド、ファネル、リテンション、スティッキネス、ライフサイクル、パスには posthog_run_insight_query を使います。コンバージョン率やリテンション率は count の値から計算します。クエリのエンドポイントはその場の分析向けで、大量エクスポート用ではありません。
インサイト、ダッシュボード、フラグ: posthog_get_insight はデフォルトで最後にキャッシュされた結果を返し、refresh blocking を指定すると古い結果を再計算します。posthog_get_dashboard はタイルとそのインサイトを返します。フィーチャーフラグは実際のユーザーに表示される内容を左右します。フラグを作成、変更する前に、AI はフラグのキー、active、ロールアウトを提示し、あなたの承認を待ちます。新しいフラグは active を false にするか、ロールアウトを 0 にするのが最も安全です。変更時には最後に読み取ったフラグの version を送るため、他の人の変更を上書きしません。
ページング: 一覧系のツールは limit と offset を受け取り、count、next(最後のページでは null)、results を返します。200 KB を超える応答は切り詰められます。
レート制限: 組織単位で適用され、すべてのキーとユーザーで共有されます。通常の読み書きは毎分 480 件、毎時 4,800 件、パーソンやインサイト計算などの分析は毎分 240 件、毎時 1,200 件です。クエリのエンドポイントは毎分 240 件、毎時 2,400 件で、同時実行はプロジェクトごとに最大 3 件、さらにプロジェクトごとの 1 時間あたりの読み取り予算を消費します(無料プランでは少なめ)。制限を超えると PostHog は 429 を返し、予算を使い切ると api_queries_budget_exceeded が返りますが、キャッシュ済みの結果は引き続き使えます。
よくあるエラー: 401 はキーが間違っている、削除された、または別のクラウドリージョンのものです。POSTHOG_HOST を確認してください。403 "API key missing required scope" は追加すべきスコープを示します(キーのスコープは後から変更できます)。それ以外の 403 は、キーが別のプロジェクトや組織に限定されているか、組織がメンバーの個人用 API キーを許可していないことを意味します。404 "Project not found." は project_id が間違っているか、ユーザーから見えないプロジェクトです。400 は無効なフィールドを示し、HogQL ではパーサーのエラーを含みます。フラグでの 409 は version が古いことを意味します。フラグを読み直してください。
このコネクターは、イベントの送信やパーソンのプロパティ設定、パーソンの削除、セッションリプレイやアンケートの閲覧、ダッシュボード、コホート、実験の作成や編集、バッチエクスポート、メンバー、請求の管理には対応していません。
ステップ 2 — アダプターをインストール
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
ステップ 3 — Gemini にコネクタを追加
サーバーURL: AnythingMCP で MCP Servers を開き、このコネクタがあるサーバーを選んで URL(
https://cloud.anythingmcp.com/mcp/…)をコピーします。このガイドでYOUR_SERVER_IDと表示されている箇所に使ってください。
Gemini CLI は ~/.gemini/settings.json(Windows では %USERPROFILE%\.gemini\settings.json)から MCP サーバーを読み込みます。次を追加してください:
{
"mcpServers": {
"anythingmcp": {
"httpUrl": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
"headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
}
}
}
- AnythingMCP の MCP Servers → 対象のサーバー → API keys で MCP API キーを作成し、
YOUR_MCP_API_KEYと置き換えます。 - ファイルを保存し、
geminiを再起動します。 - Gemini CLI で
/mcpを実行します(またはシェルでgemini mcp list)。anythingmcpが接続済みとして表示されるはずです。 - プロンプトを入力しましょう。Gemini CLI が
PostHogのツールを呼び出せるようになりました。
利用可能なツール
| Tool | What it does |
|---|---|
posthog_get_current_user | Get the user the personal API key belongs to: uuid, email and name, the current project (id, name, project_id, timezone), the current… |
posthog_list_organizations | List the organizations the user belongs to: id (a UUID), name, slug, membership_level, and each organization's projects |
posthog_list_projects | List the projects of an organization: id (the project_id every other tool takes), name, project_id, timezone, tags, is_demo and… |
posthog_get_project | Get one project's settings: name, timezone, week_start_day, base_currency, app_urls, test account filters, group types, whether events… |
posthog_run_hogql_query | Run one read-only HogQL (PostHog SQL) SELECT over events, persons, sessions, groups or warehouse tables and return columns, results (rows… |
posthog_run_insight_query | Run one of PostHog's insight calculations without saving it: TrendsQuery, FunnelsQuery, RetentionQuery, StickinessQuery, LifecycleQuery or… |
posthog_list_persons | List or search persons (identified users and anonymous visitors): id, uuid, name, distinct_ids, properties, created_at and last_seen_at.… |
posthog_get_person | Get one person by numeric id or UUID: name, distinct_ids, all person properties (email, initial UTM and referrer, geo), created_at and… |
posthog_list_insights | List saved insights (charts): id, short_id, name, description, query, tags, favorited, dashboard_tiles, created_by and last_modified_at |
posthog_get_insight | Get one insight by numeric id or 8-character short_id: name, description, query, result, columns, last_refresh, is_cached, the hogql it ran… |
posthog_create_insight | Save a new insight (chart) in the project from a query: a product analytics chart or a SQL insight |
posthog_update_insight | Change a saved insight: name, description, query, tags or favorited |
posthog_delete_insight | Delete a saved insight (PostHog marks it deleted; it disappears from every dashboard and can be restored in the app) |
posthog_list_dashboards | List dashboards: id, name, description, pinned, tags, created_by, created_at and last_viewed_at |
posthog_get_dashboard | Get one dashboard with its filters and tiles: each tile carries its insight (id, short_id, name, query and the last cached result) or a… |
posthog_list_feature_flags | List feature flags: id, key, name (the description), active, filters (release conditions with rollout_percentage, variants, payloads)… |
posthog_get_feature_flag | Get one feature flag by id: key, name, active, filters (release condition groups with properties and rollout_percentage, multivariate… |
posthog_create_feature_flag | Create a feature flag |
posthog_update_feature_flag | Change a feature flag: switch it on or off, change its rollout or targeting, rename its description, archive it or retag it |
posthog_delete_feature_flag | Delete a feature flag (PostHog marks it deleted and switches it off; code that checks the key then gets false) |
posthog_list_cohorts | List cohorts (saved groups of persons): id, name, description, count (persons in it), is_static, is_calculating, filters and created_at |
posthog_get_cohort | Get one cohort by id: name, description, its definition (filters or query), count of persons, whether it is static or behavioral… |
posthog_list_annotations | List annotations (notes on charts such as releases or incidents): id, content, date_marker, scope, the insight or dashboard they belong to… |
posthog_get_annotation | Get one annotation by id: content, date_marker, scope (project, organization, dashboard or insight), emoji, the insight or dashboard it is… |
posthog_create_annotation | Add an annotation, a note shown on charts at a point in time, e.g. a release, a campaign start or an incident |
posthog_delete_annotation | Delete an annotation (PostHog marks it deleted; it disappears from every chart and can be restored) |
posthog_list_experiments | List A/B test experiments: id, name, description, status, start_date, end_date, feature_flag_key, type, conclusion, archived and created_by |
posthog_get_experiment | Get one experiment by id: status, start and end dates, its feature flag and variants, metrics, parameters, exposure cohort, conclusion and… |
プロンプトの例
- 「先週、料金ページを訪れたユニークユーザー数を日別に、使われたブラウザーと合わせて教えてください。」
- 「過去 30 日間の登録ファネルについて、料金ページの閲覧から購入完了までのコンバージョン率を教えてください。」
- 「現在有効になっているフィーチャーフラグと、それぞれのロールアウト率を一覧にしてください。」
- 「メインプロジェクトに今日の日付でアノテーションを追加してください。内容は「春のキャンペーン開始」です。」
FAQ
Gemini CLI はどこから MCP サーバーを読み込みますか? ユーザー単位では ~/.gemini/settings.json、プロジェクト単位ではプロジェクト内の .gemini/settings.json です。gemini mcp list で各サーバーと接続状態を確認できます。
次のステップ
このガイドは役に立ちましたか?