Google Analytics MCP server on Cloudflare Workers
Provides read access to Google Analytics 4 data, enabling tools to run reports, list properties, retrieve custom dimensions, and manage annotations.
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., "@Google Analytics MCP server on Cloudflare Workerswhat are my top pages by pageviews?"
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.
Google Analytics MCP server on Cloudflare Workers
A Model Context Protocol server that gives
MCP clients (Claude, Gemini CLI, etc.) read access to Google Analytics 4 data,
running as a Cloudflare Worker instead of the local pipx run analytics-mcp
process from the original
googleanalytics/google-analytics-mcp
project.
Because a Worker can't run gcloud/Application Default Credentials the way a
local process can, this port authenticates with a GCP service account key
stored as a Cloudflare secret: the Worker signs its own JWT (via the Workers
Web Crypto API) and exchanges it for a Google OAuth2 access token on each
cold start.
The button above clones this repo into your own GitHub account, provisions a new Worker on your Cloudflare account, and wires up auto-deploy on every push. It does not set the
GA_SERVICE_ACCOUNT_KEY/MCP_LOGIN_PASSWORDsecrets or create theOAUTH_KVnamespace for you — you still need to complete the Google Cloud setup below and steps 3 (KV namespace) and 4 (secrets) before the server can actually reach Google Analytics or let anyone sign in.
Tools exposed
Same 9 tools as the original server, called via the GA4 Data API and Admin API REST endpoints directly:
Tool | What it does |
| List every GA account/property the service account can see |
| Config details for one GA4 property |
| Google Ads accounts linked to a property |
| Annotations (e.g. release/campaign notes) on a property |
| Custom dimension/metric definitions on a property |
| Core historical report ( |
| Last ~30 minutes of activity ( |
| Funnel analysis ( |
| Report scoped to specific conversion actions ( |
date_ranges, dimension_filter, metric_filter, and order_bys use the
Data API's own camelCase REST JSON shapes directly (e.g.
{"fieldName":"country","stringFilter":{"value":"United States"}}) rather
than the snake_case Python proto kwargs the original server used — see the
FilterExpression reference.
Related MCP server: google-ads-mcp-worker
1. Google Cloud setup
You'll need a GCP project with the Analytics Admin API and Analytics Data API enabled, and a service account granted read access to your GA4 properties. None of this can be done on your behalf from here — a Google Cloud project and Google Analytics account access are tied to your Google identity.
Create (or pick) a GCP project.
gcloud projects create wigwam-ga-mcp --name="Wigwam GA MCP" gcloud config set project wigwam-ga-mcpEnable the required APIs.
gcloud services enable analyticsadmin.googleapis.com analyticsdata.googleapis.comCreate a service account and a JSON key for it.
gcloud iam service-accounts create ga-mcp-reader \ --display-name="GA4 MCP read-only" gcloud iam service-accounts keys create ga-mcp-key.json \ --iam-account=ga-mcp-reader@wigwam-ga-mcp.iam.gserviceaccount.comga-mcp-key.jsonis a secret — don't commit it. You'll paste its contents into a Cloudflare secret in step 3 below, then delete the local file.Grant the service account access to your GA4 properties. This step happens in the Google Analytics UI, not GCP, since GA4 property access isn't an IAM role:
Go to analytics.google.com → Admin → Property Access Management (or Account Access Management to grant it across every property in the account at once).
Click + → Add users.
Enter the service account's email (
ga-mcp-reader@wigwam-ga-mcp.iam.gserviceaccount.com).Assign the Viewer role. Uncheck "Notify new users by email" (service accounts can't read email).
2. How auth works: a real OAuth 2.1 login, one shared password
Clients like claude.ai's and Claude Desktop's "Add custom connector" flow
expect a remote MCP server to speak OAuth 2.1 (dynamic client registration,
an authorization redirect, a token exchange) — they don't support pasting in
a static bearer token. So this server implements that flow using
@cloudflare/workers-oauth-provider:
/register,/token— handled entirely by the library (dynamic client registration + code-for-token exchange), no code needed./authorize— a login page this repo implements (src/oauth-handler.ts): it asks for one password (MCP_LOGIN_PASSWORD), and on success callscompleteAuthorization()to issue the client a token.There's only one login for everyone (no per-user accounts) since every caller ends up using the same GA service account regardless of who signed in — the password just gates who's allowed to add the connector at all.
OAuthProvider stores registered clients and issued grants/tokens in a Workers KV namespace (
OAUTH_KV), created in step 3 below.
3. Create the KV namespace
npx wrangler kv namespace create OAUTH_KVThis prints an id. Paste it into wrangler.jsonc's kv_namespaces entry,
replacing the placeholder string.
4. Local development
npm install
cp .dev.vars.example .dev.vars
# edit .dev.vars: paste the service account JSON as GA_SERVICE_ACCOUNT_KEY,
# and set MCP_LOGIN_PASSWORD to whatever password you want to sign in with
npm run devwrangler dev will print a local URL; MCP clients can connect to
http://localhost:8787/mcp and will be sent through the /authorize login
page on first connection.
5. Deploy to Cloudflare
npx wrangler login # first time only
npx wrangler secret put GA_SERVICE_ACCOUNT_KEY # paste the full JSON key contents
npx wrangler secret put MCP_LOGIN_PASSWORD # the password you'll type in at /authorize
npm run deployWrangler will print the deployed URL, e.g.
https://wigwam-google-analytics-mcp.<your-subdomain>.workers.dev.
6. Connect an MCP client
Point your client at the /mcp URL, e.g.
https://wigwam-google-analytics-mcp.<your-subdomain>.workers.dev/mcp. Since
this is now a real OAuth flow, clients that support remote connectors (the
claude.ai and Claude Desktop "Add custom connector" UI, for example) can add
it directly from just that URL — no manual header configuration needed. The
first connection will redirect to the /authorize login page; enter the
MCP_LOGIN_PASSWORD you set above.
For clients that use a config file with a raw url field instead of a UI
(some Claude Desktop versions, Claude Code's .mcp.json), the same URL
works the same way — the client handles the OAuth redirect/token exchange
itself:
{
"mcpServers": {
"google-analytics": {
"url": "https://wigwam-google-analytics-mcp.<your-subdomain>.workers.dev/mcp"
}
}
}An SSE-transport endpoint is also available at /sse for clients that don't
yet support Streamable HTTP.
Project layout
src/
index.ts MCP server definition (tool schemas) + OAuthProvider wiring
oauth-handler.ts The /authorize login page and completeAuthorization() call
ga-client.ts fetch() wrappers for the GA Admin API and Data API
auth.ts Service-account JWT signing + Google OAuth2 token exchange
wrangler.jsonc Worker/Durable Object/KV configurationTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
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
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Cloudflare Workers MCP server: api-composition-gateway
Cloudflare Workers MCP server: api-perf-analyzer
Cloudflare Workers MCP server: api-flow-analyzer
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables LLM applications to query and analyze Google Analytics 4 data through standard MCP interfaces, supporting service account and OAuth2 authentication.524MIT
- AlicenseNot gradedqualityBmaintenanceRemote MCP server for the Google Ads API running on Cloudflare Workers. Provides read-only access to Google Ads data through GAQL, including customer listing, MCC expansion, paginated search, and resource metadata retrieval.Apache 2.0
- FlicenseNot gradedqualityCmaintenanceProvides a secure FastMCP gateway to Google Analytics Admin and Data APIs, deployable on Coolify with OAuth protection and encrypted storage.-
- FlicenseNot gradedqualityBmaintenanceMulti-operator Google Analytics 4 connector for Claude.ai Custom Connectors, hosted on Google Cloud Run, enabling authenticated GA4 reporting, property selection, and metadata queries via MCP tools.-
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/cchesebro-prog/GA_MCP_CF'
If you have feedback or need assistance with the MCP directory API, please join our Discord server