How to set up the Google Analytics MCP server in Claude


On this page
The Google Analytics MCP server, or GA4 MCP server, is a Google program that lets Claude read your Google Analytics 4 (GA4) data. Claude can then answer questions about that data in plain language. Setup takes a Google Cloud project with 2 Analytics APIs turned on and a read-only Google login. The last step adds the server to Claude Desktop or Claude Code.
GA4 is the version of Google Analytics that collects event-based data from websites and apps, as Google’s introduction to GA4 describes it. MCP is the Model Context Protocol, an open-source standard that connects AI apps to outside data and tools.
Google Analytics MCP is Google’s official server
The Google Analytics MCP server is Google’s official MCP server for GA4, and its code lives in the Google Analytics MCP repository on GitHub. Google documents setup on its developer page for the Google Analytics MCP server, last updated on November 10, 2026. The server ships as the analytics-mcp package on PyPI, the public index of Python software.
The server talks to 2 Google APIs. An API is the interface one program uses to request data from another. The Google Analytics Admin API returns account and property settings, and the Google Analytics Data API runs reports. A GA4 property is the container that holds one site’s or app’s data.
Claude Desktop, Anthropic’s Claude app for your computer, and Claude Code, Anthropic’s command-line coding tool, start the server as a program on your own computer. MCP’s architecture overview calls a server like this a local server, because it runs on the same machine as the app that uses it.
The repository’s README also describes a hosted mode. In that mode the server runs as a shared web service, and each person signs in with their own Google account. The hosted mode can also run a built-in OAuth 2.1 sign-in server. OAuth is the standard that lets an app use your account without your password.
How does the Google Analytics MCP server answer a question?
The Google Analytics MCP server answers a question by running a GA4 report for Claude and handing back the rows. Claude writes the answer from those rows.
- You ask Claude a question, such as how many users your site had yesterday.
- Claude picks a tool from the list the server shared when it connected, such as
run_report. - Claude fills in the tool’s inputs, such as a date range, dimensions and metrics.
- The server sends that request to the Analytics Data API with your Google login.
- The Data API returns rows of numbers, and the server passes them back to Claude.
- Claude reads the rows and writes the answer.
A dimension is an attribute a report groups by, such as page or country. A metric is a number the report counts, such as users or sessions.
By default the server runs on your computer and calls the Data API with the ADC login you saved.
In hosted mode the server runs on a web service such as Google Cloud Run, and each tool request carries the person’s own Google sign-in.
1Your question
How many users did my site have yesterday?
2Tool picked
get_account_summariesrun_report(picked)run_realtime_reportrun_funnel_report
3Example request
- Tool
run_report- Property
123456789- Date range
yesterdaytoyesterday- Dimensions
date- Metrics
activeUsers
4Sent with your Google login
- Login
- Application Default CredentialsYour own Google sign-in
- Scope
analytics.readonly
5Example rows
date activeUsers 20261125 1234 6Written answer
Your site had 1,234 active users yesterday.
The values in this trace are made-up examples.
Google documents 9 Google Analytics MCP tools
Google’s developer page lists 9 Google Analytics MCP server tools as of November 2026, and every one of them reads data. The Admin API backs 4 of the tools, and the Data API backs the other 5.
| Tool | API | What it returns |
|---|---|---|
get_account_summaries |
Admin API | The GA4 accounts and properties your login can access |
get_property_details |
Admin API | The settings of one property |
list_google_ads_links |
Admin API | The Google Ads accounts linked to a property |
list_property_annotations |
Admin API | The annotations, or dated notes, on a property |
get_custom_dimensions_and_metrics |
Data API | The custom dimensions and custom metrics defined for a property |
run_report |
Data API | A standard GA4 report |
run_realtime_report |
Data API | A GA4 realtime report |
run_funnel_report |
Data API | A GA4 funnel exploration report of the steps people take toward a goal |
run_conversions_report |
Data API | A conversions report with ad costs, conversions, return on ad spend and attribution models, the rules that split credit for a conversion |
The repository’s README also lists list_key_events, a 10th read tool that is on by default. It returns the key events defined on a property, and key events are GA4’s current name for conversions.
Can the Google Analytics MCP server change GA4 settings?
The Google Analytics MCP server can’t change GA4 settings in its default setup. As of November 2026, Google’s developer page says the server is for read-only requests and can’t modify your Google Analytics settings. The server’s login carries the analytics.readonly scope. An OAuth scope is the level of access a login grants an app.
The README adds 3 write tools that create annotations, custom dimensions and key events. They stay off unless the server starts with the --allow-write flag and the login carries the analytics.edit scope. The custom dimension tool also needs the Editor role on the property, and the key event tool needs the Marketer or Editor role. Google’s setup commands for Claude don’t include the flag.
On10 read tools
get_account_summariesget_property_detailslist_google_ads_linkslist_property_annotationslist_key_eventsget_custom_dimensions_and_metricsrun_reportrun_realtime_reportrun_funnel_reportrun_conversions_report
Off3 write tools
- Start flag
--allow-writeIt’s added to the command that starts the server. - Login scope
analytics.editIt’s added to the scopes of the Google login.
Both switches have to be on.
create_property_annotationAdds a dated note to a property.create_custom_dimensionAdds a custom dimension to a property.create_key_eventMarks an event as a key event.
The GA4 MCP server has 5 requirements
The GA4 MCP server needs Python, a package runner, a Google Cloud project, the gcloud CLI and access to the GA4 property. Google’s developer page lists each one.
- Python 3.10 or higher is installed on your computer.
- pipx or uv is installed, so the server can run in its own isolated Python environment.
- A Google Cloud project exists to hold the 2 Analytics APIs. A Google Cloud project is the space where Google turns APIs on and tracks their use.
- The gcloud CLI, Google Cloud’s command-line tool, is installed and initialized.
- The Google account you log in with has at least the Viewer role on the GA4 property.
Set up the Google Analytics MCP server in Claude
Setting up the Google Analytics MCP server takes 4 steps in Google Cloud and the terminal. A few more steps finish it in Claude Desktop or Claude Code. Google’s developer page also gives setup steps for Cursor and Google’s Antigravity CLI and IDE. Copy each command as written and replace the capitalized placeholders with your own values.
- Google Cloud and terminal
- Claude Desktop
- Claude Code
Each stop links to its step in the lists that follow.
-
Create or select a Google Cloud project, and note its project ID.
-
Enable the Google Analytics Admin API and the Google Analytics Data API in that project.
gcloud services enable analyticsadmin.googleapis.com \ analyticsdata.googleapis.com \ --project=YOUR_PROJECT_ID -
Log in with Application Default Credentials (ADC) and the 2 scopes Google lists, analytics.readonly and cloud-platform. ADC is the login file Google’s software looks for on your computer.
gcloud auth application-default login \ --scopes="https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform" -
Copy the file path the command prints after “Credentials saved to file”. Use the full absolute path, because many MCP apps don’t expand
~or$HOMEinside JSON config files.
A service account can log in for you in step 3. A service account is a Google login made for software. Google’s developer page covers both its JSON key file and its impersonation command.
How do you connect Google Analytics MCP to Claude Desktop?
You connect Google Analytics MCP to Claude Desktop by adding the server to Claude Desktop’s config file and restarting the app.
-
Open
claude_desktop_config.json. The file sits at~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS and%APPDATA%\Claude\claude_desktop_config.jsonon Windows. Claude Desktop also opens it from Settings, then Developer, then Edit Config, as MCP’s guide to connecting local servers shows. -
Add the server, with your credentials path and project ID in place of the placeholders. If the file already has an
mcpServersblock, add theanalytics-mcpentry inside it.{ "mcpServers": { "analytics-mcp": { "command": "pipx", "args": ["run", "analytics-mcp"], "env": { "GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON", "GOOGLE_CLOUD_PROJECT": "YOUR_PROJECT_ID" } } } }With uv installed, Google’s Cursor example sets
"command"to"uvx"and"args"to["--from", "analytics-mcp", "google-analytics-mcp"]. -
Quit Claude Desktop completely and open it again, so it loads the new config and starts the server.
-
Check the connection in the Local MCP servers section of the Extensions page. You reach it from Settings, then Desktop app, then Manage next to Extensions. Anthropic’s help article on local MCP servers in Claude Desktop says that section shows each server’s status and logs.
Desktop apps often don’t inherit your terminal’s PATH, the list of folders your computer searches for programs. If the server fails with spawn pipx ENOENT, replace "pipx" with the full path that which pipx prints.
How do you add the Google Analytics MCP server to Claude Code?
You add the Google Analytics MCP server to Claude Code with one claude mcp add command.
-
Run the command with your credentials path and project ID in place of the placeholders.
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 -
Run
claude mcp listto check the server. The list shows a status such as Connected or Failed to connect next to each server.
The --scope user option makes the server available in all your projects, according to Claude Code’s MCP documentation. The -- separates Claude Code’s own options from the command that starts the server. Inside a Claude Code session, /mcp shows the same status.
Why won’t the Google Analytics MCP server connect?
Google’s developer page lists 4 common errors that stop the Google Analytics MCP server from connecting, with a fix for each.
| Error | Fix |
|---|---|
403 PERMISSION_DENIED |
Confirm both APIs are on in the project, the login has the Viewer role, and the login used both scopes. |
403 ACCESS_NOT_CONFIGURED or a missing quota project |
Set GOOGLE_CLOUD_PROJECT in the server’s env settings, or run gcloud auth application-default set-quota-project YOUR_PROJECT_ID. |
401 UNAUTHENTICATED or credentials file not found |
Use an absolute path for GOOGLE_APPLICATION_CREDENTIALS, and log in again if the credentials expired. |
spawn pipx ENOENT or uvx: command not found |
Confirm Python 3.10 or higher, and put the full path to pipx or uvx in command. |
The GA4 MCP server answers GA4 report questions
The GA4 MCP server answers questions that one GA4 report, realtime view or property setting can answer. Google’s developer page and the README give sample questions like these.
- How many users did I have yesterday?
- What were my top selling products yesterday?
- What custom dimensions and custom metrics are configured in my property?
- What are the most popular events in my Google Analytics property over the last 90 days?
- Were most of my users in the last 6 months logged in?
run_
Users yesterday
Yesterday’s active users come from one standard report.
Top products
A standard report ranks yesterday’s products by sales.
Popular events
Event counts over the last 90 days come from a standard report.
Signed-in users
A standard report can split 6 months of users by whether they signed in.
Marketing plan
The numbers behind the plan come from standard GA4 reports.
get_
Custom dimensions
This tool lists the custom dimensions and metrics set up on the property.
Claude writes it
Marketing plan
No GA4 tool writes the plan. Claude drafts it from those numbers.
Each of these maps to one tool call, such as run_report with a date range, dimensions and metrics. Google’s samples also include a request for a marketing plan on a $5,000 monthly budget. In an answer like that, the numbers come from GA4 and the plan is Claude’s own writing on top of them. When Claude adds facts from a web search, How Claude searches the web and cites sources explains where they come from.
Check GA4 MCP numbers in the GA4 interface
You check a GA4 MCP answer by rebuilding the same report in GA4 and comparing the numbers. Google’s reporting data expectations page says the date range, dimensions, metrics and filters have to match exactly.
- Ask Claude which tool it called and the exact date range, dimensions, metrics and filters it sent.
- Build the same report in GA4 with those settings.
- Compare the totals and a few rows.
- If the numbers differ, check the causes in the table below.
Adding a dimension can change a metric’s total, because fewer events may fit the narrower report. Run both reports close together.
Why do GA4 MCP numbers differ from the GA4 interface?
GA4 MCP numbers can differ from the GA4 interface because of processing time, privacy limits, sampling and how GA4 estimates unique counts. Google’s reporting data expectations page lists these causes, and the Data API marks several of them in its response.
| Cause | What happens | Where it shows |
|---|---|---|
| Processing | Recent data is still being processed, so reports pulled at different times can differ. | Reports pulled at different times |
| Sampling | runReport can return sampled data for large datasets or complex queries. |
samplingMetadatas in the Data API response |
| Thresholding | Rows with a small number of users can be removed to protect privacy. | subjectToThresholding in the Data API response |
| The (other) row | Less common values of a dimension with more than 500 unique values in a day are grouped into one “(other)” row. | dataLossFromOtherRow in the Data API response |
| Estimates | Unique counts such as active users and sessions are approximations. | Small gaps on user and session totals |
| Reporting identity | Blended and device-based identity settings count users differently. | The property’s reporting identity setting |
Google’s comparison of GA4 reporting surfaces calls a dimension with more than 500 unique values in a day a high-cardinality dimension.
Processing
MCP answer
Pulled first
1,234 active users
GA4 interface
Pulled 30 minutes later
1,241 active users
- What differs
- GA4 keeps processing recent events after they arrive. A report pulled later can show different numbers.
- What to check
- Pull the GA4 report right after Claude answers. Google describes the gaps on the newest data as minor.
Sampling
MCP answer
Sampled by the Data API
1,230 active users
GA4 interface
Sampled by the interface
1,238 active users
- What differs
- Both sides can sample a large or complex report, and each one uses its own limits and method. The 2 estimates can land a little apart.
- What to check
- Ask Claude whether the response included samplingMetadatas. That field gives the percentage of events the report used.
Thresholding
MCP answer
Report with a custom dimension
- Value A420
- Value B310
- Value CLeft out
GA4 interface
Report without that dimension
1,234 active users
- What differs
- GA4 can leave out a row with few users to protect privacy. It happens more often in reports with a high-cardinality or custom dimension. The report with the extra dimension can come back with fewer rows.
- What to check
- Ask Claude whether subjectToThresholding was true, and build the GA4 report with the same dimensions before you compare.
The (other) row
MCP answer
Page report filtered to one small page
- /small-page/No rows
GA4 interface
Page report with no filter
- /4,210
- /pricing/1,880
- (other)12,500
- What differs
- A dimension with more than 500 unique values in a day can have its less common values grouped into one (other) row. A Data API filter runs after that grouping and doesn’t look inside (other).
- What to check
- Ask Claude whether dataLossFromOtherRow was true. If it was, some values in the report were rolled into (other).
Estimates
MCP answer
Estimated by the Data API
1,234 active users
GA4 interface
Estimated by the interface
1,236 active users
- What differs
- GA4 estimates unique counts such as active users and sessions with an algorithm called HyperLogLog++, in the API and in the interface. Reports of the same users can differ slightly.
- What to check
- Treat a small gap on user or session totals as expected, and look at the other causes when the gap is large.
Reporting identity
MCP answer
Pulled after the setting changed
1,198 active users
GA4 interface
Pulled before the change
1,234 active users
- What differs
- The Data API and the GA4 interface read the same reporting identity setting for a property. User counts can differ when someone changes that setting between the 2 pulls.
- What to check
- Check whether the property’s reporting identity setting changed between the 2 reports.
The numbers and page names in each comparison are made-up examples.
GA4 agent skills pair with the MCP server
Google Analytics agent skills are instruction packs that teach an AI coding agent how to use the Analytics Data API and Admin API. An AI agent is software that works toward a goal by choosing its next step and using tools, as What is an AI agent? explains.
Google’s page on Google Analytics agent skills lists 2 skills, google-analytics-data-api-basics and google-analytics-admin-api-basics. They help an agent enable the APIs, set up credentials, check that fields work together and write client library code. Google’s developer page lists the skills as an optional add-on to pair with the MCP server. How to use Claude SEO skills covers skills in Claude more broadly, and Claude for SEO and AEO collects the rest of the Claude guides.
| Google Analytics MCP server | Google Analytics agent skills | |
|---|---|---|
| What it is | A program that runs GA4 tools | Instruction files an agent reads |
| What it gives Claude | Live account details and reports | API setup steps, field checks and client library references |
| How it installs | pipx or uvx | npx |
| What it needs | Python 3.10 or higher | Node.js |
To add the skills to Claude Code, run this command in your project folder.
npx skills add google/skills/skills/analytics --agent=claude-code
Frequently asked questions
Is there an official Google Analytics MCP server?
Yes, Google publishes the Google Analytics MCP server in its googleanalytics organization on GitHub and documents setup on its Google for Developers site.
Which apps work with the Google Analytics MCP server?
Google’s developer page gives Google Analytics MCP setup steps for Claude Desktop, Claude Code, Cursor and Google’s Antigravity CLI and IDE. Each app starts the same analytics-mcp package.
Do you need a service account for the GA4 MCP server?
No, the GA4 MCP server works with your own Google login through Application Default Credentials. A service account with Viewer access on the property is an option.