plausible-mcp
plausible-mcp
Plausible Analytics 用の MCP サーバー — Model Context Protocol をサポートする任意の AI ツールから、トラフィック、コンバージョンの照会、期間の比較ができます。
次のような質問をしたいチーム向けに作られています:
「火曜日のデプロイは /pricing へのトラフィックに影響しましたか?」
「今月の /blog のサインアップコンバージョン率は?」
「今週の直帰率は先週と比べてどうですか?」
ツール
ツール | 説明 |
| 期間ごとのトラフィックとコンバージョンメトリクス(日次/週次/月次) |
| ページ、ソース、国、デバイス、ブラウザ、OS、UTM パラメータで内訳を表示 |
| 目標コンバージョン率(ページごとの指定も可能) |
| 2 つの日付範囲を絶対値と % の差分で並べて比較 |
すべてのクエリツールは読み取り専用で、readOnlyHint: true で注釈されています。
ホスト型デプロイメントではさらに send_feedback が公開され、サーバー自体に関するフィードバック(紛らわしいエラー、不足している機能)をメンテナの Sentry User Feedback 受信トレイに送信します。これはサーバーが Sentry で実行されている場合(enableFeedbackTool)にのみ登録されます。
Related MCP server: Yandex Metrica MCP
クイックスタート
リモート(ホスト型)
ホスト型インスタンスは https://plausible-mcp.sentry.dev で利用できます。
独自の Plausible API キーを使用する場合(任意のユーザー):
claude mcp add --transport http plausible https://plausible-mcp.sentry.dev/mcp --header "Authorization: Bearer YOUR_PLAUSIBLE_API_KEY"URL を
--headerの前に置いてください。--headerは可変長引数なので、最後に置くと URL を飲み込んでしまい、CLI がerror: missing required argument 'commandOrUrl'で失敗します。
または、MCP クライアント設定(Claude Desktop、Cursor など)に手動で追加します:
{
"mcpServers": {
"plausible": {
"url": "https://plausible-mcp.sentry.dev/mcp",
"headers": {
"Authorization": "Bearer YOUR_PLAUSIBLE_API_KEY"
}
}
}
}Sentry 社員(OAuth 2.1 + Cloudflare Access 経由):
/internal エンドポイントは OAuth 2.1 サーバーです — API キーは不要です。OAuth 対応の MCP クライアント(Cowork、Claude.ai コネクタ、Claude Desktop)でリモート/カスタムコネクタとして追加してください:
https://plausible-mcp.sentry.dev/internalクライアントは OAuth エンドポイントを自動的に検出し、Sentry SSO(Cloudflare Access)を経由して認証し、@sentry.io の ID のみがアクセスを許可されます。クエリは共有のサーバーサイド Plausible API キーに対して実行されるため、キーを扱う必要はありません。
ホスト型の
/internal(plausible-mcp.sentry.dev)は Sentry 専用で、組織外では使用できません。別の組織で/internalを実行するには、セルフホスト してALLOWED_EMAIL_DOMAINを自分のドメインに設定してください。(公開の/mcp持ち込みキーエンドポイントにはそのような制限はありません。)
ローカル(STDIO)
ローカルで実行したい場合は、Node.js 20 以降を使用してください:
git clone https://github.com/getsentry/plausible-mcp.git
cd plausible-mcp
pnpm install
pnpm buildClaude Code に追加:
claude mcp add plausible -e PLAUSIBLE_API_KEY=your-key -- node /path/to/plausible-mcp/dist/index.jsまたは Claude Desktop(claude_desktop_config.json):
{
"mcpServers": {
"plausible": {
"command": "node",
"args": ["/path/to/plausible-mcp/dist/index.js"],
"env": {
"PLAUSIBLE_API_KEY": "your-key"
}
}
}
}セルフホスティング(Cloudflare Workers)
独自のインスタンスをデプロイ:
git clone https://github.com/getsentry/plausible-mcp.git
cd plausible-mcp
pnpm install
npx wrangler deployワーカーは 2 つのエンドポイントを公開します:
/mcp— 持ち込みキー。各ユーザーは独自の Plausible API キーをAuthorization: Bearerヘッダーで渡します。サーバー側で共有シークレットは不要です。ヘッダー対応の MCP クライアント(Claude Code、Cursor、MCP Inspector)で動作します。/internal— 管理コネクタ(Cowork、Claude.ai)用の Access 保護 MCP エンドポイント。Cloudflare Access アプリケーション(Managed OAuth)がワーカーのホスト名全体を前面に置きます(下記の制約を参照)。Access はクライアントとの OAuth 2.1 ハンドシェイクを実行し、各リクエストをCf-Access-Jwt-Assertionヘッダー付きでワーカーに転送します。ワーカーはそのヘッダーを検証し、共有のサーバーサイド Plausible API キーを使用してクエリを実行します。Access はALLOWED_EMAIL_DOMAIN(デフォルトはsentry.io)のメールドメインに制限されます — セルフホスト時は Sentry に関連付けられません。自分のドメインに設定してください。
Managed OAuth アプリケーションはパスなしのベアホスト名をカバーする必要があるため(OAuth を有効にすると Cloudflare はパスを拒否します — domain can not have a path if oauth is configured)、/mcp もゲートされます。持ち込みキーの /mcp エンドポイントを公開のままにするには、/mcp パスにスコープされた 2 つ目のより具体的な Access アプリケーションを Bypass ポリシーで追加します。Cloudflare は最も具体的なホスト名+パスを最初に一致させるため、/mcp リクエストは Access を完全にバイパスし、それ以外はすべて OAuth を通過します。両方のアプリは 1 つのホスト名に存在します。別のサブドメインは不要です。
ベータ版 / クライアント要件。 Cloudflare Access Managed OAuth はベータ版であり、RFC 8707(リソースインジケータ)をサポートする MCP クライアントが必要です。このパスに依存する前に、コネクタがサポートしていることを確認してください。
/internal エンドポイントの設定(Cloudflare Access Managed OAuth)
ワーカーはOAuth サーバーを実行しません — Cloudflare Access が認可サーバーです。OAUTH_KV も、クッキーキーも、OAuth クライアント ID/シークレットもありません。同じホスト名に2 つの Access アプリケーションを作成します。
ベアホスト名で Managed OAuth アプリケーションを作成(Zero Trust → Access → Applications): ドメインが
plausible-mcp.sentry.devでパスなしのセルフホストアプリまたはMCP サーバーアプリケーション。⚠️
/internalにスコープしないでください。 Managed OAuth を有効にすると、Cloudflare はパスをaccess.api.error.invalid_request: domain can not have a path if oauth is configuredで拒否します。アプリはホスト全体である必要があります。ワーカーが/internalルートを自身で強制します。メールドメイン(例:
@acme.com)と ID プロバイダーに制限する Access ポリシー(アクションAllow)を追加します。Managed OAuth を有効にし(詳細設定 → Managed OAuth)、許可されたリダイレクト URI をコネクタの実際のコールバックに設定します — Claude/Cowork の場合は
https://claude.ai/api/mcp/auth_callback。公開 HTTPS コールバックは必ずリストに含める必要があります。含めないと Dynamic Client Registration がinvalid_client_metadata: redirect_uri is not allowed by the account configurationで失敗します。ループバック(http://localhost:*)コールバックはデフォルトで許可されます。アプリケーションの AUD タグをコピー → これが
CF_ACCESS_AUDになります。
2 つ目のパススコープの Bypass アプリケーションで
/mcpを切り出します。 ステップ 1 がホスト全体をカバーするため、/mcp(持ち込みキー)もゲートされます。別のセルフホストアプリを作成し、ドメインplausible-mcp.sentry.devパスmcp、Managed OAuth オフ、ポリシーのアクションはBypass、セレクターはEveryoneにします。Bypass≠Allow:Allowポリシーは対話型ログインを強制します(クライアントはログインページへの HTML302を受け取り、Unexpected content type: text/htmlで失敗します)。Bypassのみが認証なしでリクエストを通過させ、ワーカー自身の Bearer キーチェックが適用されます。
ワーカーシークレットを設定:
npx wrangler secret put PLAUSIBLE_API_KEY # shared key for /internal queries npx wrangler secret put SENTRY_DSN # optional — the Worker's own telemetryCF_ACCESS_TEAM_DOMAINとCF_ACCESS_AUDはシークレットではありません — 公開 JWKS URL とアプリケーション識別子です。そのためステップ 4 の[vars]に入ります。wrangler.tomlの[vars]を設定:CF_ACCESS_TEAM_DOMAIN—https://<team>.cloudflareaccess.com、末尾スラッシュなし。Cf-Access-Jwt-Assertionの JWKS と発行者を検証します。CF_ACCESS_AUD— ステップ 1 でコピーした AUD タグ。ALLOWED_EMAIL_DOMAIN— サインインを許可するメールドメイン(カンマ区切り、@は省略可能、デフォルトsentry.io)。ステップ 1 の Access ポリシーに加えてコードで強制されるため、自分のドメインに設定してください — そうしないとすべてのログインが拒否されます。MCP_ALLOWED_HOSTNAMES— MCP エンドポイントが受け入れるホスト名(カンマ区切り)。plausible-mcp.sentry.devをワーカーのホスト名に置き換え、wrangler devを使用する場合は localhost エントリを維持します。MCP_ALLOWED_ORIGIN_HOSTNAMES—/internalを呼び出せるブラウザ Origin ホスト名(カンマ区切り)。非ブラウザクライアントはOriginヘッダーを送信しません。
デプロイ(
npx wrangler deploy)し、RFC 8707 対応の MCP クライアントをhttps://<your-worker-host>/internalにポイントします。
トラブルシューティング。 これらはすべて Cloudflare Access の設定であり、ワーカーではありません — リクエストがワーカー(およびその Sentry スパン)に到達するのは、Access が転送した後だけです:
症状(コネクタ内) | 原因 | 修正 |
| コネクタのコールバックが許可されたリダイレクト URI にない | 正確なコールバックを追加(ステップ 1)。拒否された |
| Managed OAuth アプリがパスにスコープされている | アプリ 1 をベアホストに再スコープ(ステップ 1) |
|
| アプリ 2 のポリシーアクションを |
|
| アプリ 2 を作成(ステップ 2) |
設定
環境変数 | 必須 | デフォルト | 説明 |
| はい(STDIO、Worker | — | あなたの Plausible API キー(こちらで取得)。Worker では |
| いいえ |
| Plausible インスタンスの URL(セルフホスト用) |
| いいえ | — | デフォルトのサイトドメイン。毎回 |
| はい(Worker | — |
|
| はい(Worker | — | Access アプリケーションの Application Audience(AUD)タグ — アサーションの |
| いいえ(Worker) | — | Worker 自身のテレメトリ用 Sentry DSN( |
| いいえ(Worker |
|
|
| はい(Worker) | — | MCP の |
| いいえ(Worker | — |
|
Worker では、/mcp エンドポイントはサーバー側キーを必要としません — 各ユーザーが Authorization: Bearer で自分のキーを渡します。/internal エンドポイントは Cloudflare Access Managed OAuth で保護され、共有のサーバー側 PLAUSIBLE_API_KEY シークレットを使用します(セルフホスティング を参照)。
Plausible API
このサーバーは Plausible Stats API v2(POST /api/v2/query)をラップしています。Plausible Cloud と セルフホスト の両方で動作します。
対応メトリクス
visitors、visits、pageviews、views_per_visit、bounce_rate、visit_duration、events、scroll_depth、percentage、conversion_rate、group_conversion_rate、average_revenue、total_revenue、time_on_page
対応ディメンション
event:page、event:goal、event:hostname、visit:entry_page、visit:exit_page、visit:source、visit:referrer、visit:channel、visit:utm_medium、visit:utm_source、visit:utm_campaign、visit:utm_content、visit:utm_term、visit:device、visit:browser、visit:browser_version、visit:os、visit:os_version、visit:country、visit:region、visit:city、visit:country_name、visit:region_name、visit:city_name
*_name の地理ディメンションは人間が読める名前(例:「カナダ」)を返します。通常の visit:country/region/city は ISO/Geoname コードを返します。
フィルタリング
すべてのクエリツールは property_filters を受け付けます。名前とは異なり、組み込みディメンションとカスタムイベントプロパティの両方でフィルタリングします。各エントリは { "property", "operator", "values" } の形式です:
property— 組み込みディメンション(例:visit:channel、visit:source、event:page)またはカスタムプロパティの素の名前("plan"はevent:props:planを対象にします)。operator—is、is_not、contains、contains_not(デフォルトはis)。event:goalはisとcontainsのみサポートします。複数のエントリは AND で結合されます。
page/goalのショートカットパラメータも同様です。同じ呼び出しでショートカットとproperty_filtersの両方からevent:page/event:goalを対象にすることは拒否されます — どちらか一方を使用してください。
例えば、オーガニック検索トラフィックの上位ページを取得する場合:get_breakdown に dimension: "event:page" と property_filters: [{ "property": "visit:channel", "values": ["Organic Search"] }] を渡します。
カスタムプロパティ
サイトは独自のカスタムイベントプロパティを送信します。これらは event:props:<name> として扱われます。サイト固有のものなので、固定リストはありません。
カスタムプロパティで分類する:
get_breakdownにevent:props:<name>のdimensionを渡します(例:event:props:plan)。カスタムプロパティでフィルタリングする:
property_filtersに素の名前を渡します。例:[{ "property": "plan", "operator": "is", "values": ["pro"] }]。
開発
pnpm install
pnpm build # TypeScript compilation
pnpm test # Run unit + integration tests
pnpm test:watch # Watch modeMCP Inspector でのテスト
pnpm build
PLAUSIBLE_API_KEY=your-key npx @modelcontextprotocol/inspector node dist/index.jsLLM 評価
自然言語の分析クエリに対してモデルが正しいツールを選択するかを検証します。OpenRouter 経由で実行されるため、任意のツール呼び出し対応モデルで動作します — デフォルトは anthropic/claude-sonnet-5 です:
OPENROUTER_API_KEY=sk-or-... pnpm eval
OPENROUTER_MODEL=openai/gpt-5 OPENROUTER_API_KEY=sk-or-... pnpm eval # try another modelアーキテクチャ
src/
├── index.ts # STDIO entry point (local use)
├── worker.ts # Cloudflare Worker entry point (remote)
├── env.ts # Worker environment bindings
├── cf-access.ts # Verifies the Cloudflare Access assertion on /internal
├── server.ts # Creates McpServer, registers all tools
├── plausible.ts # PlausibleClient — standalone API client
├── schemas.ts # Shared Zod schemas and filter helpers
├── errors.ts # UserFacingError and tool-error reporting
├── telemetry.ts # Pure classifiers — route, MCP request kind, client family
├── mcp-telemetry.ts # Records MCP client info onto the active span
├── redaction.ts # Strips PII from Sentry events on the BYOK path
└── tools/
├── get-timeseries.ts
├── get-breakdown.ts
├── get-conversions.ts
├── compare-periods.ts
└── send-feedback.tsPlausibleClient は MCP への依存がゼロで、単体で使用できます。
可観測性とデータ収集
Worker はエンドポイントに応じたプライバシーポリシーで Sentry にレポートします:
/mcp(キー持ち込み) — 完全に匿名。ツールの入力と出力は記録されません(そのデータは呼び出し元とそのキーに属します)。ID は付与されず、取り込み時に推測されたクライアント IP は削除されます(src/redaction.ts)。運用テレメトリのみが残ります:ツール名、スパンのタイミング、失敗。/internal(SSO ゲート付き) — 属性付き。リクエストには認証済みの@sentry.ioメールアドレスが付与され(Sentry.setUser)、ツールの入力/出力は共有サーバー側キーの属性追跡と不正使用トレースのために記録されます(recordToolIO)。
Authorization / Cookie / Cf-Access-Jwt-Assertion ヘッダーは、両方のパスでスパンから削除されます。念のためのバックストップとして、Sentry プロジェクトの Security & Privacy 設定で Prevent Storing of IP Addresses を有効にしてください。
ライセンス
MIT — LICENSE を参照。
Available Tools
4 toolscompare_periodsCompare PeriodsARead-onlyIdempotent
Compare metrics between two date ranges side by side. Ideal for before/after deploy analysis. period_a is the baseline and period_b is measured against it: deltas are period_b minus period_a, and percent is relative to period_a. To see how the current period changed from a prior one, pass the prior range as period_a and the current range as period_b.
Inputs: site_id (required), period_a (required), period_b (required), goal, +3 more. Returns: deltas, period_a, period_b
get_breakdownGet BreakdownBRead-onlyIdempotent
Break down metrics by a dimension: page, traffic source, country, device, etc. Use to find top pages, sources, or segment traffic.
Inputs: site_id (required), dimension (required), date_range (required), goal, +5 more. Returns: metrics, results, dimensions, pagination
get_conversionsGet ConversionsBRead-onlyIdempotent
Get goal conversion rates and counts. Can break down by page to see which pages drive conversions.
Inputs: site_id (required), date_range (required), goal, page, +2 more. Returns: metrics, results, dimensions, pagination
get_timeseriesGet TimeseriesBRead-onlyIdempotent
Get traffic and conversion metrics over time for a site or specific page. Use to spot trends and changes around deploys.
Inputs: site_id (required), date_range (required), goal, page, +3 more. Returns: metrics, results, dimensions, pagination
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct analytics purpose: dimensional breakdown, conversion goals, time series, and period comparison. There is some conceptual overlap because conversions can be segmented and trended, but the descriptions make the intended boundaries clear.
All tool names use snake_case verb_noun phrasing: get_breakdown, get_conversions, get_timeseries, and compare_periods. The get_/compare_ variation is still predictable and consistent with the action being performed.
Four tools are well scoped for a focused analytics server, with each covering a meaningful query pattern. The compact surface avoids redundancy while still supporting the core reporting workflows.
The core analytics surface is covered: breakdowns, conversions, trends over time, and period comparisons. Minor gaps remain around site/property discovery or metadata, but the main analysis workflows are supported.
Maintenance
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MCP server for marketing agencies: connect Google Ads, GA4, Search Console, Meta, LinkedIn and more to Claude or ChatGPT. Pull reports and make changes via OAuth login, no setup.
Clamp Analytics MCP server: traffic, revenue, funnels, cohorts, errors, and search, for AI agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server that provides read access to Plausible Analytics data with natural-language date resolution, enabling users to query analytics like 'yesterday' or 'last week' without needing to know exact date formats.8MIT
- AlicenseAqualityBmaintenanceMCP server for Yandex Metrica analytics: query web analytics metrics, goals, conversions, and raw API data using natural language from AI clients like Claude and Cursor.8708 npm4MIT
- AlicenseBqualityFmaintenanceMCP server for Plausible Analytics, enabling querying of traffic, conversions, sources, and device breakdowns from any MCP-compatible AI assistant.1263 npmMIT
- FlicenseBqualityDmaintenanceA read-only stdio-based MCP server that provides tools to query Plausible Analytics data, including listing sites, fetching statistics with metrics/dimensions/filters, and getting realtime visitor counts.3-