gsc-ga4-mcp
gsc-ga4-mcp
Claude Code に Google Search Console と GA4 への読み取り専用アクセスを提供する、小さなローカル MCP サーバーです。さらに、これら 2 つのデータセットを横断するいくつかのツールも含まれます。
問題
AI アシスタントでの SEO 作業は、通常、Search Console から CSV をエクスポートし、GA4 からも CSV をエクスポートし、両方をチャットに貼り付けることを意味します。そして、新しい数字が欲しくなるたびに同じことを繰り返します。また、2 つのデータセットは自動的には対応しません。Search Console はインプレッション、クリック数、CTR を把握し、GA4 はセッション、エンゲージメント、コンバージョンを把握します。「トラフィックはあるのに無駄にしているページ」を特定するには、URL で手動で結合する必要があります。
Google は Analytics 向けの公式 MCP サーバーを公開していますが、Search Console には対応していません。コミュニティ製の Search Console サーバーもありますが、データがクライアントのものである場合、他者のサーバーを信頼するより、全体を読み取れる小さなラッパーを自分で実行する方が良いでしょう。
このサーバーは、公式の Google API を読み取り専用スコープで、自分のマシンから直接呼び出します。
Related MCP server: SCMCP
機能
stdio で動作する MCP ツールが 20 個あります。
Search Console
ツール | 目的 |
| 現在の認証情報で見えるサイト |
| 独自のディメンションとフィルターを指定できる生の |
| 指定期間の上位クエリ |
| 指定期間の上位ページ |
| クエリ × ページの内訳 |
| 単一 URL のインデックス状態 |
GA4
ツール | 目的 |
| アカウントとプロパティのサマリー |
| 独自のディメンションと指標を指定した生の |
| セッション / ページビュー数上位のページ |
| ソース / メディア別のセッション数 |
| エンゲージメント指標を含むランディングページ |
| イベント数 |
| 直近 30 分間のアクティビティ |
複合分析
ツール | 目的 |
| 両 API を一括で調べ、クイックウィンとリライトに分類する |
| GSC のページと GA4 のページを URL パスで結合する |
| 順位は取れているがクリックを獲得できていないページ |
| クリックは得ているが訪問者を失っているページ |
| パフォーマンスが低下したページ |
構成
project_mappings と project_lookup は、プロジェクト名やクライアント名を GSC プロパティと GA4 プロパティに対応付けるローカルファイルを読み取ります。これにより、properties/123456789 を覚えて使う代わりに、「example.com の GSC と GA4 を掛け合わせて」という指示ができます。
スタック
Node.js + TypeScript。サーバ部は @modelcontextprotocol/sdk、認証は google-auth-library、ツールスキーマは zod。データベースなし、ホスティングバックエンドなし、テレメトリなし。プロセスはローカルで実行され、Claude Code が stdio を介して起動します。
スコープは読み取り専用で、これが権限の全容です。
https://www.googleapis.com/auth/webmasters.readonlyhttps://www.googleapis.com/auth/analytics.readonly
認証情報はリポジトリの外に置き、既定では ~/.config/gsc-ga4-mcp/ に保存されます。
セットアップ
1. インストール
git clone https://github.com/YOUR_USER/gsc-ga4-mcp.git
cd gsc-ga4-mcp
npm install
npm run build
mkdir -p ~/.config/gsc-ga4-mcp2. API を有効にする
Google Cloud Console でプロジェクトを作成または選択し、次を有効にします。
Google Search Console API
Google Analytics Data API
Google Analytics Admin API
3. OAuth 認証情報を作成する
API とサービス → OAuth 同意画面 で、同意画面を設定します。管理しているプロパティが 1 つの Google Workspace にすべて入っていなければ、外部(External)を選択し、アプリがテスト中は自分のメールアドレスをテストユーザーに追加します。
API とサービス → 認識情報 で、種類を デスクトップ アプリ に指定して OAuth クライアント ID を作成し、JSON をダウンロードして ~/.config/gsc-ga4-mcp/oauth-client.json として保存します。
クライアントごとに権限を分離したい場合は、代わりにサービスアカウントを使い、そのメールアドレスを読み取りアクセス権を持つ各 GSC プロパティと GA4 プロパティに追加します。GOOGLE_AUTH_MODE=service_account を設定し、GOOGLE_SERVICE_ACCOUNT_KEY_FILE にキーを指定します。
4. 設定
cp .env.example .env
cp projects.example.json ~/.config/gsc-ga4-mcp/projects.json.env 内のパスは絶対パスにする必要があります。~ は展開されません。
GOOGLE_AUTH_MODE=oauth
GOOGLE_OAUTH_CREDENTIALS_FILE=/Users/YOUR_USER/.config/gsc-ga4-mcp/oauth-client.json
GOOGLE_TOKEN_PATH=/Users/YOUR_USER/.config/gsc-ga4-mcp/token.json
GOOGLE_OAUTH_REDIRECT_URI=http://127.0.0.1:3000/oauth2callback
PROJECTS_CONFIG=/Users/YOUR_USER/.config/gsc-ga4-mcp/projects.json
MCP_DEFAULT_GSC_SITE=sc-domain:example.com
MCP_DEFAULT_GA4_PROPERTY=properties/123456789
MAX_ROWS=25000プロジェクトマッピング(projects.json):
{
"projects": [
{
"name": "My Site",
"client": "Internal",
"domain": "example.com",
"gscSiteUrl": "sc-domain:example.com",
"ga4Property": "properties/123456789",
"notes": "Replace with the real GA4 property ID."
}
]
}5. 承認
npm run authスクリプトは 127.0.0.1:3000 でループバックリスナーを起動し、Google の URL を表示します。URL を開いて読み取り専用スコープを承認すると、トークンは GOOGLE_TOKEN_PATH に書き込まれます。
6. Claude Code に登録する
claude mcp add google-seo -- node /ABSOLUTE/PATH/TO/gsc-ga4-mcp/dist/index.js
claude mcp listまたは、ツールを使い、プロジェクトに .mcp.json をチェックインします(.mcp.example.json を参照)。
{
"mcpServers": {
"google-seo": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/gsc-ga4-mcp/dist/index.js"],
"env": {
"GOOGLE_AUTH_MODE": "oauth",
"GOOGLE_OAUTH_CREDENTIALS_FILE": "/Users/YOUR_USER/.config/gsc-ga4-mcp/oauth-client.json",
"GOOGLE_TOKEN_PATH": "/Users/YOUR_USER/.config/gsc-ga4-mcp/token.json",
"PROJECTS_CONFIG": "/Users/YOUR_USER/.config/gsc-ga4-mcp/projects.json",
"MCP_DEFAULT_GSC_SITE": "sc-domain:example.com",
"MCP_DEFAULT_GA4_PROPERTY": "properties/123456789"
}
}
}
}パスやプロパティの初期値をリポジトリに置きたくない場合は、CLI 登録を使用します。
Claude Code での使い方
通常の日本語で質問してください。Claude がツールを選択します。
Use gsc_list_sites and ga4_list_properties. Give me a table of the GSC sites
and GA4 properties I can reach.Analyse organic traffic for sc-domain:example.com over the last 90 days using
gsc_top_queries and gsc_top_pages.Cross GSC and GA4 for example.com over the last 90 days. Find pages with high
impressions and low CTR, and rank the opportunities by likely impact.Run seo_opportunity_report and group the output into quick wins, pages that
need a rewrite, and pages that miss search intent.Inspect https://www.example.com/page/ with gsc_url_inspection and tell me
whether Google has it indexed.運用上の注意
.env、token.json、projects.json、サービスアカウントのキーはバージョン管理から除外してください。同梱の.gitignoreにすでに含まれています。クライアントのアナリティクスデータは機密情報です。クライアントが承認していないツールへ完全な出力を貼り付けないでください。
契約が終了したら、トークンまたはサービスアカウントを失効させます。
MAX_ROWSはレスポンスサイズを制限します。返答が扱いにくくなる場合は減らしてください。
トラブルシューティング
Claude Code がツールを表示しない。
claude mcp listを実行し、Claude Code 内で/mcpを使動かします。OAuth トークンのエラー。
npm run authを再実行し、GOOGLE_TOKEN_PATHが絶対パスであることを確認します。access_denied。 アプリがテスト中は、OAuth 同意画面で自分のメールアドレスをテストユーザーとして追加してください。GSC にドメインが表示されない。 認証情報にその正確なプロパティへのアクセス権が必要です。
sc-domain:example.comとhttps://www.example.com/は別物のプロパティです。GA4 プロパティが表示されない。 ユーザーまたはサービスアカウントに、アカウントまたはプロパティの少なくとも閲覧者(Viewer)権限が必要です。
gsc_url_inspectionが失敗する。inspectionUrlがsiteUrlの内部にある必要があり、URL プレフィックスプロパティは/で終わる必要があります。GA4 の指標が無効です。 公式の GA4 ディメンション名と指標名を使ってください。
runReportはそれ以外を拒否します。
リファレンス
ライセンス
MIT です。LICENSE を参照してください。
Available Tools
20 toolscompare_gsc_ga4_pagesC
Join GSC page performance with GA4 landing-page engagement.
Inputs: endDate (required), startDate (required), siteUrl, property, +1 more.
content_refresh_candidatesC
Rank pages that may deserve a content refresh based on GSC opportunity and GA4 engagement.
Inputs: endDate (required), startDate (required), siteUrl, property, +1 more.
find_high_impression_low_ctr_pagesC
Find GSC pages with high impressions and low CTR.
Inputs: endDate (required), startDate (required), maxCtr, siteUrl, +2 more.
find_pages_with_clicks_but_low_engagementC
Find pages with GSC clicks but weak GA4 engagement.
Inputs: endDate (required), startDate (required), siteUrl, property, +3 more.
ga4_eventsC
GA4 events by event name.
Inputs: endDate (required), startDate (required), limit, property.
ga4_landing_pagesD
GA4 landing pages with engagement metrics.
Inputs: endDate (required), startDate (required), limit, property.
ga4_list_propertiesA
List GA4 accounts and property summaries visible to the credentials.
Inputs: no named parameters.
ga4_realtimeD
GA4 realtime active users report.
Inputs: limit, metrics, property, dimensions.
ga4_run_reportC
Run a raw GA4 Data API report.
Inputs: endDate (required), metrics (required), startDate (required), dimensions (required), +3 more.
ga4_top_pagesC
Top GA4 pages by views, users, and sessions.
Inputs: endDate (required), startDate (required), limit, property.
ga4_traffic_sourcesB
GA4 traffic sources by default channel group and source/medium.
Inputs: endDate (required), startDate (required), limit, property.
gsc_list_sitesA
List Google Search Console sites visible to the current credentials.
Inputs: no named parameters.
gsc_query_page_matrixC
GSC query/page matrix for finding page-level keyword opportunities.
Inputs: endDate (required), startDate (required), siteUrl, rowLimit.
gsc_search_analyticsD
Run a raw Search Console Search Analytics query.
Inputs: endDate (required), startDate (required), type, siteUrl, +3 more.
gsc_top_pagesC
Top GSC pages by clicks/impressions.
Inputs: endDate (required), startDate (required), siteUrl, rowLimit.
gsc_top_queriesC
Top GSC queries by clicks/impressions.
Inputs: endDate (required), startDate (required), siteUrl, rowLimit.
gsc_url_inspectionA
Inspect Google index status for a URL under a GSC property.
Inputs: inspectionUrl (required), siteUrl, languageCode.
project_lookupB
Find a local project mapping by project name, client, or domain.
Inputs: nameOrDomain (required).
project_mappingsB
List local domain/client mappings from PROJECTS_CONFIG.
Inputs: no named parameters.
seo_opportunity_reportC
Compact SEO opportunity report combining high-impression/low-CTR and low-engagement candidates.
Inputs: endDate (required), startDate (required), siteUrl, property, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 20 tools
Several tools overlap heavily: gsc_search_analytics is a raw query tool but gsc_top_queries, gsc_top_pages, and gsc_query_page_matrix are just specialized versions of it. Similarly, ga4_run_report overlaps with ga4_top_pages, ga4_traffic_sources, ga4_landing_pages, and ga4_events, while the final four SEO opportunity tools substantially duplicate one another in purpose.
Naming is mostly consistent with service prefixes (gsc_, ga4_) followed by descriptive topic or verb_noun forms like list_sites and run_report. Minor inconsistencies exist, such as project_mappings/project_lookup using a different pattern and the verb-less gsc_search_analytics, but overall the convention is predictable.
20 tools is on the heavier side, but the server intentionally covers two analytics platforms plus cross-platform analysis, so the count is defensible. A few of the derived report tools are redundant enough that the set could be trimmed, but it does not feel bloated beyond reason.
The toolset covers the core read-only SEO workflow well: GSC site listing, raw and curated search analytics, URL inspection, GA4 property/report access, and cross-platform opportunity analysis. Minor gaps exist, such as no GSC sitemap or index-request tools and no GA4 audience or funnel reports, but the raw query tools provide a workaround.
Related MCP Connectors
Read-only Google Ads, GA4 and Search Console data for Claude, with no Google Cloud setup.
SEO research, Search Console, GA4 and PPC tools for Claude and ChatGPT.
Google Search Console, GA4, Bing Webmaster and PageSpeed MCP for Claude, ChatGPT, Cursor. Free.
GA4, Google Ads and Search Console in Claude. Read-only OAuth, multi-account for agencies.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables Claude to access Google Search Console data including search performance, URL indexation, sitemaps, and built-in SEO analysis tools such as trending queries, cannibalization detection, and traffic drop diagnostics.10-
- FlicenseNot gradedqualityDmaintenanceEnables users to securely connect Claude to their own Google Search Console data, providing custom SEO analyses such as quick wins, content decay, and cannibalization, plus optional BigQuery bulk export, with per-user token scoping and read-only tools.-
- AlicenseBqualityBmaintenanceEnables Claude Desktop to analyze Google Search Console performance, diagnose traffic drops and indexing issues, and run technical SEO checks such as robots.txt, redirects, HTTPS, DNS, Core Web Vitals, and crawl stats using read-only Google APIs and local server logs.44MIT
- AlicenseAqualityBmaintenanceEnables Claude to query Google Search Console, Google Ads, and Bing Webmaster Tools in read-only mode, returning SEO and SEA metrics and comparisons through natural-language requests without exporting CSVs.10MIT