home / mcp / analytics mcp server
Provides access to Google Analytics data and reports via an MCP API surface.
Configuration
View docs{
"mcpServers": {
"googleanalytics-google-analytics-mcp": {
"command": "pipx",
"args": [
"run",
"analytics-mcp"
],
"env": {
"GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID",
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON"
}
}
}
}You can run this MCP server locally to access Google Analytics data and reports through a structured API exposed to your preferred MCP client. It leverages Google Analytics Admin and Data APIs to fetch account info, property details, reports, and real-time data, enabling you to build powerful prompts and integrations for analytics workflows.
Use an MCP client (Gemini Code Assist or Gemini CLI) to load and invoke the analytics-mcp server. After you configure the server, you will see analytics-mcp listed as an available MCP on your client. You can then ask it to retrieve account summaries, property details, linked Google Ads accounts, run standard and real-time reports, or fetch custom dimensions and metrics for a property. Practical prompts include asking for top events, comparing property configurations over time, or listing which user segments performed best.
Prerequisites: you need Python and the Google Cloud SDK available on your system, plus the Gemini client you plan to use.
Install and configure the required tools step by step with these commands and actions.
1) Install Python and pipx, then ensure pipx is available on your system. 2) Enable the Google Analytics Admin API and Google Analytics Data API in your Google Cloud project using your cloud console. 3) Configure credentials to access Google Analytics with ADC (Application Default Credentials) that include the analytics.readonly scope.
# Authenticate with user credentials and obtain a credentials file
# You will be prompted to log in and authorize access to your Analytics data
# Save the credentials to a file path that you will reference below
# Example: Use gcloud to set up Application Default Credentials
# Modify PATH_TO_CREDENTIALS_JSON to your actual file path
# If you use a desktop/web OAuth client
gcloud auth application-default login \
--scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform \
--client-id-file=PATH_TO_CREDENTIALS_JSON
# Alternatively, for service account impersonation
gcloud auth application-default login \
--impersonate-service-account=SERVICE_ACCOUNT_EMAIL \
--scopes=https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform
```
```text
Credentials saved to file: [PATH_TO_CREDENTIALS_JSON]Create or edit the Gemini settings file at ~/.gemini/settings.json and add your MCP server to the mcpServers list. You must specify the command, arguments, and any required environment variables exactly as shown.
{
"mcpServers": {
"analytics-mcp": {
"command": "pipx",
"args": [
"run",
"analytics-mcp"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "PATH_TO_CREDENTIALS_JSON",
"GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID"
}
}
}
}Launch your Gemini Code Assist or Gemini CLI and look for analytics-mcp in the list of available MCP servers. Then start asking it to perform actions like retrieving account summaries, obtaining property details, listing Google Ads links, running reports, or fetching real-time data.
Keep your Google Cloud project ID and credentials secure. The MCP server requires read-only analytics scopes to access data. If you encounter permission issues, verify that the credentials you provide have access to the Google Analytics accounts or properties you intend to query.
If the analytics-mcp server does not appear in your MCP client, confirm that the settings.json file is correctly edited, the command is executable in your environment, and the credentials file path is valid. Ensure you have network access to Google APIs and that the required Google Analytics APIs are enabled in your project.
Retrieve a summary of Google Analytics accounts and properties available to the authenticated user.
Fetch detailed information about a specific Google Analytics property.
Return a list of Google Ads accounts linked to a Google Analytics property.
Execute a Google Analytics Data API report and return the results.
Retrieve custom dimensions and metrics defined for a property.
Run a real-time Google Analytics report via the Data API.