Javi-Python/mcp-server-ga4
3.1
If you are the rightful owner of mcp-server-ga4 and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This guide provides instructions for setting up and running the MCP Server for Google Analytics 4 (GA4) in a local environment.
MCP GA4 Server Setup Guide
This guide explains how to set up and run the MCP Server for Google Analytics 4 (GA4) in your local environment.
1. Prerequisites
- Python 3.9+ (recommended: use a virtual environment)
- Google Cloud SDK (
gcloud
) installed and authenticated - Google Analytics Data API enabled in your Google Cloud project
- Access to your GA4 property ID
2. Setup Steps
2.1. Clone the Repository
git clone <your-repo-url>
cd <your-repo-folder>
2.2. Create and Activate a Virtual Environment
python3 -m venv .venv
source .venv/bin/activate
2.3. Install Dependencies
cd mcp-server-ga4
pip install -e ".[dev]"
Note: If you use
uv
instead of pip, you can run:
uv pip install -e ".[dev]"
3. Google Cloud Authentication
3.1. Remove Old Credentials (if troubleshooting)
rm ~/.config/gcloud/application_default_credentials.json
3.2. Authenticate with Correct Scopes
gcloud auth application-default login --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/analytics.readonly
- Log in with the Google account that has access to your GA4 property.
- Make sure the Google Analytics Data API is enabled in your project.
4. Running the Server
4.1. From the Command Line
mcp-server-ga4 --property-id <YOUR_GA4_PROPERTY_ID>
- If
mcp-server-ga4
is not found, use the full path from your virtual environment:/path/to/your/.venv/bin/mcp-server-ga4 --property-id <YOUR_GA4_PROPERTY_ID>
4.2. With Claude Desktop
In your claude_desktop_config.json
, use the full path to the executable:
"ga4": {
"command": "/absolute/path/to/your/.venv/bin/mcp-server-ga4",
"args": ["--property-id", "<YOUR_GA4_PROPERTY_ID>"]
}
5. Troubleshooting
- 403 Insufficient Authentication Scopes:
Make sure you authenticated with bothcloud-platform
andanalytics.readonly
scopes. - Permission Denied for Service Account:
Ensure your user has theService Account Token Creator
role if impersonating a service account. - Command Not Found:
Use the full path to themcp-server-ga4
executable from your virtual environment.
6. Useful Commands
- Check if
mcp-server-ga4
is available:which mcp-server-ga4
- Activate your virtual environment:
source /path/to/your/.venv/bin/activate
7. References
Keep this README up to date with any changes to your setup or workflow!