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 "Install 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 Serverget 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 ReportB
Get comprehensive Google Analytics data with custom dimensions and metrics. Can create any type of report.
| Name | Required | Description | Default |
|---|---|---|---|
| propertyId | Yes | Google Analytics property ID (e.g., 123456789). Required for all queries. | |
| startDate | Yes | Start date (YYYY-MM-DD) | |
| endDate | Yes | End date (YYYY-MM-DD) | |
| dimensions | No | Dimensions to query (e.g., country, pagePath, sessionSource) | |
| metrics | Yes | Metrics to query (e.g., activeUsers, sessions, screenPageViews) | |
| dimensionFilter | No | Filter by dimension values | |
| metricFilter | No | Filter by metric values | |
| orderBy | No | Sort results by dimension or metric | |
| limit | No | Limit number of results |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must disclose behavioral traits but fails to do so. It does not mention rate limits, data scope, complexity, or any side effects. The phrase 'Can create any type of report' is vague and may mislead about capabilities.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise—only two sentences—and front-loads the core purpose. Every word earns its place with no unnecessary fluff.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite the tool's complexity (9 parameters, nested objects, no output schema), the description is too brief. It omits information about response format, filtering behavior, or reporting flexibility, leaving significant gaps for an agent to navigate effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema covers all parameters with descriptions (100% coverage), so the description adds minimal value. It echoes 'custom dimensions and metrics' but provides no additional meaning or specifics about parameter usage beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it retrieves comprehensive Google Analytics data with custom dimensions and metrics, distinguishing it from sibling tools focused on metadata or realtime data. It uses a specific verb ('get') and resource ('Google Analytics data'), making the purpose unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus its siblings or alternatives. The description does not specify context, prerequisites, or exclusions, leaving the agent to infer usage without explicit direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_metadataGet Analytics MetadataC
Get available dimensions and metrics for Google Analytics property
| Name | Required | Description | Default |
|---|---|---|---|
| propertyId | Yes | Google Analytics property ID (e.g., 123456789). Required for all queries. | |
| type | No | Type of metadata to retrieve | both |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description bears full burden but only states what it retrieves. It omits behavioral traits like error handling, rate limits, or data freshness.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence is front-loaded and concise, stating the core purpose. However, given the lack of annotations, slightly more detail could be warranted without becoming verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema and minimal description leave significant gaps. The agent is not informed about the response structure, pagination, or what 'both' returns.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, providing adequate parameter descriptions. The tool's description adds no further meaning, meeting the baseline for high coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool retrieves available dimensions and metrics for a Google Analytics property, using a specific verb and resource. However, it does not differentiate from sibling 'search_metadata', which may also fetch metadata.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus alternatives like 'analytics_report' or 'search_metadata'. The description lacks context about prerequisites or exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
quick_insightsQuick InsightsC
Get predefined analytics insights for common use cases
| Name | Required | Description | Default |
|---|---|---|---|
| propertyId | Yes | Google Analytics property ID (e.g., 123456789). Required for all queries. | |
| startDate | Yes | Start date (YYYY-MM-DD) | |
| endDate | Yes | End date (YYYY-MM-DD) | |
| reportType | Yes | Type of quick insight report | |
| limit | No | Limit number of results |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, and the description gives no behavioral details (e.g., read-only, auth requirements, rate limits, or return format). Fails to compensate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One sentence, efficient but under-specified. It is front-loaded but too vague to earn full credit.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With 5 parameters and no output schema, the description should explain what the insights contain. It does not, leaving the tool incomplete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with parameter descriptions, so baseline is 3. The description does not add extra meaning beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states 'Get predefined analytics insights for common use cases,' which is vague but conveys that it's a quick report tool. It does not differentiate from sibling tools like 'analytics_report'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool versus alternatives. Does not specify that it is for predefined templates vs custom reports.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
realtime_dataReal-time DataC
Get real-time analytics data for current active users and activity
| Name | Required | Description | Default |
|---|---|---|---|
| propertyId | Yes | Google Analytics property ID (e.g., 123456789). Required for all queries. | |
| dimensions | No | Dimensions for real-time data (e.g., country, city, pagePath) | |
| metrics | No | Real-time metrics (default: activeUsers) | |
| limit | No | Limit number of results |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must fully disclose behavior. It only implies read-only via 'Get', but does not mention any side effects, authentication needs, rate limits, or data freshness. This is insufficient for safe agent invocation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single sentence that is front-loaded and contains no fluff. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema, no annotations, and 4 parameters (with one required), the description fails to explain return format, pagination, or how to effectively use dimensions and metrics. It is too minimal for an agent to invoke correctly without assumptions.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% and parameter descriptions are present. The description adds no extra meaning beyond the schema, so baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool retrieves real-time analytics data for active users and activity. It uses a specific verb ('Get') and resource, but does not explicitly differentiate from sibling tools like analytics_report or quick_insights, though the name implies real-time nature.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives, no usage conditions, or exclusions. It simply states what it does without contextual advice.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_metadataSearch Analytics MetadataB
Search for specific dimensions or metrics by name or category
| Name | Required | Description | Default |
|---|---|---|---|
| propertyId | Yes | Google Analytics property ID (e.g., 123456789). Required for all queries. | |
| query | Yes | Search term to find dimensions/metrics | |
| type | No | Type of metadata to search | both |
| category | No | Filter by category (e.g., "USER", "SESSION", "PAGE", "EVENT") |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It does not disclose behavioral traits such as read-only nature, pagination, rate limits, or result format. The description only hints at search functionality.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that is concise and to the point. It could be slightly improved by front-loading the action, but is efficient with no wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema, the description should explain return values or result format. It does not. The tool has 4 parameters and 2 required, but the description remains too brief to fully inform the agent's usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema documents all parameters. The description adds 'by name or category' which maps to 'query' and 'category', but doesn't provide additional semantics beyond what's in the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'search' and resource 'dimensions or metrics' with scope 'by name or category'. This distinguishes it from sibling tools like 'analytics_report' and 'get_metadata'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for searching metadata but does not explicitly state when to use this tool versus alternatives or when not to use it. No exclusions or alternatives are provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.0.5- First observed
analytics_report - First observed
get_metadata - First observed
quick_insights - First observed
realtime_data - First observed
search_metadata
TDQS
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.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
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.
Let AI agents query data and act across all your business apps via MCP.
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
- AlicenseAqualityCmaintenanceEnables 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.524MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Seey215/google-analytics-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server