
Google Analytics 4
io.github.mindstone由 GitHub 账号 mindstone 发布v0.2.1更新于 Oct 24, 2026
Google Analytics 4 MCP server with reporting, schema discovery, and admin visibility tools
概览
Google Analytics 4 MCP 服务器,可浏览 GA4 账户与数据结构、运行报表与导出,并可选地修改媒体资源设置。
- 可以做什么
- 发现账户与媒体资源,查看币种、时区等属性详情
- 探索实时数据结构:维度、指标、分类及兼容性校验
- 运行报表:标准、透视、批量、实时与漏斗报表,含行数保护与配额查询
- 创建并分页读取大型异步报表任务与受众导出
- 查看管理配置:受众、关键事件、数据流、各类关联、数据保留与更改历史
- 开启写入后可创建、更新、归档或删除媒体资源设置、关键事件、维度、指标、受众、数据流与关联等
- 适用场景
- 适合让助手直接回答 GA4 数据问题、确认可用维度与指标、拉取大规模导出,或在不打开 GA4 界面的情况下审查和调整媒体资源配置。
- 运行要求
- 通过 npx 在本机运行,需要 Node.js 20+ 与 npm。需将 GOOGLE_APPLICATION_CREDENTIALS 设为 ADC 或服务账号 JSON 的绝对路径,并准备已启用 Analytics Admin 与 Data API 的 Google Cloud 项目及该 GA4 媒体资源的访问权限。GA4_PROPERTY_ID 可选,用作默认媒体资源。写入工具还需 GA4_ALLOW_WRITES=true、analytics.edit 权限范围及媒体资源上的编辑者角色。
安装
在 SourceWeft 中
- 打开 控制台中的 Google Analytics 4,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
@mindstone/mcp-server-google-analytics
[npm version] [License: FSL-1.1-MIT]
Google Analytics 4 MCP server for Model Context Protocol hosts. Discover account/property structure, explore the live schema, run reports (with row-volume safety), create large asynchronous exports, and inspect admin configuration through a standardised MCP interface. With writes explicitly enabled, it can also set up and change property configuration: key events, custom dimensions and metrics, audiences, channel groups, data streams, enhanced measurement, event create and edit rules, calculated metrics, annotations, attribution, Measurement Protocol secrets, product links, and data retention.
Status
- Version: 0.2.1 · npm
- Auth: OAuth via Google ADC (
GOOGLE_APPLICATION_CREDENTIALS) - Tools: 91 (accounts, schema, reporting, admin, admin writes)
- Surface: cloud-api
- Machine-readable:
STATUS.json
Requirements
- Node.js 20+
- npm
- Google Application Default Credentials (ADC) with the
analytics.readonlyscope, or a service account JSON with access to the GA4 property - For write tools:
GA4_ALLOW_WRITES=true, credentials with theanalytics.editscope, and the Editor role on the property
One-click install
[Add to Cursor] [Add to VS Code] [Add to VS Code Insiders]
After clicking the button, your host will prompt you to fill: GOOGLE_APPLICATION_CREDENTIALS.
Manual config for Claude Desktop / Claude Code / Goose / Continue.dev (Google Analytics 4)
Quick Start
Install & build
npx (once published)
Local
Authentication
This server uses Google Application Default Credentials (ADC). Mint ADC for a user account by installing the Google Cloud CLI and running:
The --client-id-file is optional but strongly recommended — using your own OAuth client avoids the shared gcloud quota and gives you a stable verification footprint. You'll need a Google Cloud project with the Google Analytics Admin API and Google Analytics Data API enabled.
For service accounts, set GOOGLE_APPLICATION_CREDENTIALS to the absolute path of the service-account JSON. The service account must be granted access to the GA4 property in the GA4 Admin UI.
Enabling writes
Write tools are registered but refuse to run (WRITES_DISABLED) unless GA4_ALLOW_WRITES=true. To use them, mint ADC with the edit scope instead:
The account (or service account) also needs the Editor role on the GA4 property. Service-account credentials request the edit scope automatically when writes are enabled; user ADC keeps whatever scope it was minted with.
Configuration
Environment variables
GOOGLE_APPLICATION_CREDENTIALS— required. Absolute path to ADC or service-account JSON. Node does not expand~or%APPDATA%— provide a fully-resolved path.GA4_PROPERTY_ID— optional. Default GA4 property ID (e.g.123456789). Tools fall back to this whenproperty_idis not passed in the call.GA4_ALLOW_WRITES— optional. Set totrue(or1) to allow the write tools to change GA4 configuration. Any other value, or unset, keeps the connector read-only.
Host configuration examples
Claude Desktop / Cursor
Local development (no npm publish needed)
Tools (91)
Account & property
ga_list_account_summaries— discover available accounts and propertiesga_list_properties— flat list of GA4 properties with optional filteringga_get_property_details— currency, time zone, industry category, service level
Schema discovery
ga_get_metadata— live property schemaga_get_property_schema— same data with summary countsga_search_schema— keyword search across dimensions and metricsga_list_dimension_categories,ga_list_metric_categoriesga_get_dimensions_by_category,ga_get_metrics_by_categoryga_check_compatibility— verify dimension/metric combinations before reporting
Reporting
ga_run_report— core report with row-volume safety (estimate, opt-in to large datasets, automatic aggregation suggestions)ga_run_pivot_report— cross-tabulated reportsga_batch_run_reports— up to 5 reports in one callga_run_realtime_report— last 30 minutes of activityga_get_property_quotas_snapshot— remaining tokens / requestsga_run_funnel_report— step-by-step completion and drop-off, with optional breakdown, next action, and trended view (v1alpha)
Large exports
ga_create_report_task— start an asynchronous report task for large exports (no synchronous timeout, no row-volume gate)ga_get_report_task— poll task state untilACTIVEga_query_report_task— page task rows (up to 250,000 per page)ga_create_audience_export— snapshot the users in an audience (incl. predictive segments); charges audience-export quota tokensga_get_audience_export— poll export state untilACTIVEga_list_audience_exports— find and reuse existing exportsga_query_audience_export— page user-level rows from anACTIVEexport
Admin visibility
ga_list_audiences— audiences configured on the property, with filter clausesga_list_channel_groups— channel groups and their grouping rulesga_get_custom_dimensions_and_metricsga_list_google_ads_linksga_list_key_eventsga_list_data_streamsga_get_global_site_tag— gtag.js snippet for the first web streamga_list_bigquery_linksga_get_data_retention_settingsga_list_firebase_linksga_search_change_history_eventsga_get_enhanced_measurement_settings— automatic events on a web streamga_list_event_create_rules— rules that derive new events on a streamga_list_measurement_protocol_secrets— secret values are returned; treat as sensitivega_list_annotations— chart annotations (v1alpha)ga_get_attribution_settings— attribution model and lookback windows (v1alpha)ga_list_calculated_metrics— formula metrics (v1alpha)ga_list_event_edit_rules— rules that rename or modify events on a stream (v1alpha)ga_get_google_signals_settings(v1alpha)ga_get_data_sharing_settings— account-level
Admin writes (require GA4_ALLOW_WRITES=true)
Every write is annotated readOnlyHint: false, destructiveHint: true. Archive, delete, acknowledgement, and data-retention tools also require confirm: true. Update tools change only the fields you pass (the update mask is built from them) and fail with NOTHING_TO_UPDATE if you pass none.
- Key events:
ga_create_key_event,ga_update_key_event,ga_delete_key_event - Custom dimensions:
ga_create_custom_dimension,ga_update_custom_dimension,ga_archive_custom_dimension - Custom metrics:
ga_create_custom_metric,ga_update_custom_metric,ga_archive_custom_metric - Audiences (v1alpha):
ga_create_audience,ga_update_audience,ga_archive_audience - Channel groups (v1alpha):
ga_create_channel_group,ga_update_channel_group,ga_delete_channel_group - Event create rules (v1alpha):
ga_create_event_create_rule,ga_update_event_create_rule,ga_delete_event_create_rule - Property:
ga_create_property,ga_update_property,ga_delete_property(moves to trash for 35 days),ga_acknowledge_user_data_collection - Data streams:
ga_create_web_data_stream,ga_update_data_stream,ga_delete_data_stream - Enhanced measurement (v1alpha):
ga_update_enhanced_measurement_settings - Measurement Protocol secrets:
ga_create_measurement_protocol_secret,ga_delete_measurement_protocol_secret - Google Ads links:
ga_create_google_ads_link,ga_update_google_ads_link,ga_delete_google_ads_link - Firebase links:
ga_create_firebase_link,ga_delete_firebase_link - BigQuery links (v1alpha):
ga_create_bigquery_link,ga_update_bigquery_link,ga_delete_bigquery_link - Data retention:
ga_update_data_retention_settings - Annotations (v1alpha):
ga_create_annotation,ga_update_annotation,ga_delete_annotation - Attribution (v1alpha):
ga_update_attribution_settings - Calculated metrics (v1alpha):
ga_create_calculated_metric,ga_update_calculated_metric,ga_delete_calculated_metric - Event edit rules (v1alpha):
ga_create_event_edit_rule,ga_update_event_edit_rule,ga_delete_event_edit_rule
Explorations, saved reports, and report layouts have no Google API, so they cannot be created or changed by this connector.
Notes
- Read-only by default. Without
GA4_ALLOW_WRITES=true, the only tools that create anything arega_create_report_taskandga_create_audience_export, which materialise server-side snapshots and charge quota without modifying property configuration. The admin write tools refuse withWRITES_DISABLEDbefore any request is sent. All of these are annotatedreadOnlyHint: false,destructiveHint: true, so hosts can gate them behind explicit user approval. - Alpha endpoints. Audiences, channel groups, BigQuery links, enhanced measurement, event create and edit rules, annotations, attribution, calculated metrics, Google Signals, the global site tag, change history (Admin API), and report tasks and funnel reports (Data API) are only exposed on Google's
v1alphasurfaces today; the corresponding tools note this in their descriptions. - Untrusted content. Text authored inside the GA4 property — report dimension values (page titles, campaign names, custom-dimension values), audience/display names, descriptions, definition blobs, data-stream stream-data blobs, the global site tag snippet, custom-metadata expressions, vendor-echoed header/dimension names, and vendor error messages — is returned inside
<untrusted-content source="…">envelopes so hosts treat it as data, not instructions. Metric values and resource identifiers stay raw so agents can compose follow-up calls. Resource IDs passed to tools are constrained to the ID charset before URL interpolation (INVALID_RESOURCE_IDon anything else). - Response validation. Every Google API response is validated against a Zod schema at the boundary; a shape mismatch fails closed with an
INVALID_API_RESPONSEerror rather than propagating malformed data. Paginated lists follownextPageTokenin full and fail withPAGINATION_LIMIT_EXCEEDEDif the API does not stop paging after a generous safety cap — never a silent truncation.
Licence
FSL-1.1-MIT — Functional Source License, Version 1.1, with MIT future licence. The software converts to MIT licence on the second anniversary of release.
来源:connectors/google-analytics/README.md,提交 9b9aa57
工具
0版本历史
1- v0.2.1最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。