Ga4 MCP server
Google Analytics 4 MCP: reports, realtime data, custom dimensions, data streams.
0 stars145 downloads/wk
Reviews
Write oneNobody has reviewed Ga4 yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
Ga4 tools (9, 3 write)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
ga4_create_custom_dimensionwrite actionRegister a new custom dimension in a GA4 property.
ga4_get_client_contextGet the current GA4 client context based on working directory. Call this first to confirm which GA4 property you're working with.
ga4_list_custom_dimensionsList all registered custom dimensions for a GA4 property.
ga4_list_custom_metricsList all registered custom metrics for a GA4 property.
ga4_list_data_streamsList all data streams for a GA4 property.
ga4_realtime_reportQuery GA4 Realtime Report (last 30 minutes).
ga4_run_reportwrite actionQuery GA4 historical report. Common patterns: top pages (dimensions="pagePath", metrics="screenPageViews"), traffic sources (dimensions="sessionSource,sessionMedium", metrics="sessions,totalUsers"), daily trend (dimensions="date", metrics="sessions").
ga4_send_feedbackwrite actionSend feedback about the GA4 MCP tools. Use when a query didn't work as expected.
ga4_suggest_improvementLog a GA4 query pattern that didn't work well, so it can be improved.
Public scan report
scanner v0.1.9 · 2026-09-27 · same rubric, same numbers if you re-run it
- Code scan11 source files scanned25/25
- –Live reliabilityno gateway calls yet and no remote to proben/a
- –Tool poisoningtools not inspected (local package is not executed); not countedn/a
- Auth qualitylocal package, no credentials required12/15
- Maintenancelast push 19 days ago15/15
- Maintainer identityregistry namespace matches repository owner; GitHub account older than a year8/10
How Ga4 compares
Against every graded MCP server, from our own scans and uptime checks. Updated after each scan run.
- Safety score
- 92/100
- higher than 95% of 48,255 servers
- Tools
- 9
- the typical server has 7
- Tools that change things
- 33%
- typical: 0%. Fewer write tools means less an agent can break
- Downloads a week
- 145
- more than 70% of 12,191 servers with a package
What its tools let an agent do: 6 read · 3 change
Install Ga4 in Claude Code, Cursor or VS Code
Runs npx -y mcp-ga4 on your machine. Read the scan report first; the gateway never runs local packages.
claude mcp add ga4 -- npx -y mcp-ga4
What the publisher says
From the Ga4 repository's README, as published. We do not edit it. Read it on GitHub
mcp-ga4
MCP server for Google Analytics 4 -- run reports, realtime data, custom dimensions, and property management via Claude.
Features
- 9 tools covering reporting, realtime data, custom dimensions/metrics, data streams, and feedback
- Two configuration modes: single-property (env vars) and multi-client (config.json)
- Supports both service account and OAuth credentials
- Relative date support (today, yesterday, 7daysAgo, 30daysAgo, 90daysAgo)
- Built on official Google SDKs with resilience patterns
Installation
npm install mcp-ga4Or clone the repository:
git clone https://github.com/mharnett/mcp-ga4.git
cd mcp-ga4
npm install
npm run buildAuthentication
mcp-ga4 supports two credential families. Selection is deterministic and happens once, at startup: an explicit keyfile / service account wins, then user OAuth, and if neither is configured the server exits with a loud onboarding error naming both options. There is no machine-local credentials path baked into the code and no silent runtime failover -- the only credential inputs are environment variables and (optionally) your own per-user config.json. (A later 403 therefore surfaces as the API error, not as a silent switch to the other credential family.)
Precedence: when both families are configured, the **keyfile /
service account takes precedence** over user OAuth.
Option A: Service account (recommended for unattended / server use)
Use this for any always-on or server deployment. Point GOOGLEAPPLICATIONCREDENTIALS (or config.json credentialsfile) at a JSON keyfile. The service account must be granted access on the GA4 property** (Admin → Property Access Management → add the service-account email with at least Viewer). No refresh token is involved -- the server hands the keyfile to the GA4 SDKs directly:
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.jsonThe keyfile may be a real service-account key or an authorized_user OAuth token dump -- both are accepted via the keyFile option.
Option B: User OAuth (personal / interactive use)
Use this if you want the server to act as a Google user (your own GA4 login). You bring your own Google OAuth client and mint a refresh token once.
create an OAuth 2.0 Client ID of type Desktop app. Enable the Google Analytics Data API (and the Admin API if you use the custom-dimension tools).
- In Google Cloud Console,
browser, prints the token to stdout):
- Export your client credentials and run the token helper (uses PKCE, opens a
export GA4_CLIENT_ID=... # from the Desktop-app client
export GA4_CLIENT_SECRET=...
node get-refresh-token.cjs # or: npm run authDo not redirect this command's stdout to a shared log -- the refresh
token is printed there by design.
server reads these three env vars:
- Copy the printed GA4REFRESHTOKEN=... into your environment. At runtime the
GA4_CLIENT_ID=...
GA4_CLIENT_SECRET=...
GA4_REFRESH_TOKEN=...The scope requested is read from config.json oauth.scope (see below), so the helper and the running server never disagree on what you granted.
Scopes (minimum grant)
Scopes live in config.json under oauth.scope. The committed default is:
https://www.googleapis.com/auth/analytics.readonly
https://www.googleapis.com/auth/analytics.editanalytics.edit is required because ga4createcustom_dimension mutates the property via the Admin API. If you only need read access, override oauth.scope in your own config.json to analytics.readonly alone and re-run the helper.
Configuration
Security: Never share your .mcp.json file or commit it to git -- it may contain API credentials. Add .mcp.json to your .gitignore.
Mode 1: Single Property (env vars)
Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
Ga4: common questions
- Is Ga4 MCP server safe?
- Yes, by our scan: it is graded A (92/100). Read the Ga4 safety report
- How do I install Ga4?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does Ga4 need an API key?
- No secret keys are declared. It reads 2 settings from the environment.
- Is Ga4 maintained?
- The last commit was 56 days ago (2026-09-09). The latest release is v2.0.1.
- What can I use instead of Ga4?
- Servers from other publishers that do the same job: AdLoop MCP server.
- How does Ga4 compare with other MCP servers?
- safety score 92/100 (higher than 95% of 48,255 servers); tools 9 (the typical server has 7); tools that change things 33% (typical: 0%. Fewer write tools means less an agent can break). Full comparison.
Alternatives to Ga4
Same job from other publishers: the closest match first, then the best rated.
- AdLoopGoogle Ads, Reddit Ads, GA4 and Tag Manager in your AI client, with a preview before every change.not reviewedEstablishedA