MCP Server for Google Analytics 4
Enables LLMs to interact with Google Analytics 4 data through the Google Analytics Data API, supporting standard reports, real-time data, and metadata retrieval.
README
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
Installation
Using pip
pip install mcp-server-ga4
From 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:
- Create a Google Cloud project
- Enable the Google Analytics Data API
- Set up authentication:
gcloud auth application-default login
For 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_ID
The 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-ga4 - Set up your Google Cloud authentication:
gcloud auth application-default login - Edit 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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.