How to Set Up the Google Analytics MCP for Claude and GA4

Analyst working with an AI assistant and an analytics dashboard on two screens

The Google Analytics MCP is Google's official open-source server that lets an AI assistant such as Claude run reports on your GA4 properties from a chat window. You ask which landing pages lost organic sessions last month. Claude calls the Google Analytics Data API with your own credentials and answers from the rows it gets back.

This guide walks through the setup for Claude Desktop and Claude Code as of December 2026 and then the SEO questions worth asking once it runs. It belongs to our MCP series alongside the Search Console MCP, the Bing Webmaster MCP and the Screaming Frog MCP.

What is the Google Analytics MCP server?

Google publishes the server in the googleanalytics/google-analytics-mcp repository on GitHub and on PyPI as analytics-mcp. Version 1.1.0 shipped on November 6, 2026. It talks to two Google APIs. The Admin API answers questions about accounts, properties and configuration. The Data API runs the reports.

MCP stands for Model Context Protocol, the open standard AI clients use to call outside tools (spec at modelcontextprotocol.io). In the setup below the server runs on your own computer. Claude starts it as a local process and talks to it over standard input and output. Your Google credentials stay in a file on your machine.

The repository also documents a hosted mode for teams. The same package can run as a multi-tenant HTTP service on Cloud Run, where each person signs in with their own Google account through OAuth. That mode needs real infrastructure work and sits outside this guide.

Is the Google Analytics MCP read-only?

It is read-only by default. Google's developer page for the server describes it as a tool for read requests. The credentials you create in Step 2 carry the read-only Analytics scope, analytics.readonly.

The version 1.1.0 README adds a short list of write tools. They create property annotations, custom dimensions and key events. Each one stays off until you start the server with the --allow-write flag and sign in again with the analytics.edit scope. Reporting work needs neither.

Which tools does the GA4 MCP server expose?

Every tool in the README as of December 2026 is listed below. Write tools are marked in the last column.

ToolAPIWhat it doesMode
get_account_summariesAdminLists the accounts and properties your credentials can seeRead
get_property_detailsAdminReturns the configuration of one propertyRead
list_google_ads_linksAdminLists Google Ads accounts linked to a propertyRead
list_property_annotationsAdminLists annotations on a propertyRead
list_key_eventsAdminLists the key events (formerly conversions) on a propertyRead
get_custom_dimensions_and_metricsDataLists custom dimensions and custom metricsRead
run_reportDataRuns a standard report with the dimensions, metrics and dates you chooseRead
run_realtime_reportDataRuns a realtime reportRead
run_funnel_reportData (v1alpha)Runs a funnel reportRead
run_conversions_reportData (v1alpha)Reports ad costs, conversions, ROAS and attribution modelsRead
create_property_annotationAdminAdds an annotation to a propertyWrite
create_custom_dimensionAdminCreates a custom dimension (needs the Editor role)Write
create_key_eventAdminMarks an event as a key event (needs Marketer or Editor)Write

Two of them, the funnel and conversions tools, call the alpha version of the Data API. The server's reporting code sends both through the v1alpha client. Treat their output as early-access data. Check it against the GA4 interface before it goes into a client report.

What you need before you start

  • Python 3.10 or higher plus pipx. Google's page also accepts uv as the runner. Check your version with python3 --version.
  • The gcloud CLI, which creates your credentials. Google's install guide covers every operating system.
  • A Google Cloud project where you're allowed to enable APIs.
  • Viewer access or higher on the GA4 property for the account you'll sign in with. Google's help page on managing Analytics users shows where to grant it.
  • Claude Desktop or Claude Code. Local MCP servers run in the desktop app and the CLI. The browser version of Claude can't start them.

Step 1. Enable the Analytics Admin and Data APIs

Open your project in the Google Cloud console. Enable the Google Analytics Admin API and the Google Analytics Data API. The server needs both. Google's page gives one terminal command that enables the pair.

gcloud services enable analyticsadmin.googleapis.com \
  analyticsdata.googleapis.com \
  --project=YOUR_PROJECT_ID

Write down the project ID. It goes into the client config as GOOGLE_CLOUD_PROJECT in Step 3.

Step 2. Create Application Default Credentials

The server signs in with Application Default Credentials (ADC), the standard way Google's client libraries find credentials on a machine. The quickest route uses your own Google account. Run the command below and approve the scopes in the browser window it opens.

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

In the README, this command is paired with a --client-id-file flag. That flag points at an OAuth desktop client you create in the same project, as described in Google's Manage OAuth Clients help page. Google's developer page lists it as optional.

When the login completes, gcloud prints a line that starts with Credentials saved to file followed by a path. Copy that full path. On macOS and Linux it usually ends in .config/gcloud/application_default_credentials.json inside your home folder.

Teams and scheduled jobs are better served by a service account. Add the service account's email as a Viewer on the GA4 property first. Then point GOOGLE_APPLICATION_CREDENTIALS at its JSON key. Impersonation through gcloud auth application-default login --impersonate-service-account works too. Our Search Console MCP guide walks through the same pattern for GSC.

Step 3. Connect it to Claude Desktop

Claude Desktop reads local servers from claude_desktop_config.json. The file lives at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS and at %APPDATA%\Claude\claude_desktop_config.json on Windows. Add this block under mcpServers.

{
  "mcpServers": {
    "analytics-mcp": {
      "command": "pipx",
      "args": ["run", "analytics-mcp"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
        "GOOGLE_CLOUD_PROJECT": "YOUR_PROJECT_ID"
      }
    }
  }
}

