Polynomial World

AI & LLMs

How to Connect Claude to Google Analytics 4 with MCP

Polynomial World 9 min read

You can let Claude answer questions about your GA4 data with Google’s official Analytics MCP server. It runs on your own computer, reads your data through the Google Analytics Admin and Data APIs, and cannot change your settings. Setup takes a Google Cloud project, two enabled APIs, read-only credentials, and a few lines of config in Claude Desktop or Claude Code.

Key facts (as of October 2026)

  • Google publishes the server at googleanalytics/google-analytics-mcp. The README title marks it “(Experimental)”.
  • Google says the server “is available for read requests only. It can’t edit your Google Analytics configuration or settings” (Google Analytics developer docs).
  • You need the Google Analytics Admin API and Google Analytics Data API enabled, and credentials with the analytics.readonly scope (README).
  • It needs Python 3.10 or later. Google’s README installs it with pipx (README).
  • Reports count against Data API quotas. Standard properties get 200,000 tokens per day and 40,000 per hour (Data API quotas).

What does the GA4 MCP server do?

MCP, the Model Context Protocol, lets an AI app call outside tools. Google’s server gives Claude a set of GA4 tools. Its README lists them (README):

ToolWhat it does
get_account_summariesLists the GA accounts and properties you can access
get_property_detailsReturns details about one property
list_google_ads_linksLists Google Ads links for a property
run_reportRuns a GA report through the Data API
run_funnel_reportRuns a funnel report
get_custom_dimensions_and_metricsLists a property’s custom dimensions and metrics
run_realtime_reportRuns a realtime report

Claude decides which tool to call and builds the report request for you. You ask in plain English.

The server is listed on Google’s own index of MCP servers, under open-source servers you run locally (google/mcp). It is a local server. It runs on your computer, and Claude Desktop starts it for you.

What do you need?

  • A Google account with access to the GA4 property you want to analyze. The README says the credentials must be “for a user with access to your Google Analytics accounts or properties.”
  • A Google Cloud project. A free project is enough to enable APIs.
  • The Google Cloud CLI (gcloud) on your computer.
  • Python 3.10+ and pipx, as Google documents. Or uv, which provides uvx (see Step 4).
  • Claude Desktop or Claude Code.

Step 1: Enable the two Analytics APIs

The README asks you to enable these APIs in your Google Cloud project (README):

  1. Open the Google Cloud console and select your project.
  2. Go to APIs & Services > Library.
  3. Search for Google Analytics Admin API and click Enable.
  4. Search for Google Analytics Data API and click Enable.

Google’s general guide to enabling APIs is linked from the README (Google API Console Help).

Step 2: Create an OAuth client

The simplest route for one person is an OAuth client. The README points to Google’s Manage OAuth Clients guide.

  1. In the Cloud console, go to APIs & Services > Credentials.
  2. Create an OAuth client ID of type Desktop app. You may need to configure the consent screen first.
  3. Download the client JSON file. Save it somewhere permanent, such as C:\Users\YOUR_NAME\keys\ga-oauth-client.json.

Treat this file like a password. Don’t put it in a shared folder or a Git repository.

Step 3: Create Application Default Credentials

The server uses Application Default Credentials (ADC). Run this command from Google’s README, replacing the file path (README):

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

The backslashes are line breaks for bash. In PowerShell, put the whole command on one line.

A browser opens. Sign in with the Google account that can see your GA4 property and approve access. When it finishes, gcloud prints:

Credentials saved to file: [PATH_TO_CREDENTIALS_JSON]

Copy that path. On Windows, Google Cloud’s docs say the file is stored at %APPDATA%\gcloud\application_default_credentials.json (Google Cloud docs).

The README also shows a service account impersonation option. Avoid downloading service account keys if you can. Google warns that “Service account keys create a security risk and are not recommended” (Google Cloud docs).

Why the read-only scope matters

The analytics.readonly scope only allows reading. The server’s own code also requests that read-only scope for the Admin and Data API clients (client.py). Even if Claude tried to change a setting, the credentials couldn’t.

Step 4: Add the server to Claude Desktop

Claude Desktop reads local MCP servers from claude_desktop_config.json. Open it from Settings > Developer > Edit Config. On Windows the file lives at %APPDATA%\Claude\claude_desktop_config.json (Model Context Protocol docs).

Google’s README shows the mcpServers block for Gemini. The same structure works in Claude Desktop’s config. Here is the pipx version, with placeholders:

{
  "mcpServers": {
    "analytics-mcp": {
      "command": "pipx",
      "args": ["run", "analytics-mcp"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "C:\\Users\\YOUR_NAME\\AppData\\Roaming\\gcloud\\application_default_credentials.json",
        "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
      }
    }
  }
}

