@renzo.johnson/ga4-mcp
v26.11.15
Published
GA4 Analytics MCP server for Claude Code, Cursor and any MCP client. Google Analytics 4 reports and admin, plus Search Console. mcprush.com-3d68220a1674c7ebe44e5772
Maintainers
Readme
GA4 Analytics MCP
GA4 Analytics MCP server for Claude Code, Cursor and any MCP client. Google Analytics 4 reports and admin, plus Search Console.
npx -y @renzo.johnson/ga4-mcpThe server speaks MCP over stdio. It needs Node.js 22 or newer. Prefer VS Code? Install the GA4 Analytics MCP extension: it signs you in with a wizard and registers the server with 8 AI agents.
Sign in
The server uses the first credential it finds:
- An OAuth user: set
GOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRETandGOOGLE_OAUTH_REFRESH_TOKEN. Set all three or none; a partial set stops the server with an error naming what is missing. GOOGLE_APPLICATION_CREDENTIALS: path to a service-account key or anauthorized_userJSON file.- Application Default Credentials from the gcloud CLI:
gcloud auth application-default login --scopes=https://www.googleapis.com/auth/analytics.edit,https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/indexing,https://www.googleapis.com/auth/webmastersThe OAuth refresh token (or service account) needs these scopes:
https://www.googleapis.com/auth/analytics.edithttps://www.googleapis.com/auth/analytics.readonlyhttps://www.googleapis.com/auth/indexinghttps://www.googleapis.com/auth/webmasters
Claude Code
Add it from the command line:
claude mcp add ga4-analytics -- npx -y @renzo.johnson/ga4-mcpOr add it to .mcp.json in your project (or ~/.claude.json for every project).
Cursor
Add it to ~/.cursor/mcp.json (or .cursor/mcp.json in a project).
Configuration
Claude Code and Cursor use the same JSON shape:
With Application Default Credentials (gcloud):
{
"mcpServers": {
"ga4-analytics": {
"command": "npx",
"args": [
"-y",
"@renzo.johnson/ga4-mcp"
]
}
}
}With an OAuth user:
{
"mcpServers": {
"ga4-analytics": {
"command": "npx",
"args": [
"-y",
"@renzo.johnson/ga4-mcp"
],
"env": {
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret",
"GOOGLE_OAUTH_REFRESH_TOKEN": "your-refresh-token"
}
}
}
}With a service-account key:
{
"mcpServers": {
"ga4-analytics": {
"command": "npx",
"args": [
"-y",
"@renzo.johnson/ga4-mcp"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
}
}
}
}Available Tools
Once set up, your AI agents have access to these tools:
GA4 Tools
| Tool | What It Does | Example Prompt |
|------|-------------|----------------|
| ping | Check server connectivity | "Ping the GA4 MCP server" |
| get_account_summaries | List all GA4 accounts/properties | "Show me all my GA4 properties" |
| get_property_details | Property metadata (name, timezone, currency) | "What timezone is property 371242449 set to?" |
| list_google_ads_links | Google Ads integrations for a property | "Show Google Ads links for my property" |
| run_report | Full GA4 report (dimensions, metrics, filters) | "Top 10 pages by sessions, last 7 days" |
| run_realtime_report | Live/realtime analytics data | "How many users are on my site right now?" |
| get_custom_dimensions_and_metrics | Custom dimensions/metrics for a property | "List custom dimensions for property 371242449" |
Google Search Console Tools
| Tool | What It Does | Example Prompt |
|------|-------------|----------------|
| gsc_list_sites | List all verified GSC properties | "Show me all my Search Console sites" |
| gsc_search_analytics | Query search performance (clicks, impressions, CTR, position) | "What are my top keywords for the last 28 days?" |
| gsc_inspect_url | Check index status, crawl info, mobile usability | "Is https://example.com/page indexed by Google?" |
| gsc_list_sitemaps | List submitted sitemaps and their status | "Show me the sitemaps for my site" |
Example Prompts
Show me my top 10 landing pages by sessions for the last 30 days
Compare traffic this week vs last week: sessions and pageviews by day
What are my top traffic sources? Show source/medium with sessions and bounce rate
How many active users do I have right now?
What keywords is my site ranking for? Show clicks, impressions, and average position
Which pages have the highest CTR in Google Search?
Is https://example.com/my-page indexed by Google?
Show me all submitted sitemaps and their statusPro tips:
- You don't need to know the exact API field names, just describe what you want
- The agent will figure out the right dimensions, metrics, and date ranges
- For complex reports, be specific: "sessions by country, filtered to organic traffic, last 90 days, sorted descending"
- For GSC, use your site URL as it appears in Search Console (e.g.,
https://example.com/orsc-domain:example.com)
Privacy
The server sends no telemetry. It talks only to Google APIs, with your own credentials.
Links
By Renzo Johnson | MIT License