Replace both placeholders. Write the credentials path in full, starting from the root of the drive. Google's troubleshooting notes that many MCP hosts don't expand ~ or $HOME inside JSON config files.

Claude Desktop is a GUI app and often misses the PATH your terminal uses. If the server never starts, run which pipx in a terminal and paste the full result into "command", for example /opt/homebrew/bin/pipx. Quit Claude Desktop completely and reopen it. The config loads on startup.

Step 4. Connect it to Claude Code

Google's developer page gives one command that registers the server in Claude Code.

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

The --scope user flag makes the server available in every project on your machine. Everything after the double dash is the command Claude Code runs to start the server. Confirm the registration with claude mcp list. Inside a session, /mcp shows the server's status. Both are documented in the Claude Code MCP docs.

Already set up Claude Desktop? The command claude mcp add-from-claude-desktop imports the server from that config. The docs limit the import to macOS and Windows Subsystem for Linux.

Step 5. Check the connection

Start with prompts that need no property ID. Ask Claude what the analytics-mcp server can do. Then ask it to list your Google Analytics accounts and properties. The second prompt calls get_account_summaries. A list of properties with their numeric IDs means the whole auth chain works.

Keep those IDs in a note. Naming the property in each prompt saves Claude a lookup. It also stops the model from picking the wrong property when one login sees several clients.

What can you ask the Google Analytics MCP?

Google's own sample prompts start simple, with questions like "How many users did I have yesterday?" SEO questions work better when the prompt names the GA4 fields. Claude then builds the report you meant on the first try. The field names below come from the Data API schema.

QuestionPrompt to pasteTool it calls
Which organic landing pages are slippingFor property 123456789, show sessions and keyEvents by landingPagePlusQueryString where sessionDefaultChannelGroup is Organic Search. Compare the last 28 days with the 28 days before.run_report
How much traffic AI assistants sendFor property 123456789, list sessions by sessionSource for the last 90 days where the source contains chatgpt, perplexity, gemini or copilot.run_report
Whether tracking is set up the way you thinkWhat custom dimensions and key events are configured on property 123456789?get_custom_dimensions_and_metrics, list_key_events
Whether a launch is getting visits right nowShow active users by page title right now on property 123456789.run_realtime_report
Which ad accounts feed the propertyList the Google Ads links on property 123456789.list_google_ads_links

SEO workflows that pay for the setup

Organic landing page decay check

Run the first prompt in the table every month. Ask Claude to sort the result by the absolute drop in sessions and keep the top twenty pages. For each page on that list, pull clicks and average position from the Search Console MCP in the same conversation.

The pairing tells you where the loss happened. Falling clicks point at rankings or click-through rate. Steady clicks with falling key events point at the page itself.

AI referral tracking

Prompt two gives you a monthly count of visits from assistant domains. It's a floor. Our AI search measurement guide explains why a large share of AI-referred visits lands in Direct with no referrer at all. For a permanent fix, build the custom channel group described in our GA4 measurement framework and ask the MCP to report on that channel.

Property hygiene before reporting day

Ask for the key events, custom dimensions and Google Ads links on every property you report on. A missing key event or a broken Ads link is much cheaper to catch before the monthly report than after a client asks about it.

Limits to know before you trust the numbers

The server reads GA4 and nothing else. Search Console clicks need the GSC MCP. Ad spend and search terms need the Google Ads MCP unless that cost data is already imported into GA4.

Claude chooses the dimensions and metrics for every report. Some GA4 fields can't be combined in one request. The Data API has a compatibility check for that reason. When a question needs incompatible fields, the model may split it into several reports and join the results itself. Expand the tool calls in Claude and read the request before you quote a joined number.

Every report spends tokens from the property's Data API quota. As of December 2026 a standard property gets 200,000 core tokens per day and 40,000 per hour. A long agent session on a large property can hit the hourly cap.

Recent days are still being processed. Google's data freshness page explains the delay. Compare closed periods when the numbers matter.

Troubleshooting the GA4 MCP

Most of these come straight from Google's own troubleshooting list and the repository's TROUBLESHOOTING.md.

SymptomLikely causeFix
403 PERMISSION_DENIEDAn Analytics API is disabled in the project, or the account lacks property accessEnable both APIs in the project named in GOOGLE_CLOUD_PROJECT. Grant at least Viewer on the property.
Request had insufficient authentication scopesADC was created without the Analytics scopeRerun gcloud auth application-default login with both scopes from Step 2
403 ACCESS_NOT_CONFIGURED or a missing quota projectUser credentials need a quota project with the APIs enabledSet GOOGLE_CLOUD_PROJECT in the config, or run gcloud auth application-default set-quota-project YOUR_PROJECT_ID
401 UNAUTHENTICATED or credentials file not foundThe path uses ~ or $HOME, or user credentials expiredUse the full path. Rerun the login command.
spawn pipx ENOENT or uvx: command not foundThe desktop app can't see your shell's PATHPut the output of which pipx in "command"
Failed to resolve analyticsadmin.googleapis.com on a MacThe default gRPC resolver fails behind some VPNs and split DNSAdd GRPC_DNS_RESOLVER=native to the server's environment
A write tool is missingThe server started without --allow-writeAdd the flag and the analytics.edit scope only if you need writes

Once GA4, Search Console and your crawler all answer in the same chat, most of a monthly SEO report becomes a short conversation. Our guide to using Claude for SEO covers the guardrails for that kind of work. If you want the measurement plan behind the numbers, see how we approach search measurement.

Want this for your brand

See where your brand stands in AI answers today, benchmarked against your competitors, no pitch required.