Google Analytics MCP logo

Google Analytics MCP

by dhawalshah

Query GA4 properties through MCP with standard reports, custom dimensions, realtime users, and experimental funnel analysis.

Install Google Analytics MCP

Run the project’s own setup commands, in order.

Setup steps from the project

dhawalshah/google-analytics-mcp installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    git clone https://github.com/dhawalshah/google-analytics-mcp
    
  2. 2. Run
    cd google-analytics-mcp
    
  3. 3. Install
    pip install -r requirements.txt
    
  4. 4. Configure
    cp .env.example .env       # fill in values
    
  5. 5. Sign in
    python setup_local_auth.py
    

Overview

dhawalshah/google-analytics-mcp connects MCP clients to Google Analytics 4 properties through local STDIO or a shared Cloud Run deployment. It exposes tools for traffic, users, events, devices, sources, realtime activity, metadata discovery, custom reports, and experimental funnel analysis. Use local mode for a single-machine setup, or remote mode when Claude Teams, claude.ai, or multiple users need authenticated access. Google OAuth handles sign-in, while remote deployments store user credentials and bearer-token mappings in Firestore.

Use cases

  • Analyze page views and active users across a date range
  • Compare traffic sources, devices, or event activity
  • Inspect realtime visitors during a live campaign
  • Discover valid GA4 dimensions before building a report
  • Measure drop-off across a multi-step funnel

Key features

  • Local STDIO deployment
  • Cloud Run remote deployment with OAuth
  • GA4 property and metadata discovery
  • Custom metric and dimension reports
  • Realtime users from the last 30 minutes
  • Experimental funnel analysis

Tools10

What Google Analytics MCP lets your agent do. Expand a tool for its parameters.

Self-reported~169 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

Last commit11d agoMost recent push to the default branch.
Tools exposed10Callable tools this server registers over MCP.

How Google Analytics MCP works

What dhawalshah/google-analytics-mcp does

dhawalshah/google-analytics-mcp provides an MCP interface to Google Analytics 4. An MCP-compatible client can use it to inspect accessible accounts and properties, query common GA4 reporting dimensions, check current activity, discover valid metadata, and construct custom reports.

The reporting tools cover page views, active users, events, traffic sources, and device categories. Realtime queries return active users from the previous 30 minutes. run_funnel_report analyzes drop-off across multiple steps in a user flow and is marked experimental and v1alpha. run_report accepts arbitrary GA4 metric and dimension combinations, making it suitable when the predefined reports are not enough.

How it works

Two deployment modes are available. Local STDIO runs server.py as a subprocess launched by the MCP client. Before using it, setup_local_auth.py opens a Google sign-in flow and saves the resulting token at ~/.config/google-analytics-mcp/token.json. This mode does not require Cloud Run or Firestore.

Remote HTTP mode deploys the service to Cloud Run and exposes the MCP endpoint at /mcp. It implements the MCP authorization specification dated 2025-06-18 and provides OAuth metadata, dynamic client registration, and an authorization flow backed by Google OAuth. After authentication, the service issues its own opaque bearer token; Google credentials remain on the server and are associated with the authenticated user. Firestore stores the bearer tokens and per-user Google credentials.

Setup and configuration

The prerequisites are Python 3.10 or newer, a GA4 property, and a Google Cloud project. The Google Analytics Data API and Google Analytics Admin API must be enabled. OAuth credentials use a web application client, with callback URLs configured for local authentication and, when applicable, the Cloud Run service.

Install the Python dependencies with pip install -r requirements.txt. Local mode requires OAUTH_CONFIG_PATH and MCP_USER_EMAIL in the MCP client configuration, followed by python setup_local_auth.py. Remote mode requires a public BASE_URL, a GCP project for Firestore, and either GOOGLE_CLIENT_ID plus GOOGLE_CLIENT_SECRET or OAUTH_CONFIG_PATH. ALLOWED_DOMAINS can restrict sign-in to selected email domains.

For remote use, deploy the service to Cloud Run, add its live /auth/callback URL to the Google OAuth client, and register https://YOUR-SERVICE-URL.run.app/mcp in the client. A Cloud Run secret is recommended for the Google client secret.

Tools and capabilities

  • list_properties discovers accessible GA4 accounts and properties.
  • get_page_views, get_active_users, and get_events query core reporting data.
  • get_traffic_sources reports sessions and users by source and medium.
  • get_device_metrics breaks down sessions and page views by device category.
  • get_realtime_users reads active users from the last 30 minutes.
  • get_property_metadata lists valid dimensions and metrics.
  • run_report builds custom GA4 reports.
  • run_funnel_report measures multi-step user-flow drop-off experimentally.

Limitations and notes

Access depends on the signed-in Google account's permissions on the GA4 property. External OAuth consent applications in testing mode require users to be added as test users. Remote deployments require Firestore and appropriate Cloud Run service-account access. The older ?user=email URL approach is not used; authentication occurs through the OAuth flow.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Google Analytics MCP

dhawalshah/google-analytics-mcp is an MCP server that connects AI clients to Google Analytics 4 properties. Its main tools list accessible properties, query page views, users, events, traffic sources, and devices, retrieve realtime users and metadata, run custom reports, and analyze funnel drop-off.

Install it by cloning the repository, entering its directory, and running `pip install -r requirements.txt`. Then configure Google Cloud APIs and OAuth credentials. Local users run `setup_local_auth.py`; remote users deploy the service to Cloud Run and configure its callback URL.

Yes, it works with Claude Desktop in both local and remote modes. Local mode launches `server.py` through the desktop MCP configuration, while remote mode uses the Cloud Run `/mcp` URL and completes OAuth when the connection is first used.

Deploy the server to Cloud Run, add its `/auth/callback` URL to the Google OAuth client, and add the `/mcp` URL as a custom connector in Claude Teams. The organization owner adds the connector once, and each member authenticates with Google on first use.

Enable both the Google Analytics Data API and the Google Analytics Admin API in the Google Cloud project. The server also requires OAuth scopes for Analytics access, including the analytics and analytics.readonly scopes.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewGoogle Analytics MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/dhawalshah-google-analytics-mcp?style=directory)](https://allmcps.com/mcp/dhawalshah-google-analytics-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/dhawalshah-google-analytics-mcp"><img src="https://allmcps.com/api/badge/dhawalshah-google-analytics-mcp?style=directory" alt="Google Analytics MCP on AllMCPs" /></a>