MCP Server for Google Analytics 4
Enables running standard GA4 reports, real-time data queries, and retrieving metadata (metrics and dimensions) from Google Analytics 4 properties via the Google Analytics Data API.
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., "@MCP Server for Google Analytics 4Show me the top 5 countries by active users in the last 7 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.
MCP Server for Google Analytics 4
A Model Context Protocol (MCP) server that allows Large Language Models (LLMs) to interact with Google Analytics 4 (GA4) data through the Google Analytics Data API.
Features
Run standard GA4 reports with customizable dimensions, metrics, and date ranges
Get real-time data for the past 30 minutes
Retrieve metadata about available metrics and dimensions
Secure authentication using Google Cloud's Application Default Credentials
Configurable for easy deployment via Smithery
Related MCP server: Google Analytics MCP Server
Installation
Using pip
pip install mcp-server-ga4From source
git clone https://github.com/yourusername/mcp-server-ga4.git
cd mcp-server-ga4
pip install -e .Authentication
This server uses Google Cloud's Application Default Credentials (ADC) for authentication. Before using the server, you'll need to:
Set up authentication:
gcloud auth application-default loginFor more details, see the Google Cloud Authentication documentation.
Usage
Command Line
Start the server with your GA4 property ID:
mcp-server-ga4 --property-id YOUR_GA4_PROPERTY_IDThe server will use the standard MCP stdio transport by default.
Environment Variables
You can also set configuration via environment variables:
GA4_PROPERTY_ID: Your Google Analytics 4 property ID
Using with Claude Desktop
Install the server globally:
pip install mcp-server-ga4Set up your Google Cloud authentication:
gcloud auth application-default loginEdit your Claude Desktop configuration:
{
"mcpServers": {
"ga4": {
"command": "mcp-server-ga4",
"args": ["--property-id", "YOUR_GA4_PROPERTY_ID"]
}
}
}Available Tools
run-report
Runs a standard GA4 report with configurable metrics, dimensions, and date ranges.
Parameters:
property_id(optional): GA4 property ID (overrides the default)metrics: List of metric names (e.g., ["activeUsers", "sessions"])dimensions(optional): List of dimension names (e.g., ["date", "country"])date_range: Date range in one of these formats:{"start_date": "YYYY-MM-DD", "end_date": "YYYY-MM-DD"}"last7days","last30days","today","yesterday"
limit(optional): Number of rows to return (default: 10)
run-realtime-report
Gets real-time data for the past 30 minutes.
Parameters:
property_id(optional): GA4 property ID (overrides the default)metrics: List of metric names (e.g., ["activeUsers", "screenPageViews"])dimensions(optional): List of dimension names (e.g., ["country", "city"])limit(optional): Number of rows to return (default: 10)
get-metadata
Retrieves available metrics and dimensions for a GA4 property.
Parameters:
property_id(optional): GA4 property ID (overrides the default)type(optional): Type of metadata to retrieve ("metrics","dimensions", or"all", default:"all")
Examples
Running a standard report
What were the top 5 countries by active users in the last 30 days?Checking real-time data
How many users are currently active on the site?Getting metadata information
What metrics are available for me to query in GA4?Development
Clone the repository
Install development dependencies:
pip install -e ".[dev]"Run tests:
pytest
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceEnables AI agents to interact with Google Analytics 4 data, providing tools for historical reporting, real-time activity monitoring, and property management. It supports secure service account authentication to access metrics like traffic summaries, user acquisition, and custom dimensions.Last updatedMIT
- AlicenseAqualityCmaintenanceEnables LLMs to interact with Google Analytics Admin and Data APIs to retrieve account summaries, property details, and custom metrics. It allows users to run core and real-time reports to analyze website performance and configuration via natural language.Last updated71Apache 2.0
- AlicenseAqualityDmaintenanceEnables LLMs to interact with Google Analytics via Admin and Data APIs, allowing users to retrieve account summaries, run reports, and analyze realtime data.Last updated6Apache 2.0
- AlicenseBqualityDmaintenanceEnables LLM applications to query Google Analytics 4 data through standard MCP interfaces, supporting real-time data, custom reports, and metadata discovery.Last updated51521MIT
Related MCP Connectors
Gateway between LLM agents and world data through eight tools and a bundled endpoint catalog.
SEO research, audits, backlinks, GSC, and content workflow tools for AI agents.
AI marketing agent for Google Ads, Meta, GA4, TikTok, LinkedIn, Shopify, HubSpot and more.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/harshfolio/mcp-server-ga4'
If you have feedback or need assistance with the MCP directory API, please join our Discord server