Google Analytics MCP Server
Provides tools to query Google Analytics 4 data, including real-time data, custom reports with dimensions and metrics, quick insights, and metadata discovery.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Google Analytics MCP Server get my top pages from last month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Google Analytics MCP Server
A Model Context Protocol (MCP) server that provides seamless access to Google Analytics 4 data through standard MCP interfaces. This tool allows LLM applications to easily query and analyze Google Analytics data without directly dealing with the complexities of the Google Analytics Data API.
Features
Real-time Data Access: Get real-time analytics data for current active users and activity
Custom Reports: Create comprehensive reports with custom dimensions and metrics
Quick Insights: Predefined analytics insights for common use cases
Metadata Discovery: Get available dimensions and metrics for your Google Analytics property
Smart Error Handling: Detailed error messages with actionable solutions for permission issues
Standard MCP Interface: Works with any MCP-compatible client
Related MCP server: Google Analytics MCP Server
Installation
npm install @toolsdk.ai/google-analytics-mcpPrerequisites
Node.js >= 18.0.0
Google Analytics 4 property
Google Cloud service account with appropriate permissions
Setup
1. Google Cloud Service Account Setup
Create a Google Cloud service account with the "Viewer" role for your Google Analytics property
Download the service account key as JSON
Add the service account to your Google Analytics property with Viewer access:
Go to Google Analytics (analytics.google.com)
Navigate to Admin > Property Access Management
Add your service account email with Viewer access
2. Environment Configuration
Create a .env file in your project root with the following content:
GOOGLE_CREDENTIALS='{"type":"service_account","project_id":"your-project-id","private_key_id":"your-private-key-id","private_key":"-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n","client_email":"your-service-account@your-project.iam.gserviceaccount.com","client_id":"your-client-id","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/your-service-account%40your-project.iam.gserviceaccount.com"}'Note: Make sure to properly format the private key with \n for newlines.
Usage
Use ToolSDK.ai
import { ToolSDKApiClient } from 'toolsdk/api';
const toolSDK = new ToolSDKApiClient();
// Get Tools
const GoogleAnalyticsMCP = await toolSDK.package('@toolsdk.ai/google-analytics-mcp', {
GOOGLE_CREDENTIALS: process.env.GOOGLE_CREDENTIALS,
});Use Claude
{
"mcpServers": {
"google-analytics-mcp": {
"command": "npx",
"args": [
"-y",
"@toolsdk.ai/google-analytics-mcp"
],
"env": {
"GOOGLE_CREDENTIALS": "Your Google Credentials JSON String"
}
}
}
}Available Tools
analytics_report
Get comprehensive Google Analytics data with custom dimensions and metrics. Can create any type of report.
Parameters:
propertyId(string, required): Google Analytics property IDstartDate(string, required): Start date (YYYY-MM-DD)endDate(string, required): End date (YYYY-MM-DD)dimensions(array, optional): Dimensions to querymetrics(array, required): Metrics to querydimensionFilter(object, optional): Filter by dimension valuesmetricFilter(object, optional): Filter by metric valuesorderBy(object, optional): Sort results by dimension or metriclimit(number, optional): Limit number of results (default: 100)
realtime_data
Get real-time analytics data for current active users and activity.
Parameters:
propertyId(string, required): Google Analytics property IDdimensions(array, optional): Dimensions for real-time datametrics(array, optional): Real-time metrics (default: ['activeUsers'])limit(number, optional): Limit number of results (default: 50)
quick_insights
Get predefined analytics insights for common use cases.
Parameters:
propertyId(string, required): Google Analytics property IDstartDate(string, required): Start date (YYYY-MM-DD)endDate(string, required): End date (YYYY-MM-DD)reportType(string, required): Type of quick insight report (overview, top_pages, traffic_sources, etc.)limit(number, optional): Limit number of results (default: 20)
get_metadata
Get available dimensions and metrics for Google Analytics property.
Parameters:
propertyId(string, required): Google Analytics property IDtype(string, optional): Type of metadata to retrieve (dimensions, metrics, both)
search_metadata
Search for specific dimensions or metrics by name or category.
Parameters:
propertyId(string, required): Google Analytics property IDquery(string, required): Search term to find dimensions/metricstype(string, optional): Type of metadata to search (dimensions, metrics, both)category(string, optional): Filter by category
Error Handling
The server provides detailed error messages with actionable solutions:
Permission Errors: Clear instructions on how to grant access to your service account
Configuration Errors: Guidance on setting up environment variables correctly
API Errors: Detailed information about what went wrong with the Google Analytics API
License
MIT
Available Tools
5 toolsanalytics_reportAnalytics ReportC
Get comprehensive Google Analytics data with custom dimensions and metrics. Can create any type of report.
Inputs: propertyId (required), startDate (required), endDate (required), metrics (required), +5 more.
get_metadataGet Analytics MetadataA
Get available dimensions and metrics for Google Analytics property
Inputs: propertyId (required), type.
quick_insightsQuick InsightsC
Get predefined analytics insights for common use cases
Inputs: propertyId (required), startDate (required), endDate (required), reportType (required), +1 more.
realtime_dataReal-time DataC
Get real-time analytics data for current active users and activity
Inputs: propertyId (required), dimensions, metrics, limit.
search_metadataSearch Analytics MetadataC
Search for specific dimensions or metrics by name or category
Inputs: propertyId (required), query (required), type, category.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct aspect of Google Analytics: general-report, metadata, predefined insights, real-time data, and metadata search. There is no overlap, and even the general reporting tool is clearly separated from the predefined insights.
Tool names mix imperative verbs ('get_', 'search_') with descriptive noun phrases ('analytics_report', 'quick_insights', 'realtime_data'). This inconsistency makes the set less predictable, though all names are still readable.
With 5 tools, the server is well-scoped for providing core analytics data access: metadata discovery, predefined insights, real-time tracking, and a flexible custom report generator. The number feels neither too few nor excessive.
The tool surface covers the main data retrieval use cases (custom reports, real-time, insights, metadata). A minor gap is the lack of a tool to list or select Google Analytics properties, which may require prior knowledge of property IDs.
Related MCP Connectors
Read-only Google Analytics 4 MCP server for AI assistants.
The BigQuery remote MCP server is a fully managed service that uses the Model Context Protocol to connect AI applications and LLMs to BigQuery data sources. It provides secure, standardized tools for AI agents to list datasets and tables, retrieve schemas, generate and execute SQL queries through natural language, and analyze data—enabling direct access to enterprise analytics data without requiring manual SQL coding.
Connect Google Analytics to ChatGPT. Query GA4 data in plain English and get instant insights.
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables LLMs to interact with Google Analytics 4 data through the Google Analytics Data API, supporting standard reports, real-time data, and metadata retrieval.19MIT
- AlicenseNot gradedqualityDmaintenanceEnables querying Google Analytics 4 data using natural language through MCP clients like Claude and Cursor, supporting 200+ dimensions and metrics for traffic, user behavior, and e-commerce analysis.MIT
- AlicenseAqualityDmaintenanceEnables querying Google Analytics 4 properties using natural language through MCP clients. Supports customizable reports with any dimensions and metrics, listing properties, and real-time data.4MIT
- AlicenseAqualityDmaintenanceEnables LLM applications to query and analyze Google Analytics 4 data through standard MCP interfaces, supporting service account and OAuth2 authentication.541 npmMIT