Google Analytics MCP Server: Setup for Claude, What It Can Read, and Where It Stops
Google publishes an official MCP server for GA4. It is free and it works, and it asks you for a Google Cloud project, a command-line login and a config file. Here is the setup in order, and what the assistant can and cannot do once it is running.
Google’s official Google Analytics MCP server lets Claude read your GA4 data. It is open source, read-only by default, and runs on your own computer, so setup means a Google Cloud project, a gcloud login and a config entry. This page walks through the setup as Google documents it, covers the errors that stop most first attempts, and explains what changes when an assistant, not you, chooses the report.
What the server is
It is a Python package, analytics-mcp, published by Google under the Apache-2.0 license. It exposes GA4 through the Admin API and the Data API as tools an MCP client can call. Google’s documentation lists these read tools:
- Accounts and properties:
get_account_summaries,get_property_details,list_google_ads_links,list_property_annotations - Reports:
run_report,run_realtime_report,run_funnel_report,run_conversions_report - Schema:
get_custom_dimensions_and_metrics
The assistant picks the tool and the arguments, such as which dimensions, which metrics and which dates. That is the useful part, and it is also where numbers can go wrong, which a later section covers.
Setup, in order
- Install Python 3.10 or higher and pipx. uv works instead of pipx if you prefer it.
- Enable the two APIs in a Google Cloud project. Use a project you control. In a terminal:
gcloud services enable analyticsadmin.googleapis.com \ analyticsdata.googleapis.com \ --project=YOUR_PROJECT_ID - Give your Google account the Viewer role on the GA4 property. This is done in Google Analytics itself, under the property’s access management, not in Cloud.
- Sign in with Application Default Credentials. This asks for the read-only Analytics scope:
The command prints a line startinggcloud auth application-default login \ --scopes="https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform"Credentials saved to file:. Keep that path. - Add the server to your client. For Claude Desktop, add this to the MCP servers section of its config file:
For Claude Code, Google gives a single command instead:{ "mcpServers": { "analytics-mcp": { "command": "pipx", "args": ["run", "analytics-mcp"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON", "GOOGLE_CLOUD_PROJECT": "YOUR_PROJECT_ID" } } } }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 - Restart the client and ask a question you can check. Sessions for last month is a good one.
Where first attempts fail
- The credentials path is not absolute. Google’s notes say to avoid
~and$HOMEinGOOGLE_APPLICATION_CREDENTIALS. Paste the full path. - The desktop app cannot find pipx. Apps launched from a menu often do not inherit your shell’s PATH. Replace
pipxin the config with the full path fromwhich pipx, orwhere pipxon Windows. - No quota project. Requests made with user credentials need a project with both APIs enabled, which is the job of
GOOGLE_CLOUD_PROJECT. - Signed in as the wrong Google account. The Viewer role belongs to one account. If the login used a different one, the property list comes back empty.
When a setup like this fails, it is almost never the part you spent the afternoon on. It is the property permission that someone granted to a different login, or a time zone nobody remembers choosing. The assistant then returns a perfectly calm answer built on the wrong property or the wrong week.
So I treat the first question as a test of the plumbing, not of the assistant. One month, one metric, compared with the number GA4 already shows on its own screen. Only after that do I trust it with the interesting question.
Read-only, and the flag that changes that
Google’s documentation page says the server handles read requests only and cannot change your Analytics configuration. Its repository README goes further and lists three write tools: create_property_annotation, create_custom_dimension and create_key_event. They are off by default and need the --allow-write flag plus the analytics.edit scope. The two pages do not mention each other, so read both. For reporting, I would leave write off. An assistant that can create a key event can also create the wrong one, and a changed key event definition moves every conversion number after it.
Local, and the remote option
The configuration above runs the server as a local process, which is why it suits desktop clients and Claude Code. The README also describes starting the server with an HTTP transport so it can be shared, with Cloud Run and Docker instructions and an OAuth mode. We have not run that, and the documentation page does not cover it, so treat it as a path for an engineer, not a quick start.
What an assistant can get wrong with GA4
The server hands the assistant raw reporting, and the assistant decides how to ask for it. Three GA4 traps survive review because the answers look sensible:
- Users do not add across months. A person who visits in January and again in February is one user in each month and one user in the two-month total. If the assistant runs a report per month and adds the users, the audience is overstated. Sessions, key events and revenue do add. See GA4 AI: ask questions in plain English for the full list.
- Rates must be ratios of sums. Engagement rate is engaged sessions over sessions, summed first. Averaging daily percentages treats a 50-session day like a 5,000-session day.
- Channel groups follow your tagging. Untagged email or social traffic can land in Direct, so a channel table is a sorted view of your traffic, not an audit.
The error is a number that is too high or too flat, it reads fluently, and nobody reopens a paragraph that sounds right. That is why the one-month check from the setup matters, and why a recurring figure belongs in a definition rather than in a prompt. The same drift problem is covered for CRM data in HubSpot MCP and Claude.
Which route I would pick
- Google’s server if you are comfortable in a terminal, you want to explore one property freely, and you want funnel or real-time reports. It is the more capable route for ad hoc digging.
- A connected tool if you want the same number every month, GA4 next to your ad and Search Console data, and no Cloud project. Quiriz reads one GA4 property read-only through Google sign-in, stores 13 months in three datasets (daily traffic by channel group, monthly users, landing pages by month), keeps users separate so they are never added, and answers over its own MCP server, which you can add to Claude from the connectors directory.
For what a recurring GA4 deliverable should contain, see the GA4 report guide. For the other direction, paid clicks against analytics, see Google Ads conversions in GA4.
Ask GA4 without the Cloud project
Try a traffic question on sample data with no signup, then connect a GA4 property and ask which channel brought the most revenue last quarter.
Try Quiriz free →