Allows for the retrieval and listing of Google Ads accounts linked to specific Google Analytics 4 properties.
Provides comprehensive tools for querying Google Analytics 4 (GA4) data, including property management, report execution via the Data API, and realtime data monitoring.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GA4 MCP Servershow me a report of active users by country for the last 30 days"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GA4 MCP Server
A Model Context Protocol (MCP) server for Google Analytics 4 (GA4) that provides tools for querying GA4 data through the Admin API and Data API.
Features
Dual Authentication: Supports both OAuth Playground tokens and Service Account credentials
8 GA4 Tools:
Account and property management (Admin API)
Report execution and realtime data (Data API)
GTM → GA4 parameter validation (cross-platform orchestration)
Compatible with Claude Desktop and other MCP-enabled clients
GTM Integration: Works with GTM MCP Server for end-to-end event validation
Installation
Quick Start (OAuth Setup)
1. Create OAuth Credentials
Go to Google Cloud Console
Create a new project or select an existing one
Enable the Google Analytics Data API and Google Analytics Admin API
Go to Credentials → Create Credentials → OAuth client ID
Select Desktop app as the application type
Download or copy the Client ID and Client Secret
2. Run Setup Script
This will:
Open a browser for Google login
Request read-only access to Google Analytics
Save tokens to
~/.ga4-mcp/tokens.json
3. Use the Server
Once authenticated, you can use the MCP server with Claude Desktop or other clients.
Authentication
The server supports two authentication methods, checked in this order:
1. OAuth Playground Tokens (Recommended for personal use)
Set these environment variables:
GA4_ACCESS_TOKEN- OAuth access tokenGA4_REFRESH_TOKEN- OAuth refresh tokenGA4_CLIENT_ID- OAuth client IDGA4_CLIENT_SECRET- OAuth client secret
Or create ~/.ga4-mcp/tokens.json:
2. Service Account (Recommended for production)
Options (in priority order):
Set
GA4_SERVICE_ACCOUNT_JSONenvironment variable with JSON stringSet
GOOGLE_APPLICATION_CREDENTIALSto the JSON file pathPlace JSON file at
~/.ga4-mcp/credentials.jsonPlace JSON file in
./Credential/folder
Usage
Claude Desktop Configuration
Add to your Claude Desktop configuration (~/.config/claude-desktop/config.json):
Direct Execution
Available Tools
Admin API Tools
Tool | Description |
| List all GA4 accounts and properties the user has access to |
| Get detailed information about a specific property |
| List Google Ads accounts linked to a property |
| List annotations for a property (limited support) |
Data API Tools
Tool | Description |
| Run a standard GA4 report with dimensions, metrics, and date ranges |
| Run a realtime report for the last 30 minutes |
| Get custom dimensions and metrics defined for a property |
GTM Validation Tool
Tool | Description |
| Validate GTM event parameters against GA4 custom dimensions and data collection |
Example Usage
Get Account Summaries
Run a Report
Run Realtime Report
Validate GTM Parameters
Or with GTM Export JSON:
GTM Integration (Claude Agent Orchestration)
This server works with the GTM MCP Server to provide end-to-end validation of GTM event parameters in GA4.
Architecture
Workflow
Extract from GTM:
gtm_export_full()→ Get GA4 Event tags and parametersValidate in GA4:
ga4_validate_gtm_params()→ Check registration and collectionGet recommendations: Parameters not registered or not collecting data
Claude Desktop Configuration (Both Servers)
API Call Efficiency
Scenario | Traditional | Optimized | Reduction |
5 events × 21 params | 105 calls | 22 calls | 79% |
14 events × 32 params | 448 calls | 33 calls | 93% |
The validation tool queries metadata once, then makes one API call per unique parameter instead of per event-parameter combination.
API Documentation References
Required Google API Scopes
The server uses the following scope:
https://www.googleapis.com/auth/analytics.readonly
License
MIT