0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Google Analytics MCP Server のセットアップと触ってみての感想。

Posted at

触ってみての感想は note に書いてます。
Qiita では手順周りをすこし細かく書いておきます。
https://note.com/snjssk/n/n664bd431a45e

Setup

1. Python環境の準備

# macOSの場合
brew install pipx
pipx ensurepath

# または pipでインストール
python3 -m pip install --user pipx
python3 -m pipx ensurepath

2. Google Cloud APIを有効化

Google Cloud Console で以下のAPIを有効化する。
プロジェクトに対して有効化していくため、事前に Google Cloud でプロジェクトを作成しておく必要がある。

3. 認証設定

Application Default Credentials (ADC) を設定する。
設定には以下2つも必要

  • gcloud CLI のセットアップ
  • OAuth クライアントの作成
    1. Google Cloud Console にアクセス
    2. APIs & Services > Credentials に移動(APIとサービス > 認証情報)
    3. CREATE CREDENTIALS > OAuth client IDを選択
    4. アプリケーションタイプを選択して作成
      • Desktop application (を選択した)
    5. 名前を入力して、作成されたクライアントのDownload JSONをクリック

(例)ダウンロードしたJSONファイルを~/credentials/google_cloud_oauth_client_secret.jsonに保存した場合

gcloud auth application-default login \
    --scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform \
    --client-id-file=/Users/YOUR_NAME/credentials/google_cloud_oauth_client_secret.json

* YOUR_NAME: 自身の環境に合わせてください

上記を実行後、うまくいくと設定完了画面がでてきます。

4. Gemini設定

~/.gemini/settings.json を配置する。
3で作ったADCをここで利用します、以下にファイルが作られていると思います。
~/.config/gcloud/application_default_credentials.json

{
  "mcpServers": {
    "analytics-mcp": {
      "command": "pipx",
      "args": [
        "run",
        "--spec",
        "git+https://github.com/googleanalytics/google-analytics-mcp.git",
        "google-analytics-mcp"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/Users/YOUR_NAME/.config/gcloud/application_default_credentials.json",
        "GOOGLE_CLOUD_PROJECT": "YOUR_PROJECT_NAME"
      }
    }
  },
  "selectedAuthType": "oauth-personal"
}

* YOUR_NAME: 自身の環境に合わせてください
* YOUR_PROJECT_NAME: 自身の環境に合わせてください

5. Gemini CLI インストール

好みの方法でインストールする

# Homebrew
brew install gemini-cli

# npm(グローバル)
npm install -g @google/gemini-cli

# 試用(インストール不要)
npx https://github.com/google-gemini/gemini-cli

/mcp

gemini で CLI 起動後 /mcp すると analytics-mcp がでてくる
スクリーンショット 2025-08-26 6.16.05.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?