GA4 Analytics MCP
Allows querying Google Analytics 4 properties, including listing properties, retrieving metadata for dimensions and metrics, running historical reports, and accessing real-time data (last ~30 minutes).
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GA4 Analytics MCPHow many users did I have yesterday?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GA4 Analytics MCP
Personal Google Analytics 4 connector for Claude.ai Custom Connectors. One Google account, one MCP server, deployed on Vercel.
Claude.ai Custom Connector
→ https://<VERCEL_PROJECT_NAME>.vercel.app/ga4mcp
→ Vercel Streamable HTTP MCP
→ Google Analytics Data API
→ your GA4 propertiesThere is no local stdio server, no npx requirement, and no claude_desktop_config.json.
Two authentication layers stay separate:
Claude → MCP: MCP OAuth (CIMD / DCR / optional Advanced Settings client)
MCP → Google: Google OAuth refresh token stored in
GOOGLE_REFRESH_TOKEN
MCP tools
Tool | Purpose |
| Discover properties on the connected Google account |
| List valid dimensions and metrics |
| Historical GA4 reports |
| Last ~30 minutes |
Local development
npm install
copy .env.example .env.localFill in .env.local, then:
npm run devApp:
http://localhost:3000MCP:
http://localhost:3000/ga4mcpGoogle OAuth:
http://localhost:3000/oauth/googleHealth:
http://localhost:3000/health
npm test
npm run buildClaude.ai cannot reach localhost. Deploy to Vercel before adding the Custom Connector.
Google Cloud setup
This is only so the MCP server can read your GA4 data. It is not the Claude.ai connector OAuth client.
Create or select a Google Cloud project.
Enable Google Analytics Data API.
Enable Google Analytics Admin API.
Configure the OAuth consent screen (External for personal Gmail). Publish to Production so refresh tokens do not expire after 7 days.
Create a Web application OAuth client.
Authorized redirect URIs:
http://localhost:3000/oauth/google/callbackhttps://<VERCEL_PROJECT_NAME>.vercel.app/oauth/google/callback
Scope used by this app:
https://www.googleapis.com/auth/analytics.readonlyCopy the client ID and secret into environment variables.
Then visit /oauth/google, enter MCP_AUTH_TOKEN, and sign in with the Google account that owns your GA4 properties.
Locally the refresh token is written to
.env.local.On Vercel, paste
GOOGLE_REFRESH_TOKENinto project env vars and redeploy.
Environment variables
Variable | Required | Purpose |
| Yes | Public origin, no trailing slash. Production: |
| Yes | Google OAuth web client |
| Yes | Google OAuth web client secret |
| No | Defaults to |
| Yes | Operator setup token for Google OAuth and Claude MCP consent |
| After Google OAuth | Long-lived Google token |
| No | Signs Google OAuth state cookies |
| No | Signs MCP access/refresh JWTs. Defaults to |
| No | Only if using Claude.ai Advanced Settings confidential client |
| No | Pair for the optional confidential client |
Vercel
npm i -g vercel
vercel
vercel --prodAdd the environment variables in the Vercel project. After the first Google OAuth on production, set GOOGLE_REFRESH_TOKEN and redeploy.
Disable Deployment Protection / Vercel Authentication on production. Claude.ai connects from Anthropic's network (160.79.104.0/21). If Vercel SSO sits in front of /ga4mcp, the connector cannot connect.
Production URLs:
https://<VERCEL_PROJECT_NAME>.vercel.app/ga4mcp
https://<VERCEL_PROJECT_NAME>.vercel.app/oauth/google/callback
https://<VERCEL_PROJECT_NAME>.vercel.app/healthA custom domain is optional later. Keep using APP_BASE_URL so no code change is required.
Claude.ai Custom Connector
Deploy to Vercel and confirm
https://<VERCEL_PROJECT_NAME>.vercel.app/healthreturns{"status":"ok"}.Connect Google at
https://<VERCEL_PROJECT_NAME>.vercel.app/oauth/google.Put
GOOGLE_REFRESH_TOKENin Vercel env and redeploy.In Claude.ai open Customize → Connectors → Add custom connector.
Name:
GA4 AnalyticsURL:
https://<VERCEL_PROJECT_NAME>.vercel.app/ga4mcpLeave Advanced OAuth Client ID / Secret empty. Claude uses CIMD against this server's authorization endpoints.
Click Add.
Enable the connector in the chat + → Connectors menu.
The first GA4 tool call shows a Connect card. Enter
MCP_AUTH_TOKENon this app's consent page (not your Google password).Ask: How many users did I have yesterday?
initialize and tools/list are public so Claude can discover tools. tools/call returns HTTP 401 with WWW-Authenticate until MCP OAuth completes.
Security
Never log Google tokens, authorization codes, client secrets, or MCP JWTs.
MCP tools never return secrets.
Google access tokens are not stored; only
GOOGLE_REFRESH_TOKENpersists in env vars.Do not put secrets in Git.
Dates
Passed to GA4 unchanged: today, yesterday, 7daysAgo, 30daysAgo, 90daysAgo, or YYYY-MM-DD. The date dimension comes back as YYYYMMDD.
Known limitations
One Google account and one refresh token.
Vercel cannot write env vars at runtime; paste
GOOGLE_REFRESH_TOKENand redeploy.Google Testing-mode refresh tokens expire after about 7 days.
Realtime data is roughly the last 30 minutes.
Report size is capped at 10,000 rows.
I cannot complete the live Claude.ai click-through from this repository; that requires your Claude and Vercel accounts.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Official Microsoft MCP Server to query Microsoft Entra data using natural language
GibsonAI MCP server: manage your databases with natural language
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/devopsbrandmirchi/Ga4McpServer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server