mcp -ga4
Model Context Protocol (MCP) server for Google Analytics 4 (GA4) that enables LLMs to access and analyze GA4 data
claude mcp add --transport stdio harshfolio-mcp-server-ga4 pipx run mcp-server-ga4 \ --env GA4_PROPERTY_ID="Your Google Analytics 4 property ID (optional; can be provided via --property-id as well)"
How to use
This MCP server provides an interface for LLMs to query Google Analytics 4 data through the GA4 Data API. It supports standard GA4 reports with configurable metrics, dimensions, and date ranges, as well as real-time data for the past 30 minutes and metadata about available metrics and dimensions. Authentication is handled via Google Cloud ADC (Application Default Credentials), making it straightforward to run in environments where you’ve already configured Google Cloud credentials. To use, install the server and run the CLI to expose an MCP-compatible endpoint that LLMs can interact with using the standard MCP tooling. Available tools around this server enable you to run a GA4 report, fetch real-time metrics, and retrieve metadata about GA4 properties.
How to install
Prerequisites:
- Python 3.8+ and pip
- Google Cloud SDK (for ADC authentication) or another ADC-compatible setup
Install the MCP GA4 server:
pip install mcp-server-ga4
Run the server directly (example):
mcp-server-ga4 --property-id YOUR_GA4_PROPERTY_ID
Alternatively, install and run via a package runner (recommended for environments using isolation):
pipx install mcp-server-ga4
#mcp-server-ga4 --property-id YOUR_GA4_PROPERTY_ID
For Claude Desktop integration, you can configure the MCP server in your Claude configuration and provide the --property-id flag or rely on the GA4_PROPERTY_ID environment variable.
Additional notes
Notes:
- The server authenticates using Google Cloud ADC. Ensure you have access to a Google Cloud project, the Analytics Data API enabled, and run gcloud auth application-default login if you’re using ADC locally.
- You can override the GA4 property ID per request using the property_id parameter in tool calls or set GA4_PROPERTY_ID in the environment to provide a default.
- If you deploy in Smithery or other orchestration environments, ensure the GA4 credentials and environment variables are securely managed.
- When querying, you can request standard reports via run-report, real-time data via run-realtime-report, and metadata via get-metadata. The API parameters include metrics, dimensions, date ranges, and optional limits.
- If you encounter permission or API quota issues, verify that the Google Analytics Data API is enabled and that the service account or ADC has access to the GA4 property.
Related MCP Servers
mcp-agent
Build effective agents using Model Context Protocol and simple workflow patterns
nerve
The Simple Agent Development Kit.
mcp-reddit
A Model Context Protocol (MCP) server that provides tools for fetching and analyzing Reddit content.
mcp-ical
A Model Context Protocol Server that allows you to interact with your MacOS Calendar through natural language.
mcp-twikit
A Model Context Protocol (MCP) server for interacting with Twitter.
mcp -odoo
A Model Context Protocol (MCP) server that enables AI assistants to securely interact with Odoo ERP systems through standardized resources and tools for data retrieval and manipulation.