Google Analytics MCP server on Cloudflare Workers
Enables MCP clients to read Google Analytics 4 data, deployed as a Cloudflare Worker with service account authentication.
README
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_AUTH_TOKENsecrets for you — you still need to complete the Google Cloud setup below and run thewrangler secret putcommands in step 3 before the server can actually reach Google Analytics.
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 |
|---|---|
get_account_summaries |
List every GA account/property the service account can see |
get_property_details |
Config details for one GA4 property |
list_google_ads_links |
Google Ads accounts linked to a property |
list_property_annotations |
Annotations (e.g. release/campaign notes) on a property |
get_custom_dimensions_and_metrics |
Custom dimension/metric definitions on a property |
run_report |
Core historical report (runReport) |
run_realtime_report |
Last ~30 minutes of activity (runRealtimeReport) |
run_funnel_report |
Funnel analysis (runFunnelReport, v1alpha) |
run_conversions_report |
Report scoped to specific conversion actions (runReport + conversionSpec, v1alpha) |
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.
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-mcp - Enable the required APIs.
gcloud services enable analyticsadmin.googleapis.com analyticsdata.googleapis.com - Create 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. 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_AUTH_TOKEN to a random string
npm run dev
wrangler dev will print a local URL; MCP clients can connect to
http://localhost:8787/mcp.
3. 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_AUTH_TOKEN # a long random string
npm run deploy
Wrangler will print the deployed URL, e.g.
https://wigwam-google-analytics-mcp.<your-subdomain>.workers.dev.
Why MCP_AUTH_TOKEN?
The Worker is reachable at a public *.workers.dev URL by default. Setting
MCP_AUTH_TOKEN requires every request to include
Authorization: Bearer <token>, so a stranger with the URL can't query your
GA4 data. This is a shared-secret gate, not a full auth system — treat the
token like a password and rotate it (wrangler secret put MCP_AUTH_TOKEN) if
it ever leaks. If you need per-user login instead, that's a larger change
(3-legged OAuth with Durable Object token storage) not implemented here.
4. Connect an MCP client
For clients that support remote MCP servers over Streamable HTTP, add:
{
"mcpServers": {
"google-analytics": {
"url": "https://wigwam-google-analytics-mcp.<your-subdomain>.workers.dev/mcp",
"headers": {
"Authorization": "Bearer <MCP_AUTH_TOKEN>"
}
}
}
}
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) + Worker fetch handler
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 configuration
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。