In JSON, each backslash in a Windows path must be doubled.

Using uvx instead of pipx

We run it with uvx in Claude Desktop on Windows. Google documents only pipx, so treat this as an alternative, not Google’s instruction. It works because the server is published on PyPI as analytics-mcp, and uvx “invokes a tool without installing it” in a temporary, isolated environment (uv docs).

Install uv on Windows with the official PowerShell installer (uv docs):

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Then change the command and arguments:

"command": "C:\\Users\\YOUR_NAME\\.local\\bin\\uvx.exe",
"args": ["analytics-mcp"],

Using the full path to uvx.exe avoids “not found” errors, because desktop apps may not see the same PATH as your terminal. Find the path in PowerShell with Get-Command uvx.

Restart Claude Desktop

Fully quit Claude Desktop and open it again. Closing the window is not enough. Then open the + menu at the bottom left of the message box, go to Connectors, and check that analytics-mcp appears (Model Context Protocol docs).

How do you add it in Claude Code?

Google’s README gives a Claude Code command (README):

claude mcp add analytics-mcp \
  --scope user \
  -e "GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_CREDENTIALS_JSON" \
  -e "GOOGLE_PROJECT_ID=YOUR_PROJECT_ID" \
  -- pipx run analytics-mcp

--scope user makes the server available in all your projects (Claude Code docs).

What can you ask Claude?

Start with a question that confirms the setup. The README suggests: “what can the analytics-mcp server do?”

Then try questions like these. Several come from Google’s own examples (README; Google Analytics developer docs):

  • “List my GA4 accounts and properties with their property IDs.”
  • “How many users did I have yesterday?”
  • “What are the most popular events in my property in the last 180 days?”
  • “What are the custom dimensions and custom metrics in my property?”
  • “Compare sessions by default channel group for the last 28 days and the previous 28 days.”
  • “Which landing pages had the most sessions from organic search last month?”
  • “How many active users are on the site right now?” (uses the realtime report)

Ask Claude to show the dimensions, metrics, and date range it used. If a number looks off, that is usually where the difference is.

What can go wrong?

  • “Experimental” means change. Tools and behavior can change between releases. The package was at version 0.7.0 on PyPI when we checked.
  • Wrong Google account. If ADC was created with an account that can’t see the property, Claude will find no data. Rerun Step 3 with the right account.
  • APIs not enabled. Errors that mention a disabled API usually mean Step 1 was done in a different project than GOOGLE_PROJECT_ID.
  • Project ID variable name. The README text recommends a GOOGLE_CLOUD_PROJECT attribute, while its example JSON uses GOOGLE_PROJECT_ID. We use the variable from the example. If you see project errors, check this first.
  • Server doesn’t appear. Check for JSON syntax errors and absolute paths. Claude Desktop writes MCP logs to %APPDATA%\Claude\logs on Windows. Look in mcp.log and mcp-server-analytics-mcp.log (Model Context Protocol docs).
  • Recent data looks low. For standard properties, Google lists daily processing at about 12 hours and intraday at 2 to 6 hours (Analytics Help). Yesterday’s numbers may still move.
  • Quota errors. Big date ranges and many dimensions use more Data API tokens. Standard properties also allow 10 concurrent requests (Data API quotas).

Limitations

  • It reads data only. It can’t create audiences, edit events, or change property settings.
  • It covers what the Admin and Data APIs return. It doesn’t see BigQuery exports or anything outside GA4.
  • It runs locally, so it works in Claude Desktop and Claude Code on your computer, not in the claude.ai website.
  • Your GA4 data passes through Claude when you ask about it. Check that this fits your company’s data rules before connecting a client’s property.

Checklist

  • Enable the Google Analytics Admin API and Data API in one Cloud project.
  • Create a Desktop OAuth client and keep the JSON private.
  • Run gcloud auth application-default login with the analytics.readonly scope.
  • Add analytics-mcp to claude_desktop_config.json with full paths.
  • Fully restart Claude Desktop and confirm the server under Connectors.
  • Ask “what can the analytics-mcp server do?” and then list your properties.

Related articles

AI & LLMs

How to Connect Claude to Google Ads with MCP

Set up Google's official Google Ads MCP server in Claude Desktop: Cloud project, API access level, credentials, config file, and safe, read-only use.

9 min read

AI & LLMs

How to Connect Claude to Meta Ads with MCP

Connect Claude to Meta's official ads MCP server as a custom connector, sign in with Facebook, ask for reports, and keep write actions under control.

9 min read