Ga4 MCP Server

Google Analytics 4 MCP: reports, realtime data, custom dimensions, data streams.

Local serverstdio

What is the Ga4 MCP server?

If you already use Ga4, the ga4 mcp server is the piece that lets your assistant work with it directly. Google Analytics 4 MCP: reports, realtime data, custom dimensions, data streams.

What the server does

  • 9 tools covering reporting, realtime data, custom dimensions/metrics, data streams, and feedback
  • Two configuration modes: single-property (env vars) and multi-client (config.json)
  • Supports both service account and OAuth credentials
  • Relative date support (today, yesterday, 7daysAgo, 30daysAgo, 90daysAgo)
  • Built on official Google SDKs with resilience patterns

Installation

mcp-ga4 on npm is all you need. Most clients run it directly, so configuration is a few lines and a restart.

Available tools

The toolset is worth reading before you wire it up, because it tells you what the integration is really for:

  • ga4_get_client_context — Returns the active GA4 property ID and client name
  • ga4_run_report — Run a standard GA4 report with dimensions, metrics, date range, and filters
  • ga4_realtime_report — Query realtime data (last 30 minutes)
  • ga4_list_custom_dimensions — List all custom dimensions for the property
  • ga4_create_custom_dimension — Create a new custom dimension
  • ga4_list_custom_metrics — List all custom metrics for the property
  • ga4_list_data_streams — List web/app data streams and their measurement IDs
  • ga4_send_feedback — Submit feedback on a query result
  • ga4_suggest_improvement — Suggest a new query pattern or improvement

Credentials and setup notes

Configuration is passed through the environment: GA4_PROPERTY_ID, GOOGLE_APPLICATION_CREDENTIALS, GA4_CLIENT_ID, GA4_CLIENT_SECRET, GA4_REFRESH_TOKEN, REFRESH_TOKEN. Treat anything key-shaped as a real credential — scope it to the minimum the server needs, and rotate it if it ever lands in a shared config.

Worth knowing first

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • With 9 tools registered it takes up a noticeable share of the context window; turn it off in projects that never touch Ga4.
  • Missing credentials fail quietly in some clients — if no tools show up, check the environment block first.
  • Keep per-call confirmation enabled while you learn its behaviour; it is the cheapest safeguard you have.

Where it fits

Plenty of developer tooling servers cover similar ground. The differences that matter in practice are scope of access and how much setup stands between you and a working tool call. Ga4's toolset — ga4_get_client_context, ga4_run_report, ga4_realtime_report and 6 more — is a fair guide to whether it matches your workflow. It is maintained by mharnett; worth a glance at recent repository activity before you build anything load-bearing on it.

We check each listing at SyncDev against the project's documentation before it goes live — if something here drifts out of date, it is a bug worth reporting.

Available tools

ToolWhat it does
ga4_get_client_contextReturns the active GA4 property ID and client name
ga4_run_reportRun a standard GA4 report with dimensions, metrics, date range, and filters
ga4_realtime_reportQuery realtime data (last 30 minutes)
ga4_list_custom_dimensionsList all custom dimensions for the property
ga4_create_custom_dimensionCreate a new custom dimension
ga4_list_custom_metricsList all custom metrics for the property
ga4_list_data_streamsList web/app data streams and their measurement IDs
ga4_send_feedbackSubmit feedback on a query result
ga4_suggest_improvementSuggest a new query pattern or improvement

How to install the Ga4 MCP server

Multi-client mode:

```json
{
  "mcpServers": {
    "ga4": {
      "command": "node",
      "args": ["/path/to/mcp-ga4/dist/index.js"]
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

VariableDescriptionRequired
GA4_PROPERTY_IDConfiguration value read at startup.Optional
GOOGLE_APPLICATION_CREDENTIALSConfiguration value read at startup.Optional
GA4_CLIENT_IDConfiguration value read at startup.Optional
GA4_CLIENT_SECRETCredential the server authenticates with.Yes
GA4_REFRESH_TOKENCredential the server authenticates with.Yes
REFRESH_TOKENCredential the server authenticates with.Yes

Example prompts to try

  • Use Ga4 to ga4 get client context.
  • Use Ga4 to ga4 run report.
  • Use Ga4 to ga4 realtime report.

Frequently asked questions

It connects Ga4 to MCP-compatible AI assistants such as Claude and Cursor, exposing 9 tools (ga4_get_client_context, ga4_run_report, ga4_realtime_report, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Ga4 directly.