Google Analytics MCP server: set up Google's official GA4 MCP in Claude, step by step
Google's official GA4 MCP server (analytics-mcp) is read-only and runs locally. Exact setup commands for Claude Code, Claude Desktop and Cursor, the gcloud scopes that trip most people up, all seven tools, and the questions that make it useful.
GA4's interface is built for exploring, not for answering. "Did organic conversions on the pricing page go up after the redesign, compared with the same weeks last year" is four clicks per week in the UI or one sentence to an agent with the Analytics MCP server. Google's official server is read-only, well made, and quick to set up if you have a Google Cloud project. This guide covers it. Client setup is in Claude Code, Cursor and Claude Desktop.
What the official server exposes
Google's server is a Python package that wraps the two GA4 APIs. Its tools:
| Tool | What it answers |
|---|---|
get_account_summaries | Which accounts and properties the credential can see |
get_property_details | Settings for one property |
list_google_ads_links | Which Google Ads accounts the property is linked to |
get_custom_dimensions_and_metrics | Your own events and dimensions, so the agent uses the right names |
run_report | Any Data API report: dimensions, metrics, date ranges, filters |
run_funnel_report | Step-by-step drop-off through a funnel |
run_realtime_report | Activity in the last 30 minutes |
That is enough for every reporting question. It does not write, so the agent cannot change streams, events or settings.
Setup
The server is a local process, not a hosted endpoint: the PyPI package analytics-mcp, run with pipx. Four steps.
1. Enable the APIs. In a Google Cloud project, enable the Google Analytics Admin API and the Google Analytics Data API.
2. Get credentials. The server uses Application Default Credentials. For yourself, log in with the read-only Analytics scope:
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
A plain gcloud auth application-default login without --scopes is the most common reason the first call fails with a scope error. For a team or a server, create a service account instead, add its email to the GA4 property with the Viewer role, and use its key file.
3. Add it to Claude Code.
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
4. Other clients (Claude Desktop, Cursor, Gemini CLI) take the same thing as JSON:
{
"mcpServers": {
"analytics-mcp": {
"command": "pipx",
"args": ["run", "analytics-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/credentials.json",
"GOOGLE_PROJECT_ID": "your-project-id"
}
}
}
}
Start a session, run /mcp, and ask it to list your account summaries. If your properties come back, you are done.
What to ask
Give the agent the property ID once, then:
- "Sessions and conversions by default channel group for the last 28 days versus the previous 28."
- "Top 20 landing pages by organic sessions this month, with conversion rate and the change from last month."
- "Which campaigns (session campaign) drove purchases in the last 90 days, ranked by revenue?"
- "Active users right now, by country and page."
- "Engagement rate by device for the checkout funnel pages."
- "Run a funnel from landing page to form start to lead, split by device, for the last 30 days."
The model needs to know your custom dimensions and events to use them; ask it to fetch property details first, or put them in a skill so every session starts informed.
The three-server combination
GA4 tells you what visitors did. Search Console tells you what Google showed and what got clicked. Google Ads tells you what you paid for. With all three connected, one session answers "which queries and campaigns produced the sessions that converted, and what did they cost" without a data engineer.
Add Ahrefs for what you could rank for, and you have the data side of an SEO agent. The procedures, the monthly review and the weekly brief, are the skill side.
Running it for a team
A service-account key with Viewer on every property is a modest risk compared with an ads or CRM credential, but it still should not live on laptops. In a team setup it lives in a gateway that exposes the server to approved users and logs each query.
Walma AI Hub runs the Analytics server next to Search Console, Google Ads and Ahrefs inside the customer's own EU region, with one policy and one log across Claude, GPT and the agents built on them. Book a walkthrough if you want the three-server setup for your marketing team.
The rest of the marketing stack a team can connect the same way is on AI for marketing.
Frequently asked questions
Is there an official Google Analytics MCP server?+
Yes. Google publishes an official server for Google Analytics 4 on GitHub under the googleanalytics organisation. It is read-only and exposes account and property information, standard reports through the Data API, and real-time reports.
How do I set up the GA4 MCP server?+
Enable the Google Analytics Data API and Admin API in a Google Cloud project, log in with gcloud auth application-default login including the analytics.readonly scope (or use a service account with Viewer on the property), then add it to Claude Code with: claude mcp add analytics-mcp -e GOOGLE_APPLICATION_CREDENTIALS=... -e GOOGLE_PROJECT_ID=... -- pipx run analytics-mcp.
Why does the GA4 MCP server return a scope error?+
Usually because the Application Default Credentials were created without the Analytics scope. Run gcloud auth application-default login again with --scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform.
Can an AI agent change my Google Analytics settings through MCP?+
Not with the official server; it only reads. Configuration changes go through the Admin API or the UI.
What can an agent report from GA4 through MCP?+
Anything the Data API can: sessions, users, conversions and revenue by any dimension (source, medium, campaign, landing page, device, country) and date range, plus real-time active users. Combined with Search Console and Google Ads it can trace traffic from query to conversion.
The same tools, in your EU region, under your control
A 20-minute walkthrough with an engineer. We map it to your tools, your MCP servers and your budget model.