GA4 Analytics MCP V3
GA4 Analytics MCP V3
真正的 Model B 连接器:一个 MCP 操作员可以拥有多个独立的 Google OAuth 连接。每个 GA4 查询都使用有权访问该资源的 Google 凭据执行。
这是一个新应用程序。它不修改 V2,也不使用 Firestore (default)(保留给 V1)。
本地开发
cd D:\MCP_Servers\Ga4McpV3
npm install
copy .env.example .env.local
# Fill secrets. Set FIRESTORE_DATABASE_ID=ga4-mcp-v3 (never (default)).
npm test
npm run dev应用:
http://localhost:3000MCP:
http://localhost:3000/mcp健康检查:
http://localhost:3000/health
Related MCP server: GA4 MCP Server
Claude 自定义连接器
URL: https://<v3-host>/mcp
Claude 启动 MCP OAuth 2.1(与 V2 流程相同)。
首次 Google 登录会初始化一个内部
operatorId。之后,从连接页面或
ga4_start_google_connection连接其他 Google 账户。MCP JWT 的
sub始终是operatorId,绝不是 Google OpenID 的sub。
连接第二个或第三个 Google 账户
在 Claude 中,调用 ga4_start_google_connection 并打开返回的 URL。或者在授权期间使用连接页面上的连接另一个 Google 账户。每次授权都是一个独立的 OAuth 身份。
属性路由
property_id → this operator's ga4_properties row → connection_id → encrypted refresh token → GA4 API服务器绝不会使用当前浏览器的 Google 登录、Claude 电子邮件或属性名称来选择凭据。
操作员隔离
操作员 A 无法通过猜测 connectionId 来加载操作员 B 的连接。每次敏感操作都会在服务器端检查所有权。
Cloud Run
.\scripts\cloud-run-setup.ps1 -ProjectId YOUR_PROJECT_ID
.\scripts\cloud-run-deploy.ps1 -ProjectId YOUR_PROJECT_ID
.\scripts\cloud-run-set-env.ps1 `
-ProjectId YOUR_PROJECT_ID `
-AppBaseUrl https://YOUR_V3_CLOUD_RUN_URL `
-GoogleClientId ... -GoogleClientSecret ... `
-McpTokenSecret ... -OauthStateSecret ... -TokenEncryptionKey ...首次使用前,创建一个命名的 Firestore 数据库 ga4-mcp-v3。使用与 V1/V2 不同的独立 Google OAuth Web 客户端。
文档
This server cannot be deployed
Maintenance
Related MCP Connectors
OAuth MCP for Google, Meta, X, LinkedIn, Reddit, TikTok, GSC, GA4, WordPress and GHL.
Operate secure JoinLayer data pipelines through delegated OAuth.
Multi-tenant GSC data fetcher for AI agents. OAuth secured.
Multiple Google accounts (Gmail, Calendar, Drive, Contacts, Tasks) in one Claude connector.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Google Analytics APIs to fetch reports, manage properties, data streams, conversion events, and custom dimensions/metrics through OAuth2 authentication.144 npm6MIT
- FlicenseAqualityDmaintenanceEnables interaction with Google Analytics 4 to manage accounts, run standard or realtime reports, and validate event parameters. It supports dual authentication methods and integrates with GTM for end-to-end data collection orchestration.8-
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to securely manage Google Workspace services (Gmail, Calendar, Drive, Sheets, Contacts) with persistent multi-account OAuth. Uses OS keychain for credential storage with health monitoring and granular business rules for enterprise security.-
- FlicenseNot gradedqualityDmaintenanceEnables multi-user access to Google Workspace services (Gmail, Calendar, Docs, Sheets, Slides, Drive) via remote MCP with OAuth 2.1 authentication.-