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
Metadata
Release files for iflow-mcp_harshfolio_mcp-server-ga4 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iflow_mcp_harshfolio_mcp_server_ga4-0.1.0.tar.gz | 8.4 kB | Without provenance | Details for iflow_mcp_harshfolio_mcp_server_ga4-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iflow_mcp_harshfolio_mcp_server_ga4-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for iflow_mcp_harshfolio_mcp_server_ga4-0.1.0-py3-none-any.whl |
Total release size: 18.1 kB
Release files / iflow_mcp_harshfolio_mcp_server_ga4-0.1.0.tar.gz
| Download URL | iflow_mcp_harshfolio_mcp_server_ga4-0.1.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ad08cdbe22fe6604e9b8aa9c0b442cba995ed698419654dcdfe31e1501363ac
|
|
BLAKE2b-256 checksum How to use checksums |
dc8078293b548dd23596c0dacffb0587456b8a9567b39eae832d5fed5790489c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / iflow_mcp_harshfolio_mcp_server_ga4-0.1.0-py3-none-any.whl
| Download URL | iflow_mcp_harshfolio_mcp_server_ga4-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3dc400a1c0cc4579a2b121f56a96f5f037470983d63e6295a2963def4f719c69
|
|
BLAKE2b-256 checksum How to use checksums |
e0ad9c7cd542b3d318412188ea08f5467b3e5615f9277a592974b6dfbd873e45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for iflow-mcp_harshfolio_mcp-server-ga4 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.