Model Context Protocol for Google Analytics 4 (Data API) allowing autonomous agents to query dimensions and metrics. Gives agents analysis-ready GA4 access with schema discovery, server-side aggregation, and smart defaults.
Project description
Google Analytics 4 MCP Server
mcp-name: io.github.surendranb/google-analytics-mcp
Connect Google Analytics 4 data directly to AI agents, analyst copilots, and MCP runtimes across Claude, ChatGPT, Gemini, Cursor, VS Code, and OpenClaw. Gives models analysis-ready GA4 access with live schema discovery, metric auto-aliasing, server-side aggregation, and autonomous self-healing defenses.
🌐 Website & Documentation: https://ga4mcp.com
🔗 Sister Project: Google Search Console MCP
⚡ Quickstart — 1-Line Installations
1. NPX / Node.js (Claude Code, Cursor, VS Code, Windsurf)
Add to your MCP configuration file (claude_desktop_config.json or .cursor/mcp.json):
{
"mcpServers": {
"ga4-analytics": {
"command": "npx",
"args": ["-y", "google-analytics-mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account-key.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}
2. Gemini CLI Extension
Install directly into Google Gemini CLI with a single command:
gemini extensions install github.com/surendranb/google-analytics-mcp
3. Python uvx & Explicit python -m ga4_mcp
{
"mcpServers": {
"ga4-analytics": {
"command": "uvx",
"args": ["--from", "google-analytics-mcp", "ga4-mcp-server"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account-key.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}
Or run directly via ga4-mcp-server / python -m ga4_mcp:
{
"mcpServers": {
"ga4-analytics": {
"command": "python",
"args": ["-m", "ga4_mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account-key.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}
🧠 Why AI Agents & Marketers Prefer This Server
- Autonomous Self-Healing: System directives automatically intercept schema hallucinations (like guessing legacy metric names or incorrect filter nesting) and guide models to self-correct via
get_troubleshooting_guide. - Metric Auto-Aliasing: Automatically maps legacy or common LLM requests like
'conversions'→'keyEvents', preventing unnecessary query failures. - Server-Side Aggregation: Computes property totals dynamically for non-time-series queries, so LLMs spend time answering business questions rather than parsing raw rows.
- Data Volume Protection: Runs quick row-count estimates before executing large queries (>2,500 rows) to prevent crashing model context windows.
- Multi-Platform Support: Native packages and manifests for PyPI, npm, Gemini CLI, Smithery, OpenClaw, and OpenAPI REST actions.
🔑 Setup & Credentials Guide
1. Create a Google Cloud Service Account
- Open the Google Cloud Console.
- Enable the Google Analytics Data API.
- Under APIs & Services → Credentials, create a Service Account.
- Create a JSON Key and save it locally on your machine (e.g.
/Users/yourname/keys/ga4-key.json).
2. Grant Viewer Access in GA4
- Open Google Analytics.
- Select your GA4 Property → Open Admin (gear icon) → Property Access Management.
- Add the Service Account email (found inside the JSON key as
client_email) with the Viewer role.
3. Find Your GA4 Property ID
- In Google Analytics Admin → Property Details.
- Copy the numeric Property ID (e.g.,
123456789).
🛠️ Available Tools
| Tool Name | Purpose |
|---|---|
get_ga4_data |
Execute GA4 queries with dimensions, metrics, date ranges, and optional filters. |
search_schema |
Keyword search across 200+ GA4 dimension and metric API names. |
get_property_schema |
Inspect all available dimensions and metrics for your specific property. |
list_metric_categories |
Browse metric categories (User, Session, Revenue, Event). |
list_dimension_categories |
Browse dimension categories (Geography, Traffic Source, Device). |
get_troubleshooting_guide |
Self-healing guide for IAM permissions, setup, and filter syntax. |
🔒 Telemetry & Privacy
GA4 MCP collects anonymous telemetry (mcp_started, tool_executed) to help maintainers track release adoption, improve error defenses, and optimize latency.
- No PII, no credentials, and no GA4 property data are ever collected.
- To opt out, set the environment variable:
DISABLE_TELEMETRY=1.
📄 License & Author
Developed by Surendran B (reachsuren@gmail.com) under the Apache License 2.0.
Website: https://ga4mcp.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_analytics_mcp-2.5.0.tar.gz.
File metadata
- Download URL: google_analytics_mcp-2.5.0.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
267bae5e57b82d845d20cb1c1c3cf8018b9b52652a93375808c5a1a1b93d3057
|
|
| MD5 |
8bdc9f4c4edc8fb39f9a4835a5b9ae0f
|
|
| BLAKE2b-256 |
f0f60a215d53ca7816b3e403fe9bae73a8e36bb2df4557fcd751d123a5dac941
|
Provenance
The following attestation bundles were made for google_analytics_mcp-2.5.0.tar.gz:
Publisher:
release.yml on surendranb/google-analytics-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_analytics_mcp-2.5.0.tar.gz -
Subject digest:
267bae5e57b82d845d20cb1c1c3cf8018b9b52652a93375808c5a1a1b93d3057 - Sigstore transparency entry: 2066342349
- Sigstore integration time:
-
Permalink:
surendranb/google-analytics-mcp@4a150118b3b4bb2662928bf1c876fc6c9243a41a -
Branch / Tag:
refs/tags/v2.5.0 - Owner: https://github.com/surendranb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a150118b3b4bb2662928bf1c876fc6c9243a41a -
Trigger Event:
release
-
Statement type:
File details
Details for the file google_analytics_mcp-2.5.0-py3-none-any.whl.
File metadata
- Download URL: google_analytics_mcp-2.5.0-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b253408471f1d5b2295510fd33d68c10ab6591fb14dce92d6faa0a9554dce29
|
|
| MD5 |
32a54ffb79c9077de993999b8ceee86f
|
|
| BLAKE2b-256 |
f23327228628535c13b05fd83b19c55e19201cac824ee89ba742e28d094cad0c
|
Provenance
The following attestation bundles were made for google_analytics_mcp-2.5.0-py3-none-any.whl:
Publisher:
release.yml on surendranb/google-analytics-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
google_analytics_mcp-2.5.0-py3-none-any.whl -
Subject digest:
5b253408471f1d5b2295510fd33d68c10ab6591fb14dce92d6faa0a9554dce29 - Sigstore transparency entry: 2066342363
- Sigstore integration time:
-
Permalink:
surendranb/google-analytics-mcp@4a150118b3b4bb2662928bf1c876fc6c9243a41a -
Branch / Tag:
refs/tags/v2.5.0 - Owner: https://github.com/surendranb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a150118b3b4bb2662928bf1c876fc6c9243a41a -
Trigger Event:
release
-
Statement type